Public Member Functions | Protected Member Functions | Protected Attributes | Private Member Functions
codedFunctionObject Class Reference

This function object 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, bool readNow=true)
 Construct for given objectRegistry and dictionary. More...
 
virtual ~codedFunctionObject ()
 Destructor. More...
 
functionObjectredirectFunctionObject () const
 Dynamically compiled functionObject. More...
 
virtual bool start ()
 Called at the start of the time-loop. More...
 
virtual bool execute (const bool forceWrite)
 Called at each ++ or += of the time-loop. forceWrite overrides the. More...
 
virtual bool end ()
 Called when Time::run() determines that the time-loop exits. More...
 
virtual bool timeSet ()
 Called when time was set at the end of the Time::operator++. More...
 
virtual bool read (const dictionary &)
 Read and set the function object if its data have changed. More...
 
virtual void updateMesh (const mapPolyMesh &)
 Update mesh. More...
 
virtual void movePoints (const polyMesh &)
 Move points. 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 &t, const dictionary &dict),(name, t, dict))
 
 functionObject (const word &name)
 Construct from components. More...
 
autoPtr< functionObjectclone () const
 Return clone. More...
 
virtual ~functionObject ()
 Destructor. More...
 
virtual const wordname () const
 Name. More...
 
virtual bool adjustTimeStep ()
 Called at the end of Time::adjustDeltaT() if adjustTime is true. 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 &redirectType) const
 Update library as required. More...
 

Protected Attributes

const Timetime_
 Reference to the time database. More...
 
dictionary dict_
 Input dictionary. More...
 
word redirectType_
 
string codeData_
 
string codeRead_
 
string codeExecute_
 
string codeEnd_
 
string codeTimeSet_
 
autoPtr< functionObjectredirectFunctionObjectPtr_
 Underlying functionObject. More...
 

Private Member Functions

 codedFunctionObject (const codedFunctionObject &)
 Disallow default bitwise copy construct. More...
 
void operator= (const codedFunctionObject &)
 Disallow default bitwise assignment. 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...
 
- Static Public Attributes inherited from functionObject
static int debug
 

Detailed 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:

difference
{
    functionObjectLibs ("libutilityFunctionObjects.so");

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

Definition at line 91 of file codedFunctionObject.H.

Constructor & Destructor Documentation

◆ codedFunctionObject() [1/2]

Disallow default bitwise copy construct.

◆ codedFunctionObject() [2/2]

codedFunctionObject ( const word name,
const Time time,
const dictionary dict,
bool  readNow = true 
)

Construct for given objectRegistry and dictionary.

Allow the possibility to load fields from files

Definition at line 124 of file codedFunctionObject.C.

References Foam::read().

Here is the call graph for this function:

◆ ~codedFunctionObject()

~codedFunctionObject ( )
virtual

Destructor.

Definition at line 145 of file codedFunctionObject.C.

Member Function Documentation

◆ libs()

Foam::dlLibraryTable & libs ( ) const
protectedvirtual

Get the loaded dynamic libraries.

Implements codedBase.

Definition at line 97 of file codedFunctionObject.C.

References codedFunctionObject::time_.

◆ 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 103 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 109 of file codedFunctionObject.C.

◆ codeDict()

const Foam::dictionary & codeDict ( ) const
protectedvirtual

Implements codedBase.

Definition at line 115 of file codedFunctionObject.C.

◆ operator=()

void operator= ( const codedFunctionObject )
private

Disallow default bitwise assignment.

◆ TypeName()

TypeName ( "coded"  )

Runtime type information.

◆ redirectFunctionObject()

Foam::functionObject & redirectFunctionObject ( ) const

Dynamically compiled functionObject.

Definition at line 152 of file codedFunctionObject.C.

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

Here is the call graph for this function:

◆ start()

bool start ( )
virtual

Called at the start of the time-loop.

Implements functionObject.

Definition at line 170 of file codedFunctionObject.C.

◆ execute()

bool execute ( const bool  forceWrite)
virtual

Called at each ++ or += of the time-loop. forceWrite overrides the.

outputControl behaviour.

Implements functionObject.

Definition at line 177 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 184 of file codedFunctionObject.C.

◆ timeSet()

bool timeSet ( )
virtual

Called when time was set at the end of the Time::operator++.

Reimplemented from functionObject.

Definition at line 191 of file codedFunctionObject.C.

◆ read()

bool read ( const dictionary dict)
virtual

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

Implements functionObject.

Definition at line 198 of file codedFunctionObject.C.

References dynamicCodeContext::addLineDirective(), dict, Foam::stringOps::inplaceExpand(), dictionary::lookup(), dictionary::lookupEntryPtr(), dictionaryName::name(), entry::startLineNumber(), entry::stream(), and Foam::stringOps::trim().

Here is the call graph for this function:

◆ updateMesh()

void updateMesh ( const mapPolyMesh )
virtual

Update mesh.

Implements functionObject.

Definition at line 297 of file codedFunctionObject.C.

◆ movePoints()

void movePoints ( const polyMesh )
virtual

Move points.

Implements functionObject.

Definition at line 301 of file codedFunctionObject.C.

Field Documentation

◆ time_

const Time& time_
protected

Reference to the time database.

Definition at line 101 of file codedFunctionObject.H.

Referenced by codedFunctionObject::libs().

◆ dict_

dictionary dict_
protected

Input dictionary.

Definition at line 104 of file codedFunctionObject.H.

◆ redirectType_

word redirectType_
protected

Definition at line 106 of file codedFunctionObject.H.

◆ codeData_

string codeData_
protected

Definition at line 108 of file codedFunctionObject.H.

◆ codeRead_

string codeRead_
protected

Definition at line 109 of file codedFunctionObject.H.

◆ codeExecute_

string codeExecute_
protected

Definition at line 110 of file codedFunctionObject.H.

◆ codeEnd_

string codeEnd_
protected

Definition at line 111 of file codedFunctionObject.H.

◆ codeTimeSet_

string codeTimeSet_
protected

Definition at line 112 of file codedFunctionObject.H.

◆ redirectFunctionObjectPtr_

autoPtr<functionObject> redirectFunctionObjectPtr_
mutableprotected

Underlying functionObject.

Definition at line 115 of file codedFunctionObject.H.


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