Public Member Functions | Static Public Member Functions | Static Public Attributes | Private Types | Private Member Functions | Static Private Member Functions | Friends
codeStream Class Reference

Dictionary entry that contains C++ OpenFOAM code that is compiled to generate the entry itself. So. More...

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

Public Member Functions

 ClassName ("codeStream")
 Runtime type information. More...
 
- Public Member Functions inherited from functionEntry
 declareMemberFunctionSelectionTable (bool, functionEntry, execute, dictionaryIstream,(dictionary &parentDict, Istream &is),(parentDict, is))
 
 declareMemberFunctionSelectionTable (bool, functionEntry, execute, primitiveEntryIstream,(const dictionary &parentDict, primitiveEntry &entry, Istream &is),(parentDict, entry, is))
 

Static Public Member Functions

static bool execute (dictionary &parentDict, Istream &)
 Execute the functionEntry in a sub-dict context. More...
 
static bool execute (const dictionary &parentDict, primitiveEntry &, Istream &)
 Execute the functionEntry in a primitiveEntry context. More...
 
- Static Public Member Functions inherited from functionEntry
static bool execute (const word &functionName, dictionary &parentDict, Istream &)
 Execute the functionEntry in a sub-dict context. More...
 
static bool execute (const word &functionName, const dictionary &parentDict, primitiveEntry &, Istream &)
 Execute the functionEntry in a primitiveEntry context. More...
 

Static Public Attributes

static const word codeTemplateC = "codeStreamTemplate.C"
 Name of the C code template to be used. More...
 

Private Types

typedef void(* streamingFunctionType) (Ostream &, const dictionary &)
 Interpreter function type. More...
 

Private Member Functions

 codeStream (const codeStream &)
 Disallow default bitwise copy construct. More...
 
void operator= (const codeStream &)
 Disallow default bitwise assignment. More...
 

Static Private Member Functions

static const dictionarytopDict (const dictionary &)
 Helper function: parent (of parent etc.) of dictionary up to the top. More...
 
static dlLibraryTablelibs (const dictionary &dict)
 Helper function: access to dlLibraryTable of Time. More...
 
static streamingFunctionType getFunction (const dictionary &parentDict, const dictionary &codeDict)
 Construct, compile, load and return streaming function. More...
 

Friends

class calcEntry
 Declare friendship with the calcEntry class. More...
 

Detailed Description

Dictionary entry that contains C++ OpenFOAM code that is compiled to generate the entry itself. So.

- codeStream reads three entries: 'code', 'codeInclude' (optional), 'codeOptions' (optional) and uses those to generate library sources inside codeStream/

E.g. to set the internal field of a field:

internalField  #codeStream
{
    code
    #{
        const IOdictionary& d = static_cast<const IOdictionary&>(dict);
        const fvMesh& mesh = refCast<const fvMesh>(d.db());
        scalarField fld(mesh.nCells(), 12.34);
        fld.writeEntry("", os);
    #};

    //! Optional:
    codeInclude
    #{
        #include "fvCFD.H"
    #};

    //! Optional:
    codeOptions
    #{
        -I$(LIB_SRC)/finiteVolume/lnInclude
    #};
};

Note the #{ ... #} syntax is a 'verbatim' input mode that allows inputting strings with embedded newlines.

Limitations:

Note
The code to be compiled is stored under the local codeStream directory with a subdirectory name corresponding to the SHA1 of the contents.

The corresponding library code is located under the local codeStream/platforms/$WM_OPTIONS/lib directory in a library libcodeStream_SHA1.so

Source files

Definition at line 112 of file codeStream.H.

Member Typedef Documentation

◆ streamingFunctionType

typedef void(* streamingFunctionType(Ostream &, const dictionary &)
private

Interpreter function type.

Definition at line 118 of file codeStream.H.

Constructor & Destructor Documentation

◆ codeStream()

codeStream ( const codeStream )
private

Disallow default bitwise copy construct.

Member Function Documentation

◆ topDict()

static const dictionary& topDict ( const dictionary )
staticprivate

Helper function: parent (of parent etc.) of dictionary up to the top.

◆ libs()

Foam::dlLibraryTable & libs ( const dictionary dict)
staticprivate

Helper function: access to dlLibraryTable of Time.

Definition at line 69 of file codeStream.C.

References dict, and IOobject::time().

Here is the call graph for this function:

◆ getFunction()

Foam::functionEntries::codeStream::streamingFunctionType getFunction ( const dictionary parentDict,
const dictionary codeDict 
)
staticprivate

Construct, compile, load and return streaming function.

Only block if we're not doing master-only reading. (flag set by

regIOobject::read, IOdictionary constructor)

Since the library has only been compiled on the master the

other nodes need to pick this library up through NFS We do this by just polling a few times using the fileModificationSkew.

Definition at line 80 of file codeStream.C.

References dynamicCode::addCompileFile(), dynamicCode::codeName(), dynamicCode::copyOrCreateFiles(), Foam::dlOpen(), Foam::dlSym(), Foam::endl(), Foam::exit(), Foam::FatalIOError, FatalIOErrorInFunction, Foam::fileSize(), dlLibraryTable::findLibrary(), Foam::Info, dynamicCode::libPath(), dynamicCode::libRelPath(), dynamicCodeContext::libs(), Foam::nl, dlLibraryTable::open(), dynamicCodeContext::options(), Foam::Pout, Foam::reduce(), dynamicCode::reset(), dynamicCode::setMakeOptions(), dynamicCodeContext::sha1(), Foam::sleep(), SHA1Digest::str(), dictionary::topDict(), dynamicCode::upToDate(), and dynamicCode::wmakeLibso().

Here is the call graph for this function:

◆ operator=()

void operator= ( const codeStream )
private

Disallow default bitwise assignment.

◆ ClassName()

ClassName ( "codeStream"  )

Runtime type information.

◆ execute() [1/2]

bool execute ( dictionary parentDict,
Istream is 
)
static

Execute the functionEntry in a sub-dict context.

Definition at line 359 of file codeStream.C.

References Foam::endl(), IOstream::format(), Foam::Info, IOstream::lineNumber(), dictionaryName::name(), and dictionary::read().

Here is the call graph for this function:

◆ execute() [2/2]

bool execute ( const dictionary parentDict,
primitiveEntry entry,
Istream is 
)
static

Execute the functionEntry in a primitiveEntry context.

Definition at line 325 of file codeStream.C.

References Foam::endl(), IOstream::format(), Foam::Info, IOstream::lineNumber(), and dictionaryName::name().

Here is the call graph for this function:

Friends And Related Function Documentation

◆ calcEntry

friend class calcEntry
friend

Declare friendship with the calcEntry class.

Definition at line 153 of file codeStream.H.

Field Documentation

◆ codeTemplateC

const Foam::word codeTemplateC = "codeStreamTemplate.C"
static

Name of the C code template to be used.

Definition at line 148 of file codeStream.H.


The documentation for this class was generated from the following files:
dict
dictionary dict
Definition: searchingEngine.H:14