38 namespace functionEntries
57 {
"code",
"codeInclude",
"localCode"}
62 {
"dict", word::null, word::null}
72 "codeStreamTemplate.C"
78 bool Foam::functionEntries::codeStream::masterOnlyRead
81 const dictionary&
dict
89 <<
" master-only-reading:" << topDict.global()
97 Foam::string Foam::functionEntries::codeStream::codeString
100 const word& templateFunctionName,
102 const dictionary& contextDict,
108 const dictionary codeDict(
typeName, contextDict, is);
110 if (codeDict.found(
"codeInclude"))
113 <<
"codeInclude entry not supported within #codeBlock, "
114 "use #codeInclude instead."
120 templateFunctionName +
'(' +
Foam::name(index) +
")\n"
122 " #line " +
Foam::name(codeDict.lookup(
"code").lineNumber())
123 +
" \"" + codeDict.name() +
"\"\n"
124 + codeDict.lookup<verbatimString>(
"code")
130 Foam::string Foam::functionEntries::codeStream::codeString
133 const dictionary& contextDict,
140 "CODE_BLOCK_STREAM_FUNCTION",
148 void* Foam::functionEntries::codeStream::compile
151 const dictionary& contextDict,
152 const dictionary& codeDict,
153 const word& codeOptions,
176 const fileName libPath = dynCode.libPath();
190 lib = dynCode.loadLibrary(libPath);
196 dynCode.createLibrary
199 masterOnlyRead(
typeName, contextDict)
202 lib = dynCode.loadLibrary(libPath);
208 <<
"Failed loading library " << libPath <<
nl
209 <<
"Did you add all libraries to the 'libs' entry"
210 <<
" in system/controlDict?"
214 bool allHaveLib = lib;
215 if (!masterOnlyRead(
typeName, contextDict))
217 reduce(allHaveLib, andOp<bool>());
223 <<
"Failed loading library " << libPath
224 <<
" on some processors."
228 codeName = dynCode.codeSha1Name();
234 Foam::functionEntries::codeStream::streamingFunctionType
235 Foam::functionEntries::codeStream::getFunction
237 const dictionary& contextDict,
238 const dictionary& codeDict
253 const streamingFunctionType
function =
254 reinterpret_cast<streamingFunctionType
>
262 <<
"Failed looking up symbol " << codeName
272 const dictionary& contextDict,
278 Info<<
"Using " <<
typeName <<
" at line " << is.lineNumber()
279 <<
" in file " << contextDict.name() <<
endl;
284 const dictionary codeDict(
typeName, contextDict, is);
287 const streamingFunctionType
function = getFunction(contextDict, codeDict);
290 OTstream ots(is.name(), is.format());
291 ots.lineNumber() = is.lineNumber();
292 (*function)(ots, contextDict);
304 const label lineNumber,
314 const label lineNumber,
331 return insert(contextDict, resultStream(contextDict, is));
342 return insert(contextDict, contextEntry, resultStream(contextDict, is));
Functions used by OpenFOAM that are specific to POSIX compliant operating systems and need to be repl...
Inter-processor communication reduction functions.
Macros for easy insertion into member function selection tables.
Macros for easy insertion into run-time selection tables.
bool global() const
Return global state.
An Istream is an abstract base class for all input systems (streams, files, token lists etc)....
static const List< word > & null()
Return a null List.
const fileName & name() const
Return the dictionary name.
A list of keywords followed by any number of values (e.g. words and numbers) or sub-dictionaries.
const dictionary & topDict() const
Return the top of the tree.
void * findLibrary(const fileName &libName)
Find the handle of the named library.
Compiles and executes C++ OpenFOAM code string expressions.
static const word codeOptions
Name of the code options file to be used.
static const wordList codeKeys
Keywords associated with source code.
codeStream(const functionName &, const label lineNumber, const dictionary &)
Construct from function type and parent dictionary.
static const wordList compileFiles
Name of the C code template to be used.
static const wordList codeDictVars
Name of the dictionary variables in the source code.
virtual bool execute(dictionary &contextDict, Istream &)
Expand the functionEntry into the contextDict.
A functionEntry causes entries to be added/manipulated on the specified dictionary given an input str...
A functionName is a word starting with '#'.
A keyword and a list of tokens is a 'primitiveEntry'. An primitiveEntry can be read,...
const dictionary & dict() const
This entry is not a dictionary,.
A class for handling character strings derived from std::string.
Template function which returns the un-mangled name of a given type. Useful for types which do not ha...
A class for handling words, derived from string.
static const word null
An empty word.
#define FatalIOErrorInFunction(ios)
Report an error message using Foam::FatalIOError.
#define IOWarningInFunction(ios)
Report an IO warning using Foam::Warning.
defineFunctionTypeNameAndDebug(includeFvConstraintEntry, 0)
addToMemberFunctionSelectionTable(functionEntry, calcEntry, execute, primitiveEntryIstream)
addToRunTimeSelectionTable(functionEntry, includeFvConstraintEntry, dictionary)
void insert(const scalar, DynamicList< floatScalar > &)
Append scalar to given DynamicList.
errorManipArg< error, int > exit(error &err, const int errNo=1)
dlLibraryTable libs
Table of loaded dynamic libraries.
List< word > wordList
A List of words.
intWM_LABEL_SIZE_t label
A label is an int32_t or int64_t as specified by the pre-processor macro WM_LABEL_SIZE.
Ostream & endl(Ostream &os)
Add newline and flush stream.
void reduce(const List< UPstream::commsStruct > &comms, T &Value, const BinaryOp &bop, const int tag, const label comm)
word name(const LagrangianState state)
Return a string representation of a Lagrangian state enumeration.
prefixOSstream Pout(cout, "Pout")
void * dlSym(void *handle, const std::string &symbol)
Lookup a symbol in a dlopened library using handle to library.