mirror of
https://develop.openfoam.com/Development/openfoam.git
synced 2025-11-28 03:28:01 +00:00
BUG: codedFunctionObject: add timeSet functionality
This commit is contained in:
@ -2,7 +2,7 @@
|
||||
========= |
|
||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||
\\ / O peration |
|
||||
\\ / A nd | Copyright (C) 2011-2012 OpenFOAM Foundation
|
||||
\\ / A nd | Copyright (C) 2011-2013 OpenFOAM Foundation
|
||||
\\/ M anipulation |
|
||||
-------------------------------------------------------------------------------
|
||||
License
|
||||
@ -123,6 +123,19 @@ void ${typeName}FunctionObject::end()
|
||||
}
|
||||
|
||||
|
||||
void ${typeName}FunctionObject::timeSet()
|
||||
{
|
||||
if (${verbose:-false})
|
||||
{
|
||||
Info<<"timeSet ${typeName} sha1: ${SHA1sum}\n";
|
||||
}
|
||||
|
||||
//{{{ begin codeTime
|
||||
${codeTimeSet}
|
||||
//}}} end code
|
||||
}
|
||||
|
||||
|
||||
void ${typeName}FunctionObject::write()
|
||||
{
|
||||
if (${verbose:-false})
|
||||
|
||||
@ -127,6 +127,9 @@ public:
|
||||
//- Write, execute the "writeCalls"
|
||||
virtual void write();
|
||||
|
||||
//- Called when time was set at the end of the Time::operator++
|
||||
virtual void timeSet();
|
||||
|
||||
//- Update for changes of mesh
|
||||
virtual void updateMesh(const mapPolyMesh&)
|
||||
{}
|
||||
|
||||
@ -183,10 +183,6 @@ void Foam::distributedTriSurfaceMesh::distributeSegment
|
||||
List<DynamicList<label> >& sendMap
|
||||
) const
|
||||
{
|
||||
// Work points
|
||||
point clipPt;
|
||||
|
||||
|
||||
// 1. Fully local already handled outside. Note: retest is cheap.
|
||||
if (isLocal(procBb_[Pstream::myProcNo()], start, end))
|
||||
{
|
||||
@ -227,6 +223,9 @@ void Foam::distributedTriSurfaceMesh::distributeSegment
|
||||
// Scheme a: any processor that intersects the segment gets
|
||||
// the segment.
|
||||
|
||||
// Intersection point
|
||||
point clipPt;
|
||||
|
||||
if (bb.intersects(start, end, clipPt))
|
||||
{
|
||||
sendMap[procI].append(allSegments.size());
|
||||
|
||||
@ -61,6 +61,7 @@ void Foam::codedFunctionObject::prepare
|
||||
dynCode.setFilterVariable("codeExecute", codeExecute_);
|
||||
dynCode.setFilterVariable("codeEnd", codeEnd_);
|
||||
dynCode.setFilterVariable("codeData", codeData_);
|
||||
dynCode.setFilterVariable("codeTimeSet", codeTimeSet_);
|
||||
//dynCode.setFilterVariable("codeWrite", codeWrite_);
|
||||
|
||||
// compile filtered C template
|
||||
@ -187,7 +188,8 @@ bool Foam::codedFunctionObject::end()
|
||||
|
||||
bool Foam::codedFunctionObject::timeSet()
|
||||
{
|
||||
return false;
|
||||
updateLibrary(redirectType_);
|
||||
return redirectFunctionObject().timeSet();
|
||||
}
|
||||
|
||||
|
||||
@ -267,6 +269,24 @@ bool Foam::codedFunctionObject::read(const dictionary& dict)
|
||||
);
|
||||
}
|
||||
|
||||
const entry* timeSetPtr = dict.lookupEntryPtr
|
||||
(
|
||||
"codeTimeSet",
|
||||
false,
|
||||
false
|
||||
);
|
||||
if (timeSetPtr)
|
||||
{
|
||||
codeTimeSet_ = stringOps::trim(timeSetPtr->stream());
|
||||
stringOps::inplaceExpand(codeTimeSet_, dict);
|
||||
dynamicCodeContext::addLineDirective
|
||||
(
|
||||
codeTimeSet_,
|
||||
timeSetPtr->startLineNumber(),
|
||||
dict.name()
|
||||
);
|
||||
}
|
||||
|
||||
updateLibrary(redirectType_);
|
||||
return redirectFunctionObject().read(dict);
|
||||
}
|
||||
|
||||
@ -31,6 +31,39 @@ Description
|
||||
This function object provides a general interface to enable dynamic code
|
||||
compilation.
|
||||
|
||||
The entries are
|
||||
code : c++; upon functionObject::write()
|
||||
codeInclude : include files
|
||||
codeOptions : include paths; inserted into EXE_INC in Make/options
|
||||
codeLibs : link line; inserted into LIB_LIBS in Make/options
|
||||
|
||||
codeExecute : c++;upon functionObject::execute();
|
||||
codeRead : c++; upon functionObject::read();
|
||||
codeEnd : c++; upon functionObject::end();
|
||||
codeData : c++; local member data (null constructed);
|
||||
codeTimeSet : c++; upon functionObject::timeSet();
|
||||
localCode : c++; local static functions
|
||||
|
||||
Example of function object specification:
|
||||
\verbatim
|
||||
difference
|
||||
{
|
||||
functionObjectLibs ("libutilityFunctionObjects.so");
|
||||
|
||||
type coded;
|
||||
// Name of on-the-fly generated functionObject
|
||||
redirectType writeMagU;
|
||||
code
|
||||
#{
|
||||
// Lookup U
|
||||
const volVectorField& U = mesh().lookupObject<volVectorField>("U");
|
||||
// Write
|
||||
mag(U).write();
|
||||
}
|
||||
}
|
||||
\endverbatim
|
||||
|
||||
|
||||
SeeAlso
|
||||
Foam::functionObject
|
||||
Foam::OutputFilterFunctionObject
|
||||
@ -77,6 +110,7 @@ protected:
|
||||
string codeRead_;
|
||||
string codeExecute_;
|
||||
string codeEnd_;
|
||||
string codeTimeSet_;
|
||||
|
||||
//- Underlying functionObject
|
||||
mutable autoPtr<functionObject> redirectFunctionObjectPtr_;
|
||||
|
||||
Reference in New Issue
Block a user