51 "caseDicts/postProcessing" 65 <<
"\nFOAM aborting (FOAM_ABORT set)\n" <<
endl;
72 <<
"\nFOAM parallel run exiting\n" <<
endl;
78 <<
"\nFOAM exiting\n" <<
endl;
88 void Foam::functionObjectList::createPropertiesDict()
const 94 new functionObjects::properties
98 "functionObjectProperties",
100 "uniform"/word(
"functionObjects"),
111 void Foam::functionObjectList::createOutputRegistry()
const 113 objectsRegistryPtr_.reset
119 "functionObjectObjects",
137 autoPtr<functionObject> oldptr;
139 auto iter = indices_.find(
key);
146 oldptr = this->release(oldIndex);
147 indices_.erase(iter);
158 void Foam::functionObjectList::listDir
176 listDir(dir/d, available);
187 listDir(d, available);
191 <<
"Available configured functionObjects:" 208 for (
const fileName& d :
findEtcDirs(functionObjectDictPath))
210 dictFile =
search(funcName, d);
211 if (!dictFile.empty())
223 const string& funcNameArgs,
241 const auto argsBeg = funcNameArgs.find(
'(');
242 if (argsBeg == std::string::npos)
252 const auto argsEnd = funcNameArgs.rfind(
')');
260 (argsEnd != std::string::npos && argsBeg < argsEnd)
261 ? (argsEnd - argsBeg - 1)
278 <<
"Cannot find functionObject file " << funcName <<
endl;
284 ISstream& fileStream = *fileStreamPtr;
288 dictionary& funcDict = (funcDictPtr ? *funcDictPtr : funcsDict);
296 funcDict.
set(
"field",
args[0]);
305 else if (funcDict.
found(
"field"))
309 else if (funcDict.
found(
"fields"))
319 namedArg.first() +
' ' + namedArg.second() +
';' 328 funcDict.
set(
"region", region);
334 functionsDict.
merge(funcArgsDict);
341 Foam::functionObjectList::getOrDefaultErrorHandling
355 <<
"The sub-dictionary '" <<
key 356 <<
"' masks error handling for functions" <<
endl;
360 const word enumName(eptr->
get<word>());
366 << enumName <<
" is not in enumeration: " 381 Foam::functionObjectList::functionObjectList
391 Foam::functionObjectList::functionObjectList
404 parentDict_(parentDict),
405 propsDictPtr_(nullptr),
406 objectsRegistryPtr_(nullptr),
407 execution_(execution),
431 bool modifiedControlDict =
false;
435 modifiedControlDict =
true;
455 modifiedControlDict =
true;
468 modifiedControlDict =
true;
485 if (modifiedControlDict)
494 functionsPtr->
start();
511 propsDictPtr_.reset(
nullptr);
512 createPropertiesDict();
520 createPropertiesDict();
523 return *propsDictPtr_;
532 createPropertiesDict();
535 return *propsDictPtr_;
541 if (!objectsRegistryPtr_)
543 createOutputRegistry();
546 return *objectsRegistryPtr_;
552 if (!objectsRegistryPtr_)
554 createOutputRegistry();
557 return *objectsRegistryPtr_;
564 errorHandling_.clear();
578 if (funcObj.name() == objName)
599 updated_ = execution_ =
false;
626 auto errIter = errorHandling_.cbegin();
630 const auto errorHandling = *errIter;
633 const word& objName = funcObj.name();
646 bool hadError =
false;
654 "functionObject::", objName,
"::execute" 657 ok = funcObj.execute() && ok;
668 && (nWarnings = ++warnings_(objName)) <=
maxWarnings 674 <<
"--> execute() function object '" 679 Info<<
nl <<
"... silencing further warnings";
700 "functionObject::", objName,
":write" 703 ok = funcObj.write() && ok;
714 && (nWarnings = ++warnings_(objName)) <=
maxWarnings 720 <<
"--> write() function object '" 725 Info<<
nl <<
"... silencing further warnings";
741 && !hadError && !warnings_.empty()
744 warnings_.erase(objName);
756 "functionObject::", objName,
"::execute" 759 ok = funcObj.execute() && ok;
767 "functionObject::", objName,
":write" 770 ok = funcObj.write() && ok;
777 if (time_.writeTime() && writeProperties)
782 propsDictPtr_->writeObject
797 bool ok = execution_;
805 ok = funcObj.execute(subIndex) && ok;
819 bool ok = execution_;
821 if (ok && functionNames.
size())
829 ok = funcObj.execute(subIndex) && ok;
849 auto errIter = errorHandling_.cbegin();
853 const auto errorHandling = *errIter;
856 const word& objName = funcObj.name();
867 ok = funcObj.end() && ok;
882 <<
"--> end() function object '" 896 && !warnings_.empty()
899 warnings_.erase(objName);
921 const word& objName = funcObj.name();
928 "functionObject::", objName,
"::adjustTimeStep" 931 ok = funcObj.adjustTimeStep() && ok;
943 createPropertiesDict();
946 updated_ = execution_;
955 const entry* entryPtr =
964 errorHandling_.clear();
969 else if (!entryPtr->isDict())
974 <<
"'functions' entry is not a dictionary" 979 const dictionary& functionsDict = entryPtr->dict();
981 PtrList<functionObject> newPtrs(functionsDict.size());
982 List<SHA1Digest> newDigs(functionsDict.size());
984 errorHandling_.resize
986 functionsDict.size(),
990 HashTable<label> newIndices;
999 functionObject::dictionaryConstructorTablePtr_
1004 getOrDefaultErrorHandling
1013 for (
const entry& dEntry : functionsDict)
1015 const word&
key = dEntry.keyword();
1017 if (!dEntry.isDict())
1021 if (
key ==
"useNamePrefix")
1023 Switch sw(dEntry.stream().front());
1031 <<
"Entry '" <<
key <<
"' is not a valid switch" 1035 else if (
key !=
"errors" &&
key !=
"libs")
1038 <<
"Entry '" <<
key <<
"' is not a dictionary" 1051 getOrDefaultErrorHandling
1055 errorHandlingFallback
1058 errorHandling_[nFunc] = errorHandling;
1062 label oldIndex = -1;
1063 autoPtr<functionObject> objPtr =
remove(
key, oldIndex);
1065 const bool needsTimeControl =
1074 if (enabled && newDigs[nFunc] != digests_[oldIndex])
1076 const bool wasTimeControl =
1077 isA<functionObjects::timeControl>(*objPtr);
1079 if (needsTimeControl != wasTimeControl)
1084 objPtr.reset(
nullptr);
1093 "functionObject::", objPtr->name(),
"::read" 1096 enabled = objPtr->read(
dict);
1103 objPtr.reset(
nullptr);
1108 if (enabled && !objPtr)
1120 "functionObject::",
key,
"::new" 1122 if (needsTimeControl)
1126 new functionObjects::timeControl(
key, time_,
dict)
1136 objPtr.reset(
nullptr);
1138 switch (errorHandling)
1151 if (isA<Foam::IOerror>(err))
1167 <<
"--> loading function object '" 1182 objPtr.reset(
nullptr);
1190 newPtrs.set(nFunc, std::move(objPtr));
1191 newIndices.insert(
key, nFunc);
1196 newPtrs.resize(nFunc);
1197 newDigs.resize(nFunc);
1198 errorHandling_.resize(nFunc);
1203 digests_.transfer(newDigs);
1204 indices_.transfer(newIndices);
1219 bool changed = funcObj.filesModified();
1233 funcObj.updateMesh(mpm);
1245 funcObj.movePoints(
mesh);
bool read()
Read and set the function objects if their data have changed.
static word validate(const std::string &s, const bool prefix=false)
Construct validated word (no invalid characters).
EnumType get(const word &enumName) const
The enumeration corresponding to the given name.
prefixOSstream Perr
OSstream wrapped stderr (std::cerr) with parallel prefix.
label splitFunctionArgs(const std::string &str, wordRes &args, List< Tuple2< word, string >> &namedArgs)
Split out arguments (named or unnamed) from an input string.
void size(const label n)
Older name for setAddressableSize.
A class for handling file names.
bool filesModified() const
Did any file get changed during execution?
SHA1Digest digest() const
Return the SHA1 digest of the dictionary contents.
handlerTypes
Handling of errors. The exact handling depends on the local context.
errorManipArg< error, int > exit(error &err, const int errNo=1)
void off()
Switch the function objects off.
error FatalError
Error stream (stdout output on all processes), with additional 'FOAM FATAL ERROR' header text and sta...
A list of keyword definitions, which are a keyword followed by a number of values (eg...
Storage for function object properties, derived from IOdictionary. Provides functionality to read/wri...
A 2-tuple for storing two objects of dissimilar types. The container is similar in purpose to std::pa...
static bool entriesPresent(const dictionary &dict)
Helper function to identify if a timeControl object is present.
A 1D array of objects of type <T>, where the size of the vector is known and used for subscript bound...
label findObjectID(const word &objName) const
Find the ID of a given function object by name, -1 if not found.
static void list()
Print a list of functionObject configuration files in the directories located using Foam::findEtcDirs...
constexpr char nl
The newline '\n' character (0x0a)
bool throwing() const noexcept
Return the current exception throwing state (on or off)
bool empty() const noexcept
True if List is empty (ie, size() is zero)
static const fileName null
An empty fileName.
Ostream & endl(Ostream &os)
Add newline and flush stream.
List< T > getList(const label index) const
Get a List of values from the argument at index.
static bool & parRun() noexcept
Test if this a parallel run.
functionObjects::properties & propsDict()
Write access to the properties dictionary ("functionObjectProperties") registered on Time...
#define addProfiling(Name,...)
Define profiling trigger with specified name and description string. The description is generated by ...
void on()
Switch the function objects on.
refPtr< fileOperation > fileHandler(std::nullptr_t)
Delete current file handler - forwards to fileOperation::handler()
entry * add(entry *entryPtr, bool mergeEntry=false)
Add a new entry.
bool adjustTimeStep()
Called at the end of Time::adjustDeltaT() if adjustTime is true.
Ignore writing from objectRegistry::writeObject()
T get(const word &keyword, enum keyType::option matchOpt=keyType::REGEX) const
Find and return a T. FatalIOError if not found, or if the number of tokens is incorrect.
T getOrDefault(const word &optName, const T &deflt) const
Get a value from the named option if present, or return default.
Abstract base-class for Time/database function objects.
Default behaviour (local meaning)
bool insert(const Key &key)
Insert a new entry, not overwriting existing entries.
A keyword and a list of tokens is a 'dictionaryEntry'.
Class to control time during OpenFOAM simulations that is also the top-level objectRegistry.
bool start()
Called at the start of the time-loop.
Class containing mesh-to-mesh mapping information after a change in polyMesh topology.
IOdictionary propsDict(dictIO)
bool read(const char *buf, int32_t &val)
Same as readInt32.
bool found(const word &keyword, enum keyType::option matchOpt=keyType::REGEX) const
Find an entry (const access) with the given keyword.
IOdictionary is derived from dictionary and IOobject to give the dictionary automatic IO functionalit...
Class to handle errors and exceptions in a simple, consistent stream-based manner.
void reset(T *p=nullptr) noexcept
Delete managed object and set to new given pointer.
static autoPtr< functionObjectList > New(const argList &args, const Time &runTime, dictionary &controlDict, HashSet< wordRe > &requiredFields)
Construct and return a functionObjectList for an application.
Functions used by OpenFOAM that are specific to POSIX compliant operating systems and need to be repl...
bool merge(const dictionary &dict)
Merge entries from the given dictionary.
void resetPropertiesDict()
Reset/read properties dictionary for current time.
bool returnReduceAnd(const bool value, const label comm=UPstream::worldComm)
Perform logical (and) MPI Allreduce on a copy. Uses UPstream::reduceAnd.
static void exit(int errNo=1)
Shutdown (finalize) MPI as required and exit program with errNo.
static bool useAbort()
True if FOAM_ABORT is on.
A class for handling words, derived from Foam::string.
Functions to search 'etc' directories for configuration files etc.
Extract command arguments and options from the supplied argc and argv parameters. ...
static fileName findDict(const word &funcName)
Find a functionObject dictionary file in the case <system> directory or any directory located using F...
virtual void write(Ostream &os, const bool withTitle=true) const
Print error message.
Ignore on errors/problems.
Reading is optional [identical to LAZY_READ].
static const dictionary null
An empty dictionary, which is also the parent for all dictionaries.
label size() const noexcept
The number of arguments.
A List of wordRe with additional matching capabilities.
T get() const
Get a T from the stream, FatalIOError if the number of tokens is incorrect.
HashSet< word, Hash< word > > wordHashSet
A HashSet of words, uses string hasher.
List of function objects with start(), execute() and end() functions that is called for each object...
static void exitNow(const error &err)
Mimic exit handling of the error class.
runTime controlDict().readEntry("adjustTimeStep"
The central control dictionary, the contents of which are either taken directly from the FOAM_CONTROL...
errorManip< error > abort(error &err)
A wordRe is a Foam::word, but can contain a regular expression for matching words or strings...
A 1D vector of objects of type <T>, where the size of the vector is known and can be used for subscri...
static bool readFunctionObject(const string &funcNameArgs0, dictionary &functionsDict, HashSet< wordRe > &requiredFields, const word ®ion=word::null)
Read the specified functionObject configuration dictionary parsing the optional arguments included in...
static word timeName(const scalar t, const int precision=precision_)
Return a time name for the given scalar time value formatted with the given precision.
fileName path(UMean.rootPath()/UMean.caseName()/"graphs"/UMean.instance())
messageStream Warning
Warning stream (stdout output on master, null elsewhere), with additional 'FOAM Warning' header text...
void clear()
Clear the list of function objects.
bool isFile(const fileName &name, const bool checkGzip=true, const bool followLink=true)
Does the name exist as a FILE in the file system?
bool status() const
Return the execution status (on/off) of the function objects.
static bool match(const UList< wordRe > &selectors, const std::string &text, bool literal=false)
Test for a match.
static unsigned int precision_
Default precision.
Generic input stream using a standard (STL) stream.
static constexpr const unsigned maxWarnings
Max number of warnings (per functionObject)
#define WarningInFunction
Report a warning using Foam::Warning.
#define FatalIOErrorInFunction(ios)
Report an error message using Foam::FatalIOError.
Foam::word regionName(args.getOrDefault< word >("region", Foam::polyMesh::defaultRegion))
auto key(const Type &t) -> typename std::enable_if< std::is_enum< Type >::value, typename std::underlying_type< Type >::type >::type
A list of pointers to objects of type <T>, with allocation/deallocation management of the pointers...
Input from string buffer, using a ISstream. Always UNCOMPRESSED.
List< Key > sortedToc() const
The table of contents (the keys) in sorted order.
static bool defaultUseNamePrefix
Global default for useNamePrefix.
const entry * findEntry(const word &keyword, enum keyType::option matchOpt=keyType::REGEX) const
Find an entry (const access) with the given keyword.
void clear()
Clear the PtrList. Delete allocated entries and set size to zero.
bool execute(bool writeProperties=true)
Called at each ++ or += of the time-loop.
messageStream Info
Information stream (stdout output on master, null elsewhere)
virtual bool isDict() const noexcept
True if this entry is a dictionary.
fileNameList findEtcDirs(const fileName &name, unsigned short location=0777, const bool findFirst=false)
Search for directories from user/group/other etc locations.
static void printStack(Ostream &os, int size=-1)
Helper function to print a stack, with optional upper limit.
fileName search(const word &file, const fileName &directory)
Recursively search the given directory for the file.
#define IOWarningInFunction(ios)
Report an IO warning using Foam::Warning.
void transfer(PtrList< T > &list)
Transfer into this list and annul the argument list.
objectRegistry & storedObjects()
Write access to the output objects ("functionObjectObjects") registered on Time.
Mesh consisting of general polyhedral cells.
entry * set(entry *entryPtr)
Assign a new entry, overwriting any existing entry.
T getOrDefault(const word &keyword, const T &deflt, enum keyType::option matchOpt=keyType::REGEX) const
Find and return a T, or return the given default value. FatalIOError if it is found and the number of...
static autoPtr< functionObject > New(const word &name, const Time &runTime, const dictionary &dict)
Select from dictionary, based on its "type" entry.
static bool New(dictionary &parentDict, Istream &is, const inputMode inpMode=inputMode::GLOBAL, const int endChar=0)
Construct from an Istream and insert into the dictionary.
void updateMesh(const mapPolyMesh &mpm)
Update for changes of mesh.
Registry of regIOobjects.
label triggerIndex() const
Return the current trigger index (read from the propsDict)
fileNameList readDir(const fileName &directory, const fileName::Type type=fileName::Type::FILE, const bool filtergz=true, const bool followLink=true)
Read a directory and return the entries as a fileName List.
Foam::argList args(argc, argv)
void movePoints(const polyMesh &mesh)
Update for changes of mesh.
Defines the attributes of an object for which implicit objectRegistry management is supported...
Request registration (bool: true)
static fileName functionObjectDictPath
Default relative path ("caseDicts/postProcessing") to the directory structure containing functionObje...
Fatal on errors/problems.
bool end()
Called when Time::run() determines that the time-loop exits.
bool found(const word &optName) const
Return true if the named option is found.
A keyword and a list of tokens is an 'entry'.
static const Enum< handlerTypes > handlerNames
Names of the error handler types.
const dictionary * findDict(const word &keyword, enum keyType::option matchOpt=keyType::REGEX) const
Find and return a sub-dictionary pointer if present (and it is a dictionary) otherwise return nullptr...
string expand(const std::string &s, const HashTable< string > &mapping, const char sigil='$')
Expand occurrences of variables according to the mapping and return the expanded string.
IOerror FatalIOError
Error stream (stdout output on all processes), with additional 'FOAM FATAL IO ERROR' header text and ...