Public Member Functions | Static Public Attributes | 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")
 
 codedFunctionObject (const word &name, const Time &runTime, const dictionary &dict)
 
virtual ~codedFunctionObject ()=default
 
functionObjectredirectFunctionObject () const
 
virtual bool execute ()
 
virtual bool write ()
 
virtual bool end ()
 
virtual bool read (const dictionary &)
 
- Public Member Functions inherited from timeFunctionObject
 timeFunctionObject (const word &name, const Time &runTime)
 
virtual ~timeFunctionObject ()=default
 
const Timetime () const
 
objectRegistrystoredObjects ()
 
const objectRegistrystoredObjects () const
 
- 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)
 
autoPtr< functionObjectclone () const
 
virtual ~functionObject ()=default
 
virtual const wordtype () const =0
 
const wordname () const noexcept
 
bool useNamePrefix () const noexcept
 
bool useNamePrefix (bool on) noexcept
 
virtual bool execute (const label subIndex)
 
virtual bool adjustTimeStep ()
 
virtual bool filesModified () const
 
virtual void updateMesh (const mapPolyMesh &mpm)
 
virtual void movePoints (const polyMesh &mesh)
 
- Public Member Functions inherited from codedBase
 ClassName ("codedBase")
 
 codedBase ()=default
 
virtual ~codedBase ()=default
 

Static Public Attributes

static constexpr const char *const codeTemplateC = "functionObjectTemplate.C"
 
static constexpr const char *const codeTemplateH = "functionObjectTemplate.H"
 
- Static Public Attributes inherited from functionObject
static int debug
 
static bool postProcess
 
static bool defaultUseNamePrefix
 
static word outputPrefix
 

Protected Member Functions

virtual dlLibraryTablelibs () const
 
virtual string description () const
 
virtual void clearRedirect () const
 
virtual const dictionarycodeContext () const
 
virtual const dictionarycodeDict () const
 
virtual void prepare (dynamicCode &, const dynamicCodeContext &) const
 
 codedFunctionObject (const codedFunctionObject &)=delete
 
void operator= (const codedFunctionObject &)=delete
 
- Protected Member Functions inherited from timeFunctionObject
void clearOutputObjects (const wordList &objNames)
 
 timeFunctionObject (const timeFunctionObject &)=delete
 
void operator= (const timeFunctionObject &)=delete
 
- Protected Member Functions inherited from functionObject
word scopedName (const word &name) const
 
- Protected Member Functions inherited from codedBase
dynamicCodeContextcodeContext ()
 
void setCodeContext (const dictionary &dict)
 
void append (const std::string &str)
 
void updateLibrary (const word &name, const dynamicCodeContext &context) const
 
void updateLibrary (const word &name, const dictionary &dict) const
 
void updateLibrary (const word &name) const
 
 codedBase (const codedBase &)=delete
 
void operator= (const codedBase &)=delete
 

Protected Attributes

dictionary dict_
 
word name_
 
string codeData_
 
string codeRead_
 
string codeExecute_
 
string codeWrite_
 
string codeEnd_
 
autoPtr< functionObjectredirectFunctionObjectPtr_
 
- Protected Attributes inherited from timeFunctionObject
const Timetime_
 

Additional Inherited Members

- Static Public Member Functions inherited from functionObject
static autoPtr< functionObjectNew (const word &name, const Time &runTime, const dictionary &dict)
 
- Public Attributes inherited from functionObject
bool log
 
- Static Protected Member Functions inherited from codedBase
static void writeCodeDict (Ostream &os, const dictionary &dict)
 
static const dictionarycodeDict (const objectRegistry &obr, const word &dictName="codeDict")
 

Detailed Description

Provides a general interface to enable dynamic code compilation.

The entries are:

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
Usage
Example of function object specification:
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();
    #};
}
Note
The code context dictionary can be supplied separately as the codeContext entry.
See also
Foam::functionObject Foam::codedBase
Source files

Definition at line 136 of file codedFunctionObject.H.

Constructor & Destructor Documentation

◆ codedFunctionObject() [1/2]

codedFunctionObject ( const codedFunctionObject )
protecteddelete

◆ codedFunctionObject() [2/2]

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

Definition at line 128 of file codedFunctionObject.C.

References Foam::read().

Here is the call graph for this function:

◆ ~codedFunctionObject()

virtual ~codedFunctionObject ( )
virtualdefault

Member Function Documentation

◆ libs()

Foam::dlLibraryTable & libs ( ) const
protectedvirtual

Implements codedBase.

Definition at line 50 of file codedFunctionObject.C.

References Time::libs(), and timeFunctionObject::time_.

Here is the call graph for this function:

◆ description()

Foam::string description ( ) const
protectedvirtual

Implements codedBase.

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

◆ codeContext()

const Foam::dictionary & codeContext ( ) const
protectedvirtual

Definition at line 69 of file codedFunctionObject.C.

References dictionary::findDict(), keyType::LITERAL, and dictionary::null.

Here is the call graph for this function:

◆ codeDict()

const Foam::dictionary & codeDict ( ) const
protectedvirtual

Implements codedBase.

Definition at line 77 of file codedFunctionObject.C.

◆ prepare()

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

◆ operator=()

void operator= ( const codedFunctionObject )
protecteddelete

◆ TypeName()

TypeName ( "coded"  )

◆ redirectFunctionObject()

Foam::functionObject & redirectFunctionObject ( ) const

Definition at line 148 of file codedFunctionObject.C.

References dictionaryContent::dict(), functionObject::New(), Foam::nl, dictionary::set(), and WarningInFunction.

Here is the call graph for this function:

◆ execute()

bool execute ( )
virtual

Implements functionObject.

Definition at line 182 of file codedFunctionObject.C.

◆ write()

bool write ( )
virtual

Implements functionObject.

Definition at line 189 of file codedFunctionObject.C.

◆ end()

bool end ( )
virtual

Reimplemented from functionObject.

Definition at line 196 of file codedFunctionObject.C.

◆ read()

bool read ( const dictionary dict)
virtual

Reimplemented from functionObject.

Definition at line 203 of file codedFunctionObject.C.

References codedBase::codeContext(), dict, Foam::endl(), IOWarningInFunction, Foam::nl, functionObject::read(), and codedBase::setCodeContext().

Here is the call graph for this function:

Member Data Documentation

◆ dict_

dictionary dict_
protected

Definition at line 146 of file codedFunctionObject.H.

◆ name_

word name_
protected

Definition at line 148 of file codedFunctionObject.H.

◆ codeData_

string codeData_
protected

Definition at line 150 of file codedFunctionObject.H.

◆ codeRead_

string codeRead_
protected

Definition at line 151 of file codedFunctionObject.H.

◆ codeExecute_

string codeExecute_
protected

Definition at line 152 of file codedFunctionObject.H.

◆ codeWrite_

string codeWrite_
protected

Definition at line 153 of file codedFunctionObject.H.

◆ codeEnd_

string codeEnd_
protected

Definition at line 154 of file codedFunctionObject.H.

◆ redirectFunctionObjectPtr_

autoPtr<functionObject> redirectFunctionObjectPtr_
mutableprotected

Definition at line 157 of file codedFunctionObject.H.

◆ codeTemplateC

constexpr const char* const codeTemplateC = "functionObjectTemplate.C"
staticconstexpr

Definition at line 194 of file codedFunctionObject.H.

◆ codeTemplateH

constexpr const char* const codeTemplateH = "functionObjectTemplate.H"
staticconstexpr

Definition at line 198 of file codedFunctionObject.H.


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