58 primitiveEntryIstream,
88 masterOnly = rioPtr->global();
92 <<
"codeStream : " << (rioPtr ?
"IO" :
"plain")
93 <<
" dictionary:" <<
dict.name()
94 <<
" master-only-reading:" << masterOnly <<
endl;
112 std::string sha1Str(context.
sha1().
str(
true));
113 dynamicCode dynCode(
"codeStream" + sha1Str, sha1Str);
117 const bool masterOnly = doingMasterOnlyReading(topDict);
128 lib = libs(parentDict).findLibrary(libPath);
136 <<
"Using #codeStream with " << libPath <<
endl;
141 lib = libs(parentDict).open(libPath,
false);
163 dynCode.
reset(context);
173 +
"\n\nLIB_LIBS = \\\n"
181 <<
"Failed writing files for" <<
nl
218 lib = libs(parentDict).open(libPath,
false);
230 <<
"Failed loading library " << dynCode.
libRelPath()
231 <<
" on some processors."
232 <<
"Did you add all libraries to the 'libs' entry"
233 <<
" in system/controlDict?"
239 streamingFunctionType function =
240 reinterpret_cast<streamingFunctionType
>
249 <<
"Failed looking up symbol " << dynCode.
codeName()
265 <<
"Using #codeStream at line " << is.
lineNumber()
270 "functionEntries::codeStream::evaluate(..)",
275 dictionary codeDict(
"#codeStream", parentDict, is);
280 streamingFunctionType function = getFunction(parentDict, codeDict);
281 (*function)(
os, parentDict);
298 entry.read(parentDict, result);
311 parentDict.
read(result);
Input/output from string buffers.
Macros for easy insertion into member function selection tables.
#define addNamedToMemberFunctionSelectionTable(baseType, thisType, funcName, argNames, lookupName)
Add to hash-table of functions with 'lookupName' as the key.
const Time & time() const noexcept
Return Time associated with the objectRegistry.
static float fileModificationSkew
Time skew (seconds) for file modification checks.
streamFormat format() const noexcept
Get the current stream format.
label lineNumber() const noexcept
Const access to the current stream line number.
Input from string buffer, using a ISstream. Always UNCOMPRESSED.
An Istream is an abstract base class for all input systems (streams, files, token lists etc)....
Output to string buffer, using a OSstream. Always UNCOMPRESSED.
std::string str(const bool prefixed=false) const
The digest (40-byte) text representation, optionally with '_' prefix.
dlLibraryTable & libs() const noexcept
Mutable access to the loaded dynamic libraries.
static bool master(const label communicator=worldComm)
True if process corresponds to the master rank in the communicator.
static label worldComm
Communicator for all ranks. May differ from commGlobal() if local worlds are in use.
baseIOdictionary is derived from dictionary and IOobject to give the dictionary automatic IO function...
A list of keyword definitions, which are a keyword followed by a number of values (eg,...
const dictionary & topDict() const
Return the top of the tree.
fileName relativeName(const bool caseTag=false) const
The dictionary name relative to the case.
bool read(Istream &is)
Read dictionary from Istream (discards the header). Reads entries until EOF or when the first token i...
A table of dynamically loaded libraries.
Encapsulation of dynamic code dictionaries.
const string & libs() const noexcept
The code libs (LIB_LIBS).
const SHA1 & sha1() const noexcept
The SHA1 calculated from options, libs, include, code, etc.
const string & options() const noexcept
The code options (Make/options).
const dictionary & dict() const noexcept
Return the parent dictionary context.
Tools for handling dynamic code compilation.
bool copyOrCreateFiles(const bool verbose=false) const
Copy/create files prior to compilation.
void reset(const dynamicCodeContext &)
Clear files and reset variables to specified context.
fileName libRelPath() const
Library path for specified code name relative to <case>.
static void waitForFile(const fileName &file, const dictionary &contextDict)
Wait for libPath() file to appear on sub-ranks.
static void checkSecurity(const char *title, const dictionary &)
Check security for creating dynamic code.
void addCompileFile(const fileName &name)
Add a file template name, which will be found and filtered.
bool upToDate(const dynamicCodeContext &context) const
Verify if the copied code is up-to-date, based on Make/SHA1Digest.
fileName libPath() const
Library path for specified code name.
bool wmakeLibso() const
Compile a libso.
void setMakeOptions(const std::string &content)
Define contents for Make/options.
const word & codeName() const noexcept
Return the code-name.
entry(const keyType &keyword)
Construct from keyword.
A class for handling file names.
Dictionary entry that contains C++ OpenFOAM code that is compiled to generate the entry itself....
static bool doingMasterOnlyReading(const dictionary &dict)
Helper: access IOobject for master-only-reading functionality.
static streamingFunctionType getFunction(const dictionary &parentDict, const dictionary &codeDict)
Construct, compile, load and return streaming function.
static bool execute(const dictionary &parentDict, primitiveEntry &entry, Istream &is)
Execute in a primitiveEntry context.
void(* streamingFunctionType)(Ostream &, const dictionary &)
Interpreter function type.
static string evaluate(const dictionary &parentDict, Istream &is)
Evaluate dynamically compiled code, returning result as string.
static dlLibraryTable & libs(const dictionary &dict)
Helper function: access to dlLibraryTable of Time.
static constexpr const char *const codeTemplateC
Name of the C code template to be used.
A functionEntry causes entries to be added/manipulated on the specified dictionary given an input str...
primitiveEntry(const keyType &key)
Construct from keyword and no tokens.
virtual const dictionary & dict() const
This entry is not a dictionary, calling this function generates a FatalError.
static bool masterOnlyReading
To flag master-only reading of objects.
A class for handling character strings derived from std::string.
#define defineTypeNameAndDebug(Type, DebugSwitch)
Define the typeName and debug information.
#define FatalIOErrorInFunction(ios)
Report an error message using Foam::FatalIOError.
OBJstream os(runTime.globalPath()/outputName)
#define DebugPout
Report an information message using Foam::Pout.
Namespace for containing a functionEntry.
bool returnReduceOr(const bool value, const int communicator=UPstream::worldComm)
Perform logical (or) MPI Allreduce on a copy. Uses UPstream::reduceOr.
refPtr< fileOperation > fileHandler(std::nullptr_t)
Delete current file handler - forwards to fileOperation::handler().
Ostream & endl(Ostream &os)
Add newline and flush stream.
const Type * isA(const U &obj)
Attempt dynamic_cast to Type.
IOerror FatalIOError
Error stream (stdout output on all processes), with additional 'FOAM FATAL IO ERROR' header text and ...
void * dlOpen(const fileName &libName, const bool check=true)
Open a shared library and return handle to library.
void * dlSym(void *handle, const std::string &symbol)
Lookup a symbol in a dlopened library using handle to library.
errorManipArg< error, int > exit(error &err, const int errNo=1)
constexpr char nl
The newline '\n' character (0x0a).