Public Member Functions | Protected Member Functions | Protected Attributes | List of all members
codedFunctionObject Class Reference

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

Inheritance diagram for codedFunctionObject:
Inheritance graph
[legend]
Collaboration diagram for codedFunctionObject:
Collaboration graph
[legend]

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...
 
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...
 
- 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...
 
virtual ~functionObject ()
 Destructor. More...
 
const wordname () const
 Return the name of this functionObject. More...
 
virtual bool adjustTimeStep ()
 Called at the end of Time::adjustDeltaT() if adjustTime is true. 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...
 
- Public Member Functions inherited from codedBase
 ClassName ("codedBase")
 Runtime type information. More...
 
 codedBase ()
 Construct null. More...
 
virtual ~codedBase ()
 Destructor. 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
 
virtual void clearRedirect () const
 
virtual const dictionarycodeDict () const
 
- 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_
 
string codeData_
 
string codeRead_
 
string codeExecute_
 
string codeWrite_
 
string codeEnd_
 
autoPtr< functionObjectredirectFunctionObjectPtr_
 Underlying functionObject. 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 124 of file codedFunctionObject.H.

Constructor & Destructor Documentation

◆ codedFunctionObject()

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

Construct from Time and dictionary.

Definition at line 120 of file codedFunctionObject.C.

References Foam::read().

Here is the call graph for this function:

◆ ~codedFunctionObject()

~codedFunctionObject ( )
virtual

Destructor.

Definition at line 140 of file codedFunctionObject.C.

Member Function Documentation

◆ libs()

Foam::dlLibraryTable & libs ( ) const
protectedvirtual

Get the loaded dynamic libraries.

Implements codedBase.

Definition at line 93 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 53 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

Implements codedBase.

Definition at line 99 of file codedFunctionObject.C.

References Foam::name().

Here is the call graph for this function:

◆ clearRedirect()

void clearRedirect ( ) const
protectedvirtual

Implements codedBase.

Definition at line 105 of file codedFunctionObject.C.

◆ codeDict()

const Foam::dictionary & codeDict ( ) const
protectedvirtual

Implements codedBase.

Definition at line 111 of file codedFunctionObject.C.

◆ TypeName()

TypeName ( "coded"  )

Runtime type information.

◆ redirectFunctionObject()

Foam::functionObject & redirectFunctionObject ( ) const

Dynamically compiled functionObject.

Definition at line 146 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 164 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 171 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 178 of file codedFunctionObject.C.

◆ read()

bool read ( const dictionary dict)
virtual

Member Data Documentation

◆ time_

const Time& time_
protected

Reference to the time database.

Definition at line 134 of file codedFunctionObject.H.

◆ dict_

dictionary dict_
protected

Input dictionary.

Definition at line 137 of file codedFunctionObject.H.

◆ name_

word name_
protected

Definition at line 139 of file codedFunctionObject.H.

◆ codeData_

string codeData_
protected

Definition at line 141 of file codedFunctionObject.H.

◆ codeRead_

string codeRead_
protected

Definition at line 142 of file codedFunctionObject.H.

◆ codeExecute_

string codeExecute_
protected

Definition at line 143 of file codedFunctionObject.H.

◆ codeWrite_

string codeWrite_
protected

Definition at line 144 of file codedFunctionObject.H.

◆ codeEnd_

string codeEnd_
protected

Definition at line 145 of file codedFunctionObject.H.

◆ redirectFunctionObjectPtr_

autoPtr<functionObject> redirectFunctionObjectPtr_
mutableprotected

Underlying functionObject.

Definition at line 148 of file codedFunctionObject.H.


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