40namespace functionEntries
58 primitiveEntryIstream,
84 const auto* iodictPtr = isA<baseIOdictionary>(
dict.topDict());
88 masterOnly = iodictPtr->globalObject();
91 <<
"codeStream : baseIOdictionary:" <<
dict.name()
92 <<
" master-only-reading:" << masterOnly <<
endl;
97 <<
"codeStream : not a baseIOdictionary:" <<
dict.name()
98 <<
" master-only-reading:" << masterOnly <<
endl;
117 std::string sha1Str(context.
sha1().
str(
true));
118 dynamicCode dynCode(
"codeStream" + sha1Str, sha1Str);
129 if (isA<baseIOdictionary>(topDict))
131 lib = libs(parentDict).findLibrary(libPath);
139 <<
"Using #codeStream with " << libPath <<
endl;
141 if (isA<baseIOdictionary>(topDict))
144 lib = libs(parentDict).open(libPath,
false);
166 dynCode.
reset(context);
176 +
"\n\nLIB_LIBS = \\\n"
184 <<
"Failed writing files for" <<
nl
202 !doingMasterOnlyReading(topDict)
212 off_t masterSize = mySize;
224 <<
"masterSize:" << masterSize
225 <<
" and localSize:" << mySize
228 if (mySize == masterSize)
232 else if (mySize > masterSize)
235 <<
"Excessive size when reading (NFS mounted) library "
236 <<
nl << libPath <<
nl
238 <<
" detected size " << mySize
239 <<
" whereas master size is " << masterSize
241 <<
"If your case is NFS mounted increase"
242 <<
" fileModificationSkew or maxFileModificationPolls;"
243 <<
nl <<
"If your case is not NFS mounted"
244 <<
" (so distributed) set fileModificationSkew"
251 <<
"Local file " << libPath
252 <<
" not of same size (" << mySize
254 << masterSize <<
"). Waiting for "
256 <<
" seconds." <<
endl;
267 if (mySize != masterSize)
270 <<
"Cannot read (NFS mounted) library " <<
nl
273 <<
" detected size " << mySize
274 <<
" whereas master size is " << masterSize
276 <<
"If your case is NFS mounted increase"
277 <<
" fileModificationSkew or maxFileModificationPolls;"
278 <<
nl <<
"If your case is not NFS mounted"
279 <<
" (so distributed) set fileModificationSkew"
286 <<
" after waiting: have masterSize:" << masterSize
287 <<
" and localSize:" << mySize <<
endl;
290 if (isA<baseIOdictionary>(topDict))
294 <<
"Opening cached dictionary:" << libPath <<
endl;
296 lib = libs(parentDict).open(libPath,
false);
301 <<
"Failed loading library " << libPath <<
nl
302 <<
"Did you add all libraries to the 'libs' entry"
303 <<
" in system/controlDict?"
311 <<
"Opening uncached dictionary:" << libPath <<
endl;
318 if (!doingMasterOnlyReading(topDict))
326 <<
"Failed loading library " << libPath
327 <<
" on some processors."
333 streamingFunctionType function =
334 reinterpret_cast<streamingFunctionType
>
343 <<
"Failed looking up symbol " << dynCode.
codeName()
358 <<
"Using #codeStream at line " << is.
lineNumber()
363 "functionEntries::codeStream::evaluate(..)",
368 dictionary codeDict(
"#codeStream", parentDict, is);
373 streamingFunctionType function = getFunction(parentDict, codeDict);
374 (*function)(
os, parentDict);
391 entry.read(parentDict, result);
404 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.
void evaluate()
Evaluate boundary conditions.
static float fileModificationSkew
Time skew (seconds) for file modification checks.
static int maxFileModificationPolls
Max number of times to poll for file modification changes.
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.
static void broadcast(Type &value, const label comm=UPstream::worldComm)
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...
virtual dlLibraryTable & libs() const
Mutable access to the loaded dynamic libraries.
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.
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 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.
const word & codeName() const
Return the code-name.
bool wmakeLibso() const
Compile a libso.
void setMakeOptions(const std::string &content)
Define contents for Make/options.
A keyword and a list of tokens is an 'entry'.
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.
void(* streamingFunctionType)(Ostream &, const dictionary &)
Interpreter function type.
A functionEntry causes entries to be added/manipulated on the specified dictionary given an input str...
virtual bool execute()
Calculate the output fields.
A keyword and a list of tokens comprise a primitiveEntry. A primitiveEntry can be read,...
virtual const dictionary & dict() const
This entry is not a dictionary,.
int myProcNo() const noexcept
Return processor number.
static bool masterOnlyReading
To flag master-only reading of objects.
splitCell * master() const
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.
unsigned int sleep(const unsigned int sec)
Sleep for the specified number of seconds.
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)
off_t fileSize(const fileName &name, const bool followLink=true)
Return size of file or -1 on failure (normally follows symbolic links).
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)