Provides a general interface to enable dynamic code compilation. More...
#include <codedFunctionObject.H>


Public Member Functions | |
| TypeName ("coded") | |
| Runtime type information. | |
| codedFunctionObject (const word &name, const Time &runTime, const dictionary &dict) | |
| Construct from name, Time and dictionary. | |
| virtual | ~codedFunctionObject ()=default |
| Destructor. | |
| functionObject & | redirectFunctionObject () const |
| Dynamically compiled functionObject. | |
| virtual bool | execute () |
| Called at each ++ or += of the time-loop. | |
| virtual bool | write () |
| Called at each ++ or += of the time-loop. | |
| virtual bool | end () |
| Called when Time::run() determines that the time-loop exits. | |
| virtual bool | read (const dictionary &) |
| Read and set the function object if its data have changed. | |
| Public Member Functions inherited from timeFunctionObject | |
| timeFunctionObject (const word &name, const Time &runTime) | |
| Construct from Time. | |
| virtual | ~timeFunctionObject ()=default |
| Destructor. | |
| const Time & | time () const |
| Return time database. | |
| objectRegistry & | storedObjects () |
| Write access to the output objects ("functionObjectObjects") registered on Time. | |
| const objectRegistry & | storedObjects () const |
| Const access to the output objects ("functionObjectObjects") registered on Time. | |
| Public Member Functions inherited from functionObject | |
| 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. | |
| autoPtr< functionObject > | clone () const |
| Return clone. | |
| virtual | ~functionObject ()=default |
| Destructor. | |
| virtual const word & | type () const =0 |
| Runtime type information. | |
| const word & | name () const noexcept |
| Return the name of this functionObject. | |
| bool | useNamePrefix () const noexcept |
| Return the flag for adding a scoping name prefix. | |
| bool | useNamePrefix (bool on) noexcept |
| Modify the flag for adding a scoping name prefix. | |
| virtual bool | execute (const label subIndex) |
| Execute using the specified subIndex. | |
| virtual bool | adjustTimeStep () |
| Called at the end of Time::adjustDeltaT() if adjustTime is true. | |
| virtual bool | filesModified () const |
| Did any file get changed during execution? | |
| virtual void | updateMesh (const mapPolyMesh &mpm) |
| Update for changes of mesh. | |
| virtual void | movePoints (const polyMesh &mesh) |
| Update for changes of mesh. | |
| Public Member Functions inherited from codedBase | |
| ClassName ("codedBase") | |
| Runtime type information. | |
| codedBase (const codedBase &)=delete | |
| No copy construct. | |
| void | operator= (const codedBase &)=delete |
| No copy assignment. | |
| codedBase ()=default | |
| Default construct. | |
| virtual | ~codedBase ()=default |
| Destructor. | |
Static Public Attributes | |
| static constexpr const char *const | codeTemplateC = "functionObjectTemplate.C" |
| Name of the C code template to be used. | |
| static constexpr const char *const | codeTemplateH = "functionObjectTemplate.H" |
| Name of the H code template to be used. | |
| Static Public Attributes inherited from functionObject | |
| static int | debug |
| Flag to execute debug content. | |
| static bool | postProcess |
| Global post-processing mode switch. | |
| static bool | defaultUseNamePrefix |
| Global default for useNamePrefix. | |
| static word | outputPrefix |
| Directory prefix. | |
Protected Member Functions | |
| virtual dlLibraryTable & | libs () const |
| Mutable access to the loaded dynamic libraries. | |
| virtual string | description () const |
| Description (type + name) for the output. | |
| virtual void | clearRedirect () const |
| Clear redirected object(s). | |
| virtual const dictionary & | codeContext () const |
| Additional 'codeContext' dictionary to pass through. | |
| virtual const dictionary & | codeDict () const |
| The code dictionary. | |
| virtual void | prepare (dynamicCode &, const dynamicCodeContext &) const |
| Adapt the context for the current object. | |
| codedFunctionObject (const codedFunctionObject &)=delete | |
| No copy construct. | |
| void | operator= (const codedFunctionObject &)=delete |
| No copy assignment. | |
| Protected Member Functions inherited from timeFunctionObject | |
| void | clearOutputObjects (const wordList &objNames) |
| Remove specified items from "functionObjectObjects". | |
| timeFunctionObject (const timeFunctionObject &)=delete | |
| No copy construct. | |
| void | operator= (const timeFunctionObject &)=delete |
| No copy assignment. | |
| Protected Member Functions inherited from functionObject | |
| word | scopedName (const word &name) const |
| Return a scoped (prefixed) name. | |
| Protected Member Functions inherited from codedBase | |
| dynamicCodeContext & | codeContext () |
| Access to the dynamic code context. | |
| void | setCodeContext (const dictionary &dict) |
| Set code context from a dictionary. | |
| void | append (const std::string &str) |
| Add content to SHA1 hashing. | |
| void | updateLibrary (const word &name, const dynamicCodeContext &context) const |
| Update library as required, using the given context. | |
| void | updateLibrary (const word &name, const dictionary &dict) const |
| Update library as required, using the given code dictionary to use for the context. | |
| void | updateLibrary (const word &name) const |
| Update library as required, using the predefined context or use the codeDict() to generate one. | |
Protected Attributes | |
| dictionary | dict_ |
| Input dictionary. | |
| word | name_ |
| string | codeData_ |
| string | codeRead_ |
| string | codeExecute_ |
| string | codeWrite_ |
| string | codeEnd_ |
| autoPtr< functionObject > | redirectFunctionObjectPtr_ |
| Underlying functionObject. | |
| Protected Attributes inherited from timeFunctionObject | |
| const Time & | time_ |
| Reference to the time database. | |
Additional Inherited Members | |
| Static Public Member Functions inherited from functionObject | |
| static autoPtr< functionObject > | New (const word &name, const Time &runTime, const dictionary &dict) |
| Select from dictionary, based on its "type" entry. | |
| Public Attributes inherited from functionObject | |
| bool | log |
| Flag to write log into Info. | |
| Static Protected Member Functions inherited from codedBase | |
| static void | writeCodeDict (Ostream &os, const dictionary &dict) |
| Write code-dictionary contents. | |
| static const dictionary & | codeDict (const objectRegistry &obr, const word &dictName="codeDict") |
| Return "codeDict" from objectRegistry or read from disk. | |
Provides a general interface to enable dynamic code compilation.
system/controlDict.functions: difference
{
// Mandatory entries
type coded;
libs (utilityFunctionObjects);
// Name of on-the-fly generated functionObject
name <word>; // writeMagU;
codeWrite
#{
// Lookup U
const volVectorField& U = mesh().lookupObject<volVectorField>("U");
// Write
mag(U)().write();
#};
...
// Inherited entries
...
}
where the entries mean:
| Property | Description | Type | Reqd | Deflt |
|---|---|---|---|---|
type | Type name: coded | word | yes | - |
libs | Library name: utilityFunctionObjects | word | yes | - |
name | Name of the function object | word | yes | - |
codeInclude | include files | word | no | - |
codeOptions | compiler line: added to EXE_INC (Make/options) | word | no | - |
codeLibs | linker line: added to LIB_LIBS (Make/options) | word | no | - |
codeData | c++; local member data (default constructed) | word | no | - |
localCode | c++; local static functions | word | no | - |
codeRead | c++; upon functionObject::read() | word | no | - |
codeExecute | c++; upon functionObject::execute() | word | no | - |
codeWrite | c++; upon functionObject::write() | word | no | - |
codeEnd | c++; upon functionObject::end() | word | no | - |
codeContext | additional dictionary context for the code | word | no | - |
The inherited entries are elaborated in:
codeContext entry.Definition at line 188 of file codedFunctionObject.H.
|
protecteddelete |
No copy construct.
References codedFunctionObject().
Referenced by codedFunctionObject(), and operator=().


| codedFunctionObject | ( | const word & | name, |
| const Time & | runTime, | ||
| const dictionary & | dict ) |
Construct from name, Time and dictionary.
Definition at line 127 of file codedFunctionObject.C.
References codedBase::codedBase(), dict, dict_, functionObject::name(), name_, read(), redirectFunctionObject(), runTime, timeFunctionObject::timeFunctionObject(), and codedBase::updateLibrary().

|
virtualdefault |
|
protectedvirtual |
Mutable access to the loaded dynamic libraries.
Implements codedBase.
Definition at line 50 of file codedFunctionObject.C.
References timeFunctionObject::time_.
|
protectedvirtual |
Description (type + name) for the output.
Implements codedBase.
Definition at line 56 of file codedFunctionObject.C.
References name.
|
protectedvirtual |
Clear redirected object(s).
Implements codedBase.
Definition at line 62 of file codedFunctionObject.C.
References redirectFunctionObjectPtr_.
|
protectedvirtual |
Additional 'codeContext' dictionary to pass through.
Definition at line 69 of file codedFunctionObject.C.
References dict_, keyType::LITERAL, and dictionary::null.
Referenced by redirectFunctionObject().

|
protectedvirtual |
The code dictionary.
Implements codedBase.
Definition at line 77 of file codedFunctionObject.C.
References dict_.
|
protectedvirtual |
Adapt the context for the current object.
Implements codedBase.
Definition at line 83 of file codedFunctionObject.C.
References dynamicCode::addCompileFile(), dynamicCode::addCopyFile(), codeData_, codeEnd_, codeExecute_, codeRead_, codeTemplateC, codeTemplateH, codeWrite_, DetailInfo, Foam::endl(), dynamicCodeContext::libs(), name_, dynamicCodeContext::options(), dynamicCode::setFilterVariable(), dynamicCode::setMakeOptions(), and dynamicCodeContext::sha1().

|
protecteddelete |
| TypeName | ( | "coded" | ) |
Runtime type information.
References dict, functionObject::name(), and runTime.

| Foam::functionObject & redirectFunctionObject | ( | ) | const |
Dynamically compiled functionObject.
Definition at line 148 of file codedFunctionObject.C.
References codeContext(), dict_, name_, functionObject::New(), Foam::nl, redirectFunctionObjectPtr_, dictionary::set(), timeFunctionObject::time_, and WarningInFunction.
Referenced by codedFunctionObject(), end(), execute(), read(), and write().


|
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 182 of file codedFunctionObject.C.
References name_, redirectFunctionObject(), and codedBase::updateLibrary().

|
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 189 of file codedFunctionObject.C.
References name_, redirectFunctionObject(), and codedBase::updateLibrary().

|
virtual |
Called when Time::run() determines that the time-loop exits.
By default it simply calls execute().
Reimplemented from functionObject.
Definition at line 196 of file codedFunctionObject.C.
References name_, redirectFunctionObject(), and codedBase::updateLibrary().

|
virtual |
Read and set the function object if its data have changed.
Reimplemented from functionObject.
Definition at line 203 of file codedFunctionObject.C.
References codedBase::codeContext(), codeData_, codeEnd_, codeExecute_, codeRead_, codeWrite_, dict, Foam::endl(), IOWarningInFunction, name_, Foam::nl, functionObject::read(), redirectFunctionObject(), codedBase::setCodeContext(), and codedBase::updateLibrary().
Referenced by codedFunctionObject().


|
protected |
Input dictionary.
Definition at line 200 of file codedFunctionObject.H.
Referenced by codeContext(), codedFunctionObject(), codeDict(), and redirectFunctionObject().
|
protected |
Definition at line 202 of file codedFunctionObject.H.
Referenced by codedFunctionObject(), end(), execute(), prepare(), read(), redirectFunctionObject(), and write().
|
protected |
Definition at line 204 of file codedFunctionObject.H.
|
protected |
Definition at line 205 of file codedFunctionObject.H.
|
protected |
Definition at line 206 of file codedFunctionObject.H.
|
protected |
Definition at line 207 of file codedFunctionObject.H.
|
protected |
Definition at line 208 of file codedFunctionObject.H.
|
mutableprotected |
Underlying functionObject.
Definition at line 213 of file codedFunctionObject.H.
Referenced by clearRedirect(), and redirectFunctionObject().
|
staticconstexpr |
Name of the C code template to be used.
Definition at line 267 of file codedFunctionObject.H.
Referenced by prepare().
|
staticconstexpr |
Name of the H code template to be used.
Definition at line 273 of file codedFunctionObject.H.
Referenced by prepare().