Provides a general interface to enable dynamic code compilation. More...
Public Member Functions | |
TypeName ("coded") | |
Runtime type information. More... | |
codedFunctionObject (const word &name, const Time &runTime, const dictionary &dict) | |
Construct from Time and dictionary. More... | |
virtual | ~codedFunctionObject ()=default |
Destructor. More... | |
functionObject & | redirectFunctionObject () const |
Dynamically compiled functionObject. More... | |
virtual bool | execute () |
Called at each ++ or += of the time-loop. More... | |
virtual bool | write () |
Called at each ++ or += of the time-loop. More... | |
virtual bool | end () |
Called when Time::run() determines that the time-loop exits. More... | |
virtual bool | read (const dictionary &) |
Read and set the function object if its data have changed. More... | |
![]() | |
timeFunctionObject (const word &name, const Time &runTime) | |
Construct from Time. More... | |
virtual | ~timeFunctionObject ()=default |
Destructor. More... | |
const Time & | time () const |
Return time database. More... | |
objectRegistry & | storedObjects () |
const objectRegistry & | storedObjects () const |
![]() | |
declareRunTimeSelectionTable (autoPtr, functionObject, dictionary,(const word &name, const Time &runTime, const dictionary &dict),(name, runTime, dict)) | |
functionObject (const word &name, const bool withNamePrefix=defaultUseNamePrefix) | |
Construct from components. More... | |
autoPtr< functionObject > | clone () const |
Return clone. More... | |
virtual | ~functionObject ()=default |
Destructor. More... | |
virtual const word & | type () const =0 |
Runtime type information. More... | |
const word & | name () const noexcept |
Return the name of this functionObject. More... | |
bool | useNamePrefix () const noexcept |
Return the flag for adding a scoping name prefix. More... | |
bool | useNamePrefix (bool on) noexcept |
Modify the flag for adding a scoping name prefix. More... | |
virtual bool | execute (const label subIndex) |
Execute using the specified subIndex. More... | |
virtual bool | adjustTimeStep () |
Called at the end of Time::adjustDeltaT() if adjustTime is true. More... | |
virtual bool | filesModified () const |
Did any file get changed during execution? More... | |
virtual void | updateMesh (const mapPolyMesh &mpm) |
Update for changes of mesh. More... | |
virtual void | movePoints (const polyMesh &mesh) |
Update for changes of mesh. More... | |
![]() | |
ClassName ("codedBase") | |
Runtime type information. More... | |
codedBase ()=default | |
Default construct. More... | |
virtual | ~codedBase ()=default |
Destructor. More... | |
Static Public Attributes | |
static constexpr const char *const | codeTemplateC = "functionObjectTemplate.C" |
Name of the C code template to be used. More... | |
static constexpr const char *const | codeTemplateH = "functionObjectTemplate.H" |
Name of the H code template to be used. More... | |
![]() | |
static int | debug |
Flag to execute debug content. More... | |
static bool | postProcess |
Global post-processing mode switch. More... | |
static bool | defaultUseNamePrefix |
Global default for useNamePrefix. More... | |
static word | outputPrefix |
Directory prefix. More... | |
Protected Member Functions | |
virtual dlLibraryTable & | libs () const |
Mutable access to the loaded dynamic libraries. More... | |
virtual string | description () const |
Description (type + name) for the output. More... | |
virtual void | clearRedirect () const |
Clear redirected object(s) More... | |
virtual const dictionary & | codeContext () const |
Additional 'codeContext' dictionary to pass through. More... | |
virtual const dictionary & | codeDict () const |
The code dictionary. More... | |
virtual void | prepare (dynamicCode &, const dynamicCodeContext &) const |
Adapt the context for the current object. More... | |
codedFunctionObject (const codedFunctionObject &)=delete | |
No copy construct. More... | |
void | operator= (const codedFunctionObject &)=delete |
No copy assignment. More... | |
![]() | |
void | clearOutputObjects (const wordList &objNames) |
Remove specified items from "functionObjectObjects". More... | |
timeFunctionObject (const timeFunctionObject &)=delete | |
No copy construct. More... | |
void | operator= (const timeFunctionObject &)=delete |
No copy assignment. More... | |
![]() | |
word | scopedName (const word &name) const |
Return a scoped (prefixed) name. More... | |
![]() | |
dynamicCodeContext & | codeContext () |
Access to the dynamic code context. More... | |
void | setCodeContext (const dictionary &dict) |
Set code context from a dictionary. More... | |
void | append (const std::string &str) |
Add content to SHA1 hashing. More... | |
void | updateLibrary (const word &name, const dynamicCodeContext &context) const |
Update library as required, using the given context. More... | |
void | updateLibrary (const word &name, const dictionary &dict) const |
void | updateLibrary (const word &name) const |
codedBase (const codedBase &)=delete | |
No copy construct. More... | |
void | operator= (const codedBase &)=delete |
No copy assignment. More... | |
Protected Attributes | |
dictionary | dict_ |
Input dictionary. More... | |
word | name_ |
string | codeData_ |
string | codeRead_ |
string | codeExecute_ |
string | codeWrite_ |
string | codeEnd_ |
autoPtr< functionObject > | redirectFunctionObjectPtr_ |
Underlying functionObject. More... | |
![]() | |
const Time & | time_ |
Reference to the time database. More... | |
Additional Inherited Members | |
![]() | |
static autoPtr< functionObject > | New (const word &name, const Time &runTime, const dictionary &dict) |
Select from dictionary, based on its "type" entry. More... | |
![]() | |
bool | log |
Flag to write log into Info. More... | |
![]() | |
static void | writeCodeDict (Ostream &os, const dictionary &dict) |
Write code-dictionary contents. More... | |
static const dictionary & | codeDict (const objectRegistry &obr, const word &dictName="codeDict") |
Return "codeDict" from objectRegistry or read from disk. More... | |
Provides a general interface to enable dynamic code compilation.
codeInclude | : | include files |
codeOptions | : | compiler line: added to EXE_INC (Make/options) |
codeLibs | : | linker line: added to LIB_LIBS (Make/options) |
codeData | : | c++; local member data (default constructed) |
localCode | : | c++; local static functions |
codeRead | : | c++; upon functionObject::read() |
codeExecute | : | c++; upon functionObject::execute() |
codeWrite | : | c++; upon functionObject::write() |
codeEnd | : | c++; upon functionObject::end() |
codeContext | : | additional dictionary context for the code |
difference { type coded; libs (utilityFunctionObjects); // Name of on-the-fly generated functionObject name writeMagU; codeWrite #{ // Lookup U const volVectorField& U = mesh().lookupObject<volVectorField>("U"); // Write mag(U)().write(); #}; }
codeContext
entry.Definition at line 140 of file codedFunctionObject.H.
|
protecteddelete |
No copy construct.
codedFunctionObject | ( | const word & | name, |
const Time & | runTime, | ||
const dictionary & | dict | ||
) |
Construct from Time and dictionary.
Definition at line 135 of file codedFunctionObject.C.
References Foam::read().
|
virtualdefault |
Destructor.
|
protectedvirtual |
Mutable access to the loaded dynamic libraries.
Implements codedBase.
Definition at line 57 of file codedFunctionObject.C.
References Time::libs(), and timeFunctionObject::time_.
|
protectedvirtual |
Description (type + name) for the output.
Implements codedBase.
Definition at line 63 of file codedFunctionObject.C.
References Foam::name().
|
protectedvirtual |
Clear redirected object(s)
Implements codedBase.
Definition at line 69 of file codedFunctionObject.C.
|
protectedvirtual |
Additional 'codeContext' dictionary to pass through.
Definition at line 76 of file codedFunctionObject.C.
References dictionary::findDict(), keyType::LITERAL, and dictionary::null.
|
protectedvirtual |
|
protectedvirtual |
Adapt the context for the current object.
Implements codedBase.
Definition at line 91 of file codedFunctionObject.C.
References dynamicCode::addCompileFile(), dynamicCode::addCopyFile(), DetailInfo, Foam::endl(), dynamicCodeContext::libs(), dynamicCodeContext::options(), dynamicCode::setFilterVariable(), dynamicCode::setMakeOptions(), and dynamicCodeContext::sha1().
|
protecteddelete |
No copy assignment.
TypeName | ( | "coded" | ) |
Runtime type information.
Foam::functionObject & redirectFunctionObject | ( | ) | const |
Dynamically compiled functionObject.
Definition at line 155 of file codedFunctionObject.C.
References dictionaryContent::dict(), functionObject::New(), Foam::nl, dictionary::set(), and WarningInFunction.
|
virtual |
Called at each ++ or += of the time-loop.
postProcess overrides the usual executeControl behaviour and forces execution (used in post-processing mode)
Implements functionObject.
Definition at line 189 of file codedFunctionObject.C.
|
virtual |
Called at each ++ or += of the time-loop.
postProcess overrides the usual writeControl behaviour and forces writing always (used in post-processing mode)
Implements functionObject.
Definition at line 196 of file codedFunctionObject.C.
|
virtual |
Called when Time::run() determines that the time-loop exits.
By default it simply calls execute().
Reimplemented from functionObject.
Definition at line 203 of file codedFunctionObject.C.
|
virtual |
Read and set the function object if its data have changed.
Reimplemented from functionObject.
Definition at line 210 of file codedFunctionObject.C.
References codedBase::codeContext(), dict, Foam::endl(), IOWarningInFunction, Foam::nl, functionObject::read(), and codedBase::setCodeContext().
|
protected |
Input dictionary.
Definition at line 150 of file codedFunctionObject.H.
|
protected |
Definition at line 152 of file codedFunctionObject.H.
|
protected |
Definition at line 154 of file codedFunctionObject.H.
|
protected |
Definition at line 155 of file codedFunctionObject.H.
|
protected |
Definition at line 156 of file codedFunctionObject.H.
|
protected |
Definition at line 157 of file codedFunctionObject.H.
|
protected |
Definition at line 158 of file codedFunctionObject.H.
|
mutableprotected |
Underlying functionObject.
Definition at line 161 of file codedFunctionObject.H.
|
staticconstexpr |
Name of the C code template to be used.
Definition at line 198 of file codedFunctionObject.H.
|
staticconstexpr |
Name of the H code template to be used.
Definition at line 202 of file codedFunctionObject.H.