78 os.writeEntry(key, toks[0]);
132void* Foam::codedBase::loadLibrary
135 const std::string& funcName,
141 void* handle = libs().open(libPath,
false);
153 const bool ok = libs().loadHook(handle, funcName,
false);
158 <<
"Failed symbol lookup " << funcName.c_str() <<
nl
159 <<
"from " << libPath <<
nl
163 if (!libs().close(libPath,
false))
166 <<
"Failed unloading library " << libPath <<
nl
175void Foam::codedBase::unloadLibrary
178 const std::string& funcName,
182 void* handle = libs().open(libPath,
false);
192 const bool ok = libs().unloadHook(handle, funcName,
false);
197 <<
"Failed looking up symbol " << funcName <<
nl
198 <<
"from " << libPath <<
nl;
201 if (!libs().close(libPath,
false))
204 <<
"Failed unloading library " << libPath <<
nl
210void Foam::codedBase::createLibrary
227 && !dynCode.upToDate(context)
231 dynCode.reset(context);
233 this->prepare(dynCode, context);
235 if (!dynCode.copyOrCreateFiles(
true))
238 <<
"Failed writing files for" <<
nl
239 << dynCode.libRelPath() <<
nl
243 if (!dynCode.wmakeLibso())
246 <<
"Failed wmake " << dynCode.libRelPath() <<
nl
257 const fileName libPath = dynCode.libPath();
279 context_.setCodeContext(
dict);
285 context_.append(str);
297 "codedBase::updateLibrary()",
309 const fileName libPath = dynCode.libPath();
313 if (libs().findLibrary(libPath))
319 <<
"Using dynamicCode for " << this->description().c_str()
325 this->clearRedirect();
331 void* lib =
loadLibrary(libPath, dynCode.codeName(), context);
341 createLibrary(dynCode, context);
347 oldLibPath_ = libPath;
365 updateLibrary(
name, context_);
369 updateLibrary(
name, dynamicCodeContext(this->codeDict()));
Functions used by OpenFOAM that are specific to POSIX compliant operating systems and need to be repl...
static void * loadLibrary(const Foam::fileName &libName)
Inter-processor communication reduction functions.
IOdictionary is derived from dictionary and IOobject to give the dictionary automatic IO functionalit...
@ REGISTER
Request registration (bool: true).
@ NO_WRITE
Ignore writing from objectRegistry::writeObject().
Defines the attributes of an object for which implicit objectRegistry management is supported,...
static float fileModificationSkew
Time skew (seconds) for file modification checks.
An Ostream is an abstract base class for all output systems (streams, files, token lists,...
std::string str(const bool prefixed=false) const
The digest (40-byte) text representation, optionally with '_' prefix.
const word & system() const noexcept
Return system name.
bool empty() const noexcept
True if List is empty (ie, size() is zero).
static void barrier(const int communicator, UPstream::Request *req=nullptr)
Impose a synchronisation barrier (optionally non-blocking).
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.
Base class for function objects and boundary conditions using dynamic code that provides methods for ...
void updateLibrary(const word &name, const dynamicCodeContext &context) const
Update library as required, using the given context.
virtual void clearRedirect() const =0
void setCodeContext(const dictionary &dict)
Set code context from a dictionary.
virtual dlLibraryTable & libs() const =0
Mutable access to the loaded dynamic libraries.
virtual string description() const =0
void append(const std::string &str)
Add content to SHA1 hashing.
virtual const dictionary & codeDict() const =0
static void writeCodeDict(Ostream &os, const dictionary &dict)
Write code-dictionary contents.
static const dictionary & codeDict(const objectRegistry &obr, const word &dictName="codeDict")
Return "codeDict" from objectRegistry or read from disk.
A list of keyword definitions, which are a keyword followed by a number of values (eg,...
const fileName & name() const noexcept
The dictionary name.
void writeEntry(Ostream &os) const
Write sub-dictionary with its dictName as its header.
label startLineNumber() const
Return line number of first token in dictionary.
static word basename(const fileName &libPath)
Library basename without leading 'lib' or trailing '.so'.
Encapsulation of dynamic code dictionaries.
const SHA1 & sha1() const noexcept
The SHA1 calculated from options, libs, include, code, etc.
const dictionary & dict() const noexcept
Return the parent dictionary context.
Tools for handling dynamic code compilation.
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.
fileName libPath() const
Library path for specified code name.
const word & codeName() const noexcept
Return the code-name.
A keyword and a list of tokens is an 'entry'.
virtual ITstream & stream() const =0
Return token stream, if entry is a primitive entry.
virtual bool isDict() const noexcept
True if this entry is a dictionary.
virtual const dictionary & dict() const =0
Return dictionary, if entry is a dictionary, otherwise Fatal.
A class for handling file names.
Registry of regIOobjects.
const Time & time() const noexcept
Return time registry.
Type * getObjectPtr(const word &name, const bool recursive=false) const
Return non-const pointer to the object of the given Type, using a const-cast to have it behave like a...
bool store()
Register object with its registry and transfer ownership to the registry.
A class for handling words, derived from Foam::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)
const word dictName("faMeshDefinition")
#define IOWarningInFunction(ios)
Report an IO warning using Foam::Warning.
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().
static void writeEntryIfPresent(Ostream &os, const dictionary &dict, const word &key)
Ostream & endl(Ostream &os)
Add newline and flush stream.
IOerror FatalIOError
Error stream (stdout output on all processes), with additional 'FOAM FATAL IO ERROR' header text and ...
word name(const expressions::valueTypeCode typeCode)
A word representation of a valueTypeCode. Empty for expressions::valueTypeCode::INVALID.
List< token > tokenList
List of token, used for dictionary primitive entry (for example).
errorManipArg< error, int > exit(error &err, const int errNo=1)
constexpr char nl
The newline '\n' character (0x0a).