Go to the documentation of this file.
38 namespace functionEntries
63 =
"codeStreamTemplate.C";
74 return const_cast<Time&
>(d.
time()).libs();
90 std::string sha1Str(context.
sha1().
str(
true));
91 dynamicCode dynCode(
"codeStream" + sha1Str, sha1Str);
99 if (isA<IOdictionary>(parentDict.
topDict()))
101 lib = libs(parentDict).findLibrary(libPath);
106 Info<<
"Using #codeStream with " << libPath <<
endl;
114 if (isA<IOdictionary>(parentDict.
topDict()))
119 if (dlLibs.
open(libPath,
false))
127 lib =
dlOpen(libPath,
false);
137 || (regIOobject::fileModificationSkew <= 0);
144 dynCode.
reset(context);
154 +
"\n\nLIB_LIBS = \\\n"
164 ) <<
"Failed writing files for" <<
nl
184 !regIOobject::masterOnlyReading
185 && regIOobject::fileModificationSkew > 0
194 off_t masterSize = mySize;
195 Pstream::scatter(masterSize);
199 Pout<<
endl<<
"on processor " << Pstream::myProcNo()
200 <<
" have masterSize:" << masterSize
201 <<
" and localSize:" << mySize
206 if (mySize < masterSize)
210 Pout<<
"Local file " << libPath
211 <<
" not of same size (" << mySize
213 << masterSize <<
"). Waiting for "
214 << regIOobject::fileModificationSkew
215 <<
" seconds." <<
endl;
222 if (mySize < masterSize)
227 ) <<
"Cannot read (NFS mounted) library " <<
nl
229 <<
"on processor " << Pstream::myProcNo()
230 <<
" detected size " << mySize
231 <<
" whereas master size is " << masterSize
233 <<
"If your case is not NFS mounted"
234 <<
" (so distributed) set fileModificationSkew"
242 Pout<<
endl<<
"on processor " << Pstream::myProcNo()
243 <<
" after waiting: have masterSize:" << masterSize
244 <<
" and localSize:" << mySize
249 if (isA<IOdictionary>(parentDict.
topDict()))
257 Pout<<
"Opening cached dictionary:" << libPath <<
endl;
260 if (!dlLibs.
open(libPath,
false))
265 ) <<
"Failed loading library " << libPath <<
nl
266 <<
"Did you add all libraries to the 'libs' entry"
267 <<
" in system/controlDict?"
278 Pout<<
"Opening uncached dictionary:" << libPath <<
endl;
280 lib =
dlOpen(libPath,
true);
285 if (!regIOobject::masterOnlyReading)
295 ) <<
"Failed loading library " << libPath
296 <<
" on some processors."
302 streamingFunctionType
function =
303 reinterpret_cast<streamingFunctionType
>
314 ) <<
"Failed looking up symbol " << dynCode.
codeName()
332 <<
" in file " << parentDict.
name() <<
endl;
334 dynamicCode::checkSecurity
336 "functionEntries::codeStream::execute(..)",
342 dictionary codeDict(
"#codeStream", parentDict, is);
344 streamingFunctionType
function = getFunction(parentDict, codeDict);
348 (*function)(os, parentDict);
352 entry.read(parentDict, resultStream);
365 <<
" in file " << parentDict.
name() <<
endl;
367 dynamicCode::checkSecurity
369 "functionEntries::codeStream::execute(..)",
375 dictionary codeDict(
"#codeStream", parentDict, is);
377 streamingFunctionType
function = getFunction(parentDict, codeDict);
381 (*function)(os, parentDict);
385 parentDict.
read(resultStream);
const string & libs() const
Return the code-libs.
A keyword and a list of tokens is an 'entry'.
IOdictionary is derived from dictionary and IOobject to give the dictionary automatic IO functionalit...
streamFormat format() const
Return current stream format.
A table of dynamically loaded libraries.
Class to control time during OpenFOAM simulations that is also the top-level objectRegistry.
A keyword and a list of tokens is a 'primitiveEntry'. An primitiveEntry can be read,...
A class for handling words, derived from string.
A class for handling file names.
fileName libPath() const
Library path for specified code name.
void * findLibrary(const fileName &name)
Find the handle of the named library.
bool copyOrCreateFiles(const bool verbose=false) const
Copy/create files prior to compilation.
Tools for handling dynamic code compilation.
void * dlSym(void *handle, const std::string &symbol)
Lookup a symbol in a dlopened library using handle to library.
bool wmakeLibso() const
Compile a libso.
const fileName & name() const
Return the dictionary name.
Encapsulation of dynamic code dictionaries.
Ostream & endl(Ostream &os)
Add newline and flush stream.
const Time & time() const
Return time.
unsigned int sleep(const unsigned int)
Sleep for the specified number of seconds.
static const word codeTemplateC
Name of the C code template to be used.
static streamingFunctionType getFunction(const dictionary &parentDict, const dictionary &codeDict)
Construct, compile, load and return streaming function.
void(* streamingFunctionType)(Ostream &, const dictionary &)
Interpreter function type.
void reduce(const List< UPstream::commsStruct > &comms, T &Value, const BinaryOp &bop, const int tag, const label comm)
void addCompileFile(const fileName &name)
Add a file template name, which will be found and filtered.
const word & codeName() const
Return the code-name.
An Istream is an abstract base class for all input systems (streams, files, token lists etc)....
static dlLibraryTable & libs(const dictionary &dict)
Helper function: access to dlLibraryTable of Time.
Macros for easy insertion into member function selection tables.
void * dlOpen(const fileName &lib, const bool check=true)
Open a shared library. Return handle to library. Print error message.
fileName libRelPath() const
Library path for specified code name relative to $FOAM_CASE.
const dictionary & topDict() const
Return the top of the tree.
const SHA1Digest & sha1() const
Return SHA1 digest calculated from include, options, code.
A list of keyword definitions, which are a keyword followed by any number of values (e....
const string & options() const
Return the code-options.
Input from memory buffer stream.
addToMemberFunctionSelectionTable(functionEntry, calcEntry, execute, dictionaryIstream)
errorManipArg< error, int > exit(error &err, const int errNo=1)
void reset(const dynamicCodeContext &)
Clear files and reset variables to specified context.
bool upToDate(const dynamicCodeContext &context) const
Verify if the copied code is up-to-date, based on Make/SHA1Digest.
void setMakeOptions(const std::string &content)
Define contents for Make/options.
static bool execute(dictionary &parentDict, Istream &)
Execute the functionEntry in a sub-dict context.
prefixOSstream Pout(cout, "Pout")
bool open(const fileName &name, const bool verbose=true)
Open the named library, optionally with warnings if problems occur.
Output to memory buffer stream.
label lineNumber() const
Return current stream line number.
#define FatalIOErrorInFunction(ios)
Report an error message using Foam::FatalIOError.
bool read(Istream &)
Read dictionary from Istream.
defineTypeNameAndDebug(calcEntry, 0)
off_t fileSize(const fileName &)
Return size of file.
std::string str(const bool prefixed=false) const
Return (40-byte) text representation, optionally with '_' prefix.