codedFunctionObject Class Reference

Provides a general interface to enable dynamic code compilation. More...

Inheritance diagram for codedFunctionObject:
Collaboration diagram for codedFunctionObject:

Public Member Functions

 TypeName ("coded")
 Runtime type information. More...
 
 codedFunctionObject (const word &name, const Time &time, const dictionary &dict)
 Construct from Time and dictionary. More...
 
 codedFunctionObject (const codedFunctionObject &)=delete
 Disallow default bitwise copy construction. More...
 
virtual ~codedFunctionObject ()
 Destructor. More...
 
functionObjectredirectFunctionObject () 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...
 
void operator= (const codedFunctionObject &)=delete
 Disallow default bitwise assignment. More...
 
- Public Member Functions inherited from functionObject
virtual const wordtype () const =0
 Runtime type information. More...
 
 declareRunTimeSelectionTable (autoPtr, functionObject, dictionary,(const word &name, const Time &runTime, const dictionary &dict),(name, runTime, dict))
 
 functionObject (const word &name)
 Construct from components. More...
 
autoPtr< functionObjectclone () const
 Return clone. More...
 
 functionObject (const functionObject &)=delete
 Disallow default bitwise copy construction. More...
 
virtual ~functionObject ()
 Destructor. More...
 
const wordname () const
 Return the name of this functionObject. More...
 
virtual bool setTimeStep ()
 Called by Time::setDeltaT(). Allows the function object to override. More...
 
virtual scalar timeToNextWrite ()
 Called by Time::adjustTimeStep(). Allows the function object to. 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...
 
void operator= (const functionObject &)=delete
 Disallow default bitwise assignment. More...
 
- Public Member Functions inherited from codedBase
 ClassName ("codedBase")
 Runtime type information. More...
 
 codedBase ()
 Construct null. More...
 
 codedBase (const codedBase &)=delete
 Disallow default bitwise copy construction. More...
 
virtual ~codedBase ()
 Destructor. More...
 
void operator= (const codedBase &)=delete
 Disallow default bitwise assignment. More...
 

Protected Member Functions

virtual dlLibraryTablelibs () const
 Get the loaded dynamic libraries. More...
 
virtual void prepare (dynamicCode &, const dynamicCodeContext &) const
 Adapt the context for the current object. More...
 
virtual string description () const
 Return a description (type + name) for the output. More...
 
virtual void clearRedirect () const
 Clear any redirected objects. More...
 
virtual const dictionarycodeDict () const
 Get the dictionary to initialize the codeContext. More...
 
virtual const wordListcodeKeys () const
 Get the keywords associated with source code. More...
 
- Protected Member Functions inherited from codedBase
void updateLibrary (const word &name) const
 Update library as required. More...
 

Protected Attributes

const Timetime_
 Reference to the time database. More...
 
dictionary dict_
 Input dictionary. More...
 
word name_
 The name. More...
 
autoPtr< functionObjectredirectFunctionObjectPtr_
 Underlying functionObject. More...
 

Static Protected Attributes

static const wordList codeKeys_
 The keywords associated with source code. More...
 

Additional Inherited Members

- Static Public Member Functions inherited from functionObject
static autoPtr< functionObjectNew (const word &name, const Time &, const dictionary &)
 Select from dictionary, based on its "type" entry. More...
 
- Public Attributes inherited from functionObject
Switch log
 Switch write log to Info. More...
 
- Static Public Attributes inherited from functionObject
static int debug
 
static bool postProcess
 Global post-processing mode switch. More...
 

Detailed Description

Provides a general interface to enable dynamic code compilation.

The entries are:

codeInclude : include files
codeOptions : include paths; inserted into EXE_INC in Make/options
codeLibs : link line; inserted into LIB_LIBS in Make/options
codeData : c++; local member data (null 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();

Example of function object specification:

    difference
    {
        libs        ("libutilityFunctionObjects.so");

        type coded;
        // Name of on-the-fly generated functionObject
        name writeMagU;
        codeWrite
        #{
            // Lookup U
            const volVectorField& U = mesh().lookupObject<volVectorField>("U");
            // Write
            mag(U)().write();
        #};
    }
See also
Foam::functionObject Foam::codedBase
Source files

Definition at line 121 of file codedFunctionObject.H.

Constructor & Destructor Documentation

◆ codedFunctionObject() [1/2]

codedFunctionObject ( const word name,
const Time time,
const dictionary dict 
)

Construct from Time and dictionary.

Definition at line 135 of file codedFunctionObject.C.

References Foam::read().

Referenced by codedFunctionObject::codeKeys().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ codedFunctionObject() [2/2]

Disallow default bitwise copy construction.

◆ ~codedFunctionObject()

~codedFunctionObject ( )
virtual

Destructor.

Definition at line 152 of file codedFunctionObject.C.

Member Function Documentation

◆ libs()

Foam::dlLibraryTable & libs ( ) const
protectedvirtual

Get the loaded dynamic libraries.

Implements codedBase.

Definition at line 102 of file codedFunctionObject.C.

◆ prepare()

void prepare ( dynamicCode dynCode,
const dynamicCodeContext context 
) const
protectedvirtual

Adapt the context for the current object.

Implements codedBase.

Definition at line 68 of file codedFunctionObject.C.

References dynamicCode::addCompileFile(), dynamicCode::addCopyFile(), dynamicCodeContext::libs(), dynamicCodeContext::options(), dynamicCode::setFilterVariable(), and dynamicCode::setMakeOptions().

Here is the call graph for this function:

◆ description()

Foam::string description ( ) const
protectedvirtual

Return a description (type + name) for the output.

Implements codedBase.

Definition at line 108 of file codedFunctionObject.C.

References Foam::name().

Here is the call graph for this function:

◆ clearRedirect()

void clearRedirect ( ) const
protectedvirtual

Clear any redirected objects.

Implements codedBase.

Definition at line 114 of file codedFunctionObject.C.

◆ codeDict()

const Foam::dictionary & codeDict ( ) const
protectedvirtual

Get the dictionary to initialize the codeContext.

Implements codedBase.

Definition at line 120 of file codedFunctionObject.C.

◆ codeKeys()

const Foam::wordList & codeKeys ( ) const
protectedvirtual

Get the keywords associated with source code.

Implements codedBase.

Definition at line 126 of file codedFunctionObject.C.

References codedFunctionObject::codedFunctionObject().

Here is the call graph for this function:

◆ TypeName()

TypeName ( "coded"  )

Runtime type information.

◆ redirectFunctionObject()

Foam::functionObject & redirectFunctionObject ( ) const

Dynamically compiled functionObject.

Definition at line 158 of file codedFunctionObject.C.

References functionObject::New(), and dictionary::set().

Here is the call graph for this function:

◆ execute()

bool execute ( )
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 176 of file codedFunctionObject.C.

◆ write()

bool write ( )
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 183 of file codedFunctionObject.C.

◆ end()

bool end ( )
virtual

Called when Time::run() determines that the time-loop exits.

By default it simply calls execute().

Reimplemented from functionObject.

Definition at line 190 of file codedFunctionObject.C.

◆ read()

bool read ( const dictionary dict)
virtual

Read and set the function object if its data have changed.

Reimplemented from functionObject.

Definition at line 197 of file codedFunctionObject.C.

References dictionary::lookup(), dictionary::lookupOrDefault(), and word::null.

Here is the call graph for this function:

◆ operator=()

void operator= ( const codedFunctionObject )
delete

Disallow default bitwise assignment.

Member Data Documentation

◆ codeKeys_

const Foam::wordList codeKeys_
staticprotected
Initial value:
=
{
"codeData",
"codeEnd",
"codeExecute",
"codeInclude",
"codeRead",
"codeWrite",
"localCode"
}

The keywords associated with source code.

Definition at line 131 of file codedFunctionObject.H.

◆ time_

const Time& time_
protected

Reference to the time database.

Definition at line 137 of file codedFunctionObject.H.

◆ dict_

dictionary dict_
protected

Input dictionary.

Definition at line 140 of file codedFunctionObject.H.

◆ name_

word name_
protected

The name.

Definition at line 143 of file codedFunctionObject.H.

◆ redirectFunctionObjectPtr_

autoPtr<functionObject> redirectFunctionObjectPtr_
mutableprotected

Underlying functionObject.

Definition at line 146 of file codedFunctionObject.H.


The documentation for this class was generated from the following files: