40 namespace functionEntries
58 primitiveEntryIstream,
84 const auto* rioPtr = isA<regIOobject>(
dict.topDict());
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);
121 const fileName libPath = dynCode.libPath();
126 if (isA<baseIOdictionary>(topDict))
128 lib = libs(parentDict).findLibrary(libPath);
136 <<
"Using #codeStream with " << libPath <<
endl;
138 if (isA<baseIOdictionary>(topDict))
141 lib = libs(parentDict).open(libPath,
false);
159 && !dynCode.upToDate(context)
163 dynCode.reset(context);
166 dynCode.addCompileFile(codeTemplateC);
169 dynCode.setMakeOptions
173 +
"\n\nLIB_LIBS = \\\n" 178 if (!dynCode.copyOrCreateFiles(
true))
181 <<
"Failed writing files for" <<
nl 182 << dynCode.libRelPath() <<
nl 186 if (!dynCode.wmakeLibso())
189 <<
"Failed wmake " << dynCode.libRelPath() <<
nl 216 if (isA<baseIOdictionary>(topDict))
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()
250 <<
" in library " << dynCode.libRelPath()
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);
A class for handling file names.
std::string str(const bool prefixed=false) const
The digest (40-byte) text representation, optionally with '_' prefix.
baseIOdictionary is derived from dictionary and IOobject to give the dictionary automatic IO function...
errorManipArg< error, int > exit(error &err, const int errNo=1)
defineTypeNameAndDebug(codeStream, 0)
static float fileModificationSkew
Time skew (seconds) for file modification checks.
bool read(Istream &is)
Read dictionary from Istream (discards the header). Reads entries until EOF or when the first token i...
A list of keyword definitions, which are a keyword followed by a number of values (eg...
static bool doingMasterOnlyReading(const dictionary &dict)
Helper: access IOobject for master-only-reading functionality.
Input/output from string buffers.
static void waitForFile(const fileName &file, const dictionary &contextDict)
Wait for libPath() file to appear on sub-ranks.
static streamingFunctionType getFunction(const dictionary &parentDict, const dictionary &codeDict)
Construct, compile, load and return streaming function.
An Istream is an abstract base class for all input systems (streams, files, token lists etc)...
constexpr char nl
The newline '\n' character (0x0a)
Ostream & endl(Ostream &os)
Add newline and flush stream.
refPtr< fileOperation > fileHandler(std::nullptr_t)
Delete current file handler - forwards to fileOperation::handler()
static label worldComm
Communicator for all ranks. May differ from commGlobal() if local worlds are in use.
static string evaluate(const dictionary &parentDict, Istream &is)
Evaluate dynamically compiled code, returning result as string.
void(* streamingFunctionType)(Ostream &, const dictionary &)
Interpreter function type.
A keyword and a list of tokens comprise a primitiveEntry. A primitiveEntry can be read...
const dictionary & dict() const noexcept
Return the parent dictionary context.
static bool execute(const dictionary &parentDict, primitiveEntry &entry, Istream &is)
Execute in a primitiveEntry context.
const string & options() const noexcept
The code options (Make/options)
string evaluate(label fieldWidth, const std::string &s, size_t pos=0, size_t len=std::string::npos)
String evaluation with specified (positive, non-zero) field width.
const dictionary & topDict() const
Return the top of the tree.
A table of dynamically loaded libraries.
OBJstream os(runTime.globalPath()/outputName)
virtual const dictionary & dict() const
This entry is not a dictionary, calling this function generates a FatalError.
fileName relativeName(const bool caseTag=false) const
The dictionary name relative to the case.
label lineNumber() const noexcept
Const access to the current stream line number.
static bool masterOnlyReading
To flag master-only reading of objects.
Tools for handling dynamic code compilation.
Encapsulation of dynamic code dictionaries.
void * dlSym(void *handle, const std::string &symbol)
Lookup a symbol in a dlopened library using handle to library.
#define FatalIOErrorInFunction(ios)
Report an error message using Foam::FatalIOError.
Input from string buffer, using a ISstream. Always UNCOMPRESSED.
void * dlOpen(const fileName &libName, const bool check=true)
Open a shared library and return handle to library.
static bool master(const label communicator=worldComm)
True if process corresponds to the master rank in the communicator.
Macros for easy insertion into member function selection tables.
const string & libs() const noexcept
The code libs (LIB_LIBS)
#define DebugPout
Report an information message using Foam::Pout.
static dlLibraryTable & libs(const dictionary &dict)
Helper function: access to dlLibraryTable of Time.
addNamedToMemberFunctionSelectionTable(functionEntry, calcEntry, execute, dictionaryIstream, calc)
bool returnReduceOr(const bool value, const label comm=UPstream::worldComm)
Perform logical (or) MPI Allreduce on a copy. Uses UPstream::reduceOr.
static void checkSecurity(const char *title, const dictionary &)
Check security for creating dynamic code.
A class for handling character strings derived from std::string.
Output to string buffer, using a OSstream. Always UNCOMPRESSED.
streamFormat format() const noexcept
Get the current stream format.
A keyword and a list of tokens is an 'entry'.
const SHA1 & sha1() const noexcept
The SHA1 calculated from options, libs, include, code, etc.
IOerror FatalIOError
Error stream (stdout output on all processes), with additional 'FOAM FATAL IO ERROR' header text and ...