Dictionary entry that contains C++ OpenFOAM code that is compiled to generate the entry itself. So. More...
Public Member Functions | |
ClassName ("codeStream") | |
Runtime type information. More... | |
![]() | |
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 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 dictionary & | topDict (const dictionary &) |
Helper function: parent (of parent etc.) of dictionary up to the top. More... | |
static dlLibraryTable & | libs (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... | |
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:
$
and ~
sequences)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
Definition at line 112 of file codeStream.H.
|
private |
Interpreter function type.
Definition at line 118 of file codeStream.H.
|
private |
Disallow default bitwise copy construct.
|
staticprivate |
Helper function: parent (of parent etc.) of dictionary up to the top.
|
staticprivate |
Helper function: access to dlLibraryTable of Time.
Definition at line 69 of file codeStream.C.
References dict, and IOobject::time().
|
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().
|
private |
Disallow default bitwise assignment.
ClassName | ( | "codeStream" | ) |
Runtime type information.
|
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().
|
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().
|
friend |
Declare friendship with the calcEntry class.
Definition at line 153 of file codeStream.H.
|
static |
Name of the C code template to be used.
Definition at line 148 of file codeStream.H.
Copyright © 2011-2018 OpenFOAM | OPENFOAM® is a registered trademark of OpenCFD Ltd.