diff --git a/etc/codeTemplates/dynamicCode/functionObjectTemplate.C b/etc/codeTemplates/dynamicCode/functionObjectTemplate.C index b44bdfb8dc..91b31dda2b 100644 --- a/etc/codeTemplates/dynamicCode/functionObjectTemplate.C +++ b/etc/codeTemplates/dynamicCode/functionObjectTemplate.C @@ -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}) diff --git a/etc/codeTemplates/dynamicCode/functionObjectTemplate.H b/etc/codeTemplates/dynamicCode/functionObjectTemplate.H index 211c0868ec..a139f25a8b 100644 --- a/etc/codeTemplates/dynamicCode/functionObjectTemplate.H +++ b/etc/codeTemplates/dynamicCode/functionObjectTemplate.H @@ -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&) {} diff --git a/src/parallel/distributed/distributedTriSurfaceMesh/distributedTriSurfaceMesh.C b/src/parallel/distributed/distributedTriSurfaceMesh/distributedTriSurfaceMesh.C index 7c80bd1a56..6d3ec9d7f1 100644 --- a/src/parallel/distributed/distributedTriSurfaceMesh/distributedTriSurfaceMesh.C +++ b/src/parallel/distributed/distributedTriSurfaceMesh/distributedTriSurfaceMesh.C @@ -183,10 +183,6 @@ void Foam::distributedTriSurfaceMesh::distributeSegment List >& 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()); diff --git a/src/postProcessing/functionObjects/utilities/codedFunctionObject/codedFunctionObject.C b/src/postProcessing/functionObjects/utilities/codedFunctionObject/codedFunctionObject.C index 5c1ed4a967..cd8c3e0169 100644 --- a/src/postProcessing/functionObjects/utilities/codedFunctionObject/codedFunctionObject.C +++ b/src/postProcessing/functionObjects/utilities/codedFunctionObject/codedFunctionObject.C @@ -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); } diff --git a/src/postProcessing/functionObjects/utilities/codedFunctionObject/codedFunctionObject.H b/src/postProcessing/functionObjects/utilities/codedFunctionObject/codedFunctionObject.H index f597407e1c..7b3f8f57e3 100644 --- a/src/postProcessing/functionObjects/utilities/codedFunctionObject/codedFunctionObject.H +++ b/src/postProcessing/functionObjects/utilities/codedFunctionObject/codedFunctionObject.H @@ -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("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 redirectFunctionObjectPtr_;