Merge branch 'master' of ssh://noisy/home/noisy3/OpenFOAM/OpenFOAM-dev
This commit is contained in:
commit
c9ca457c87
@ -233,7 +233,11 @@
|
|||||||
- codedFixedValue could be extended to provide local data however
|
- codedFixedValue could be extended to provide local data however
|
||||||
in terms of complexity this is not really worthwhile.
|
in terms of complexity this is not really worthwhile.
|
||||||
|
|
||||||
- all templates come from
|
- all templates come from (in order of preference)
|
||||||
=etc/codeTemplates/dynamicCode=
|
|
||||||
=~/.OpenFOAM/dev/codeTemplates/dynamicCode=
|
|
||||||
=FOAM_TEMPLATE_DIR=
|
=FOAM_TEMPLATE_DIR=
|
||||||
|
=~/.OpenFOAM/dev/codeTemplates/dynamicCode=
|
||||||
|
=etc/codeTemplates/dynamicCode=
|
||||||
|
|
||||||
|
- any generated C++ code will display line numbers relative to the original
|
||||||
|
dictionary (using the '#line' directive) to ease finding compilation
|
||||||
|
errors.
|
||||||
|
@ -522,7 +522,7 @@ bool Foam::dynamicCode::copyOrCreateFiles(const bool verbose) const
|
|||||||
|
|
||||||
bool Foam::dynamicCode::wmakeLibso() const
|
bool Foam::dynamicCode::wmakeLibso() const
|
||||||
{
|
{
|
||||||
const Foam::string wmakeCmd("wmake -s libso " + this->codeRelPath());
|
const Foam::string wmakeCmd("wmake -s libso " + this->codePath());
|
||||||
Info<< "Invoking " << wmakeCmd << endl;
|
Info<< "Invoking " << wmakeCmd << endl;
|
||||||
|
|
||||||
if (Foam::system(wmakeCmd))
|
if (Foam::system(wmakeCmd))
|
||||||
|
@ -34,44 +34,57 @@ License
|
|||||||
Foam::dynamicCodeContext::dynamicCodeContext(const dictionary& dict)
|
Foam::dynamicCodeContext::dynamicCodeContext(const dictionary& dict)
|
||||||
:
|
:
|
||||||
dict_(dict),
|
dict_(dict),
|
||||||
code_(stringOps::trim(dict["code"])),
|
code_(),
|
||||||
localCode_(),
|
localCode_(),
|
||||||
include_(),
|
include_(),
|
||||||
options_(),
|
options_(),
|
||||||
libs_()
|
libs_()
|
||||||
{
|
{
|
||||||
// expand dictionary entries
|
// expand dictionary entries
|
||||||
stringOps::inplaceExpand(code_, dict);
|
|
||||||
|
{
|
||||||
|
const entry& codeEntry = dict.lookupEntry("code", false, false);
|
||||||
|
code_ = stringOps::trim(codeEntry.stream());
|
||||||
|
stringOps::inplaceExpand(code_, dict);
|
||||||
|
addLineDirective(code_, codeEntry.startLineNumber(), dict.name());
|
||||||
|
}
|
||||||
|
|
||||||
// note: removes any leading/trailing whitespace
|
// note: removes any leading/trailing whitespace
|
||||||
// - necessary for compilation options, convenient for includes
|
// - necessary for compilation options, convenient for includes
|
||||||
// and body.
|
// and body.
|
||||||
|
|
||||||
// optional
|
// optional
|
||||||
if (dict.found("localCode"))
|
const entry* includePtr = dict.lookupEntryPtr
|
||||||
|
(
|
||||||
|
"codeInclude",
|
||||||
|
false,
|
||||||
|
false
|
||||||
|
);
|
||||||
|
if (includePtr)
|
||||||
{
|
{
|
||||||
localCode_ = stringOps::trim(dict["localCode"]);
|
include_ = stringOps::trim(includePtr->stream());
|
||||||
stringOps::inplaceExpand(localCode_, dict);
|
|
||||||
}
|
|
||||||
|
|
||||||
// optional
|
|
||||||
if (dict.found("codeInclude"))
|
|
||||||
{
|
|
||||||
include_ = stringOps::trim(dict["codeInclude"]);
|
|
||||||
stringOps::inplaceExpand(include_, dict);
|
stringOps::inplaceExpand(include_, dict);
|
||||||
|
addLineDirective(include_, includePtr->startLineNumber(), dict.name());
|
||||||
}
|
}
|
||||||
|
|
||||||
// optional
|
// optional
|
||||||
if (dict.found("codeOptions"))
|
const entry* optionsPtr = dict.lookupEntryPtr
|
||||||
|
(
|
||||||
|
"codeOptions",
|
||||||
|
false,
|
||||||
|
false
|
||||||
|
);
|
||||||
|
if (optionsPtr)
|
||||||
{
|
{
|
||||||
options_ = stringOps::trim(dict["codeOptions"]);
|
options_ = stringOps::trim(optionsPtr->stream());
|
||||||
stringOps::inplaceExpand(options_, dict);
|
stringOps::inplaceExpand(options_, dict);
|
||||||
}
|
}
|
||||||
|
|
||||||
// optional
|
// optional
|
||||||
if (dict.found("codeLibs"))
|
const entry* libsPtr = dict.lookupEntryPtr("codeLibs", false, false);
|
||||||
|
if (libsPtr)
|
||||||
{
|
{
|
||||||
libs_ = stringOps::trim(dict["codeLibs"]);
|
libs_ = stringOps::trim(libsPtr->stream());
|
||||||
stringOps::inplaceExpand(libs_, dict);
|
stringOps::inplaceExpand(libs_, dict);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -82,4 +95,17 @@ Foam::dynamicCodeContext::dynamicCodeContext(const dictionary& dict)
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
// * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * * //
|
||||||
|
|
||||||
|
void Foam::dynamicCodeContext::addLineDirective
|
||||||
|
(
|
||||||
|
string& code,
|
||||||
|
const label lineNum,
|
||||||
|
const fileName& name
|
||||||
|
)
|
||||||
|
{
|
||||||
|
code = "#line " + Foam::name(lineNum) + " \"" + name + "\"\n" + code;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
// ************************************************************************* //
|
// ************************************************************************* //
|
||||||
|
@ -51,6 +51,7 @@ namespace Foam
|
|||||||
class dynamicCodeContext
|
class dynamicCodeContext
|
||||||
{
|
{
|
||||||
// Private data
|
// Private data
|
||||||
|
|
||||||
//- The parent dictionary context
|
//- The parent dictionary context
|
||||||
const dictionary& dict_;
|
const dictionary& dict_;
|
||||||
|
|
||||||
@ -123,6 +124,13 @@ public:
|
|||||||
return sha1_;
|
return sha1_;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//- Helper: add #line directive
|
||||||
|
static void addLineDirective
|
||||||
|
(
|
||||||
|
string&,
|
||||||
|
const label lineNum,
|
||||||
|
const fileName& name
|
||||||
|
);
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -241,10 +241,6 @@ void Foam::codedFixedValueFvPatchField<Type>::createLibrary
|
|||||||
// Write files for new library
|
// Write files for new library
|
||||||
if (!dynCode.upToDate(context))
|
if (!dynCode.upToDate(context))
|
||||||
{
|
{
|
||||||
Info<< "Using dynamicCode for patch " << this->patch().name()
|
|
||||||
<< " on field " << this->dimensionedInternalField().name()
|
|
||||||
<< endl;
|
|
||||||
|
|
||||||
// filter with this context
|
// filter with this context
|
||||||
dynCode.reset(context);
|
dynCode.reset(context);
|
||||||
|
|
||||||
@ -271,7 +267,7 @@ void Foam::codedFixedValueFvPatchField<Type>::createLibrary
|
|||||||
dynCode.setMakeOptions
|
dynCode.setMakeOptions
|
||||||
(
|
(
|
||||||
"EXE_INC = -g \\\n"
|
"EXE_INC = -g \\\n"
|
||||||
"-I$(LIB_SRC)/finiteVolume/lnInclude\\\n"
|
"-I$(LIB_SRC)/finiteVolume/lnInclude \\\n"
|
||||||
+ context.options()
|
+ context.options()
|
||||||
+ "\n\nLIB_LIBS = \\\n"
|
+ "\n\nLIB_LIBS = \\\n"
|
||||||
+ " -lOpenFOAM \\\n"
|
+ " -lOpenFOAM \\\n"
|
||||||
@ -343,6 +339,12 @@ void Foam::codedFixedValueFvPatchField<Type>::updateLibrary() const
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Info<< "Using dynamicCode for patch " << this->patch().name()
|
||||||
|
<< " on field " << this->dimensionedInternalField().name() << nl
|
||||||
|
<< "at line " << codeDict.startLineNumber()
|
||||||
|
<< " in " << codeDict.name() << endl;
|
||||||
|
|
||||||
|
|
||||||
// remove instantiation of fvPatchField provided by library
|
// remove instantiation of fvPatchField provided by library
|
||||||
redirectPatchFieldPtr_.clear();
|
redirectPatchFieldPtr_.clear();
|
||||||
|
|
||||||
|
@ -2,7 +2,7 @@
|
|||||||
========= |
|
========= |
|
||||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||||
\\ / O peration |
|
\\ / O peration |
|
||||||
\\ / A nd | Copyright (C) 2004-2010 OpenCFD Ltd.
|
\\ / A nd | Copyright (C) 2004-2011 OpenCFD Ltd.
|
||||||
\\/ M anipulation |
|
\\/ M anipulation |
|
||||||
-------------------------------------------------------------------------------
|
-------------------------------------------------------------------------------
|
||||||
License
|
License
|
||||||
@ -72,14 +72,14 @@ Foam::Pair<Foam::vector> Foam::searchableSurfaceWithGaps::offsetVecs
|
|||||||
}
|
}
|
||||||
|
|
||||||
offsets[0][minCmpt] = 1.0;
|
offsets[0][minCmpt] = 1.0;
|
||||||
// Orthogonalise
|
// Orthonormalise
|
||||||
offsets[0] -= n[minCmpt]*n;
|
offsets[0] -= n[minCmpt]*n;
|
||||||
// Scale
|
offsets[0] /= mag(offsets[0]);
|
||||||
offsets[0] *= gap_/mag(offsets[0]);
|
|
||||||
|
|
||||||
|
|
||||||
// Do second offset vector perp to original edge and first offset vector
|
// Do second offset vector perp to original edge and first offset vector
|
||||||
offsets[1] = n ^ offsets[0];
|
offsets[1] = n ^ offsets[0];
|
||||||
|
|
||||||
|
// Scale
|
||||||
|
offsets[0] *= gap_;
|
||||||
offsets[1] *= gap_;
|
offsets[1] *= gap_;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -240,7 +240,7 @@ void Foam::searchableSurfaceWithGaps::findLine
|
|||||||
// test in pairs: only if both perturbations hit something
|
// test in pairs: only if both perturbations hit something
|
||||||
// do we accept the hit.
|
// do we accept the hit.
|
||||||
|
|
||||||
const vectorField smallVec(SMALL*(compactEnd-compactStart));
|
const vectorField smallVec(1E-6*(compactEnd-compactStart));
|
||||||
|
|
||||||
List<pointIndexHit> plusInfo;
|
List<pointIndexHit> plusInfo;
|
||||||
surface().findLine
|
surface().findLine
|
||||||
@ -294,7 +294,7 @@ void Foam::searchableSurfaceWithGaps::findLine
|
|||||||
offset0.setSize(plusMissMap.size());
|
offset0.setSize(plusMissMap.size());
|
||||||
offset1.setSize(plusMissMap.size());
|
offset1.setSize(plusMissMap.size());
|
||||||
|
|
||||||
const vectorField smallVec(SMALL*(compactEnd-compactStart));
|
const vectorField smallVec(1E-6*(compactEnd-compactStart));
|
||||||
|
|
||||||
surface().findLine
|
surface().findLine
|
||||||
(
|
(
|
||||||
|
@ -2,7 +2,7 @@
|
|||||||
========= |
|
========= |
|
||||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||||
\\ / O peration |
|
\\ / O peration |
|
||||||
\\ / A nd | Copyright (C) 2004-2010 OpenCFD Ltd.
|
\\ / A nd | Copyright (C) 2004-2011 OpenCFD Ltd.
|
||||||
\\/ M anipulation |
|
\\/ M anipulation |
|
||||||
-------------------------------------------------------------------------------
|
-------------------------------------------------------------------------------
|
||||||
License
|
License
|
||||||
@ -573,6 +573,9 @@ const Foam::indexedOctree<Foam::treeDataEdge>&
|
|||||||
bb.min() -= point(ROOTVSMALL, ROOTVSMALL, ROOTVSMALL);
|
bb.min() -= point(ROOTVSMALL, ROOTVSMALL, ROOTVSMALL);
|
||||||
bb.max() += point(ROOTVSMALL, ROOTVSMALL, ROOTVSMALL);
|
bb.max() += point(ROOTVSMALL, ROOTVSMALL, ROOTVSMALL);
|
||||||
|
|
||||||
|
scalar oldTol = indexedOctree<treeDataTriSurface>::perturbTol();
|
||||||
|
indexedOctree<treeDataEdge>::perturbTol() = tolerance_;
|
||||||
|
|
||||||
edgeTree_.reset
|
edgeTree_.reset
|
||||||
(
|
(
|
||||||
new indexedOctree<treeDataEdge>
|
new indexedOctree<treeDataEdge>
|
||||||
@ -590,6 +593,8 @@ const Foam::indexedOctree<Foam::treeDataEdge>&
|
|||||||
3.0 // duplicity
|
3.0 // duplicity
|
||||||
)
|
)
|
||||||
);
|
);
|
||||||
|
|
||||||
|
indexedOctree<treeDataEdge>::perturbTol() = oldTol;
|
||||||
}
|
}
|
||||||
return edgeTree_();
|
return edgeTree_();
|
||||||
}
|
}
|
||||||
|
@ -188,9 +188,6 @@ void Foam::codedFunctionObject::createLibrary
|
|||||||
// Write files for new library
|
// Write files for new library
|
||||||
if (!dynCode.upToDate(context))
|
if (!dynCode.upToDate(context))
|
||||||
{
|
{
|
||||||
Info<< "Using dynamicCode for functionObject " << name()
|
|
||||||
<< endl;
|
|
||||||
|
|
||||||
// filter with this context
|
// filter with this context
|
||||||
dynCode.reset(context);
|
dynCode.reset(context);
|
||||||
|
|
||||||
@ -282,6 +279,11 @@ void Foam::codedFunctionObject::updateLibrary() const
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Info<< "Using dynamicCode for functionObject " << name()
|
||||||
|
<< " at line " << dict_.startLineNumber()
|
||||||
|
<< " in " << dict_.name() << endl;
|
||||||
|
|
||||||
|
|
||||||
// remove instantiation of fvPatchField provided by library
|
// remove instantiation of fvPatchField provided by library
|
||||||
redirectFunctionObjectPtr_.clear();
|
redirectFunctionObjectPtr_.clear();
|
||||||
|
|
||||||
@ -375,21 +377,60 @@ bool Foam::codedFunctionObject::read(const dictionary& dict)
|
|||||||
{
|
{
|
||||||
dict.lookup("redirectType") >> redirectType_;
|
dict.lookup("redirectType") >> redirectType_;
|
||||||
|
|
||||||
if (dict.found("codeRead"))
|
const entry* readPtr = dict.lookupEntryPtr
|
||||||
|
(
|
||||||
|
"codeRead",
|
||||||
|
false,
|
||||||
|
false
|
||||||
|
);
|
||||||
|
if (readPtr)
|
||||||
{
|
{
|
||||||
codeRead_ = stringOps::trim(dict["codeRead"]);
|
codeRead_ = stringOps::trim(readPtr->stream());
|
||||||
stringOps::inplaceExpand(codeRead_, dict);
|
stringOps::inplaceExpand(codeRead_, dict);
|
||||||
|
dynamicCodeContext::addLineDirective
|
||||||
|
(
|
||||||
|
codeRead_,
|
||||||
|
readPtr->startLineNumber(),
|
||||||
|
dict.name()
|
||||||
|
);
|
||||||
}
|
}
|
||||||
if (dict.found("codeExecute"))
|
|
||||||
|
const entry* execPtr = dict.lookupEntryPtr
|
||||||
|
(
|
||||||
|
"codeExecute",
|
||||||
|
false,
|
||||||
|
false
|
||||||
|
);
|
||||||
|
if (execPtr)
|
||||||
{
|
{
|
||||||
codeExecute_ = stringOps::trim(dict["codeExecute"]);
|
codeExecute_ = stringOps::trim(execPtr->stream());
|
||||||
stringOps::inplaceExpand(codeExecute_, dict);
|
stringOps::inplaceExpand(codeExecute_, dict);
|
||||||
|
dynamicCodeContext::addLineDirective
|
||||||
|
(
|
||||||
|
codeExecute_,
|
||||||
|
execPtr->startLineNumber(),
|
||||||
|
dict.name()
|
||||||
|
);
|
||||||
}
|
}
|
||||||
if (dict.found("codeEnd"))
|
|
||||||
|
const entry* endPtr = dict.lookupEntryPtr
|
||||||
|
(
|
||||||
|
"codeEnd",
|
||||||
|
false,
|
||||||
|
false
|
||||||
|
);
|
||||||
|
if (execPtr)
|
||||||
{
|
{
|
||||||
codeEnd_ = stringOps::trim(dict["codeEnd"]);
|
codeEnd_ = stringOps::trim(endPtr->stream());
|
||||||
stringOps::inplaceExpand(codeEnd_, dict);
|
stringOps::inplaceExpand(codeEnd_, dict);
|
||||||
|
dynamicCodeContext::addLineDirective
|
||||||
|
(
|
||||||
|
codeEnd_,
|
||||||
|
endPtr->startLineNumber(),
|
||||||
|
dict.name()
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
updateLibrary();
|
updateLibrary();
|
||||||
return redirectFunctionObject().read(dict);
|
return redirectFunctionObject().read(dict);
|
||||||
}
|
}
|
||||||
|
@ -277,6 +277,8 @@ void Foam::sampledSurfaces::read(const dictionary& dict)
|
|||||||
void Foam::sampledSurfaces::updateMesh(const mapPolyMesh&)
|
void Foam::sampledSurfaces::updateMesh(const mapPolyMesh&)
|
||||||
{
|
{
|
||||||
expire();
|
expire();
|
||||||
|
|
||||||
|
// pointMesh and interpolation will have been reset in mesh.update
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -327,10 +329,6 @@ bool Foam::sampledSurfaces::expire()
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// reset interpolation
|
|
||||||
pointMesh::Delete(mesh_);
|
|
||||||
volPointInterpolation::Delete(mesh_);
|
|
||||||
|
|
||||||
// true if any surfaces just expired
|
// true if any surfaces just expired
|
||||||
return justExpired;
|
return justExpired;
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user