51 "caseDicts/postProcessing"
57 Foam::functionObjectList::errorHandlingType
59Foam::functionObjectList::errorHandlingNames_
61 { errorHandlingType::DEFAULT,
"default" },
62 { errorHandlingType::WARN,
"warn" },
63 { errorHandlingType::IGNORE,
"ignore" },
64 { errorHandlingType::STRICT,
"strict" },
78 <<
"\nFOAM aborting (FOAM_ABORT set)\n" <<
endl;
85 <<
"\nFOAM parallel run exiting\n" <<
endl;
91 <<
"\nFOAM exiting\n" <<
endl;
101void Foam::functionObjectList::createPropertiesDict()
const
107 new functionObjects::properties
111 "functionObjectProperties",
113 "uniform"/word(
"functionObjects"),
123void Foam::functionObjectList::createOutputRegistry()
const
125 objectsRegistryPtr_.reset
131 "functionObjectObjects",
148 autoPtr<functionObject> oldptr;
150 auto iter = indices_.find(key);
157 oldptr = this->release(oldIndex);
158 indices_.erase(iter);
169void Foam::functionObjectList::listDir
187 listDir(dir/d, available);
198 listDir(d, available);
202 <<
"Available configured functionObjects:"
221 dictFile =
search(funcName, d);
222 if (!dictFile.empty())
234 const string& funcNameArgs,
252 const auto argsBeg = funcNameArgs.find(
'(');
253 if (argsBeg == std::string::npos)
263 const auto argsEnd = funcNameArgs.rfind(
')');
271 (argsEnd != std::string::npos && argsBeg < argsEnd)
272 ? (argsEnd - argsBeg - 1)
289 <<
"Cannot find functionObject file " << funcName <<
endl;
295 ISstream& fileStream = *fileStreamPtr;
299 dictionary& funcDict = (funcDictPtr ? *funcDictPtr : funcsDict);
307 funcDict.
set(
"field",
args[0]);
316 else if (funcDict.
found(
"field"))
320 else if (funcDict.
found(
"fields"))
330 namedArg.first() +
' ' + namedArg.second() +
';'
339 funcDict.
set(
"region", region);
345 functionsDict.
merge(funcArgsDict);
351Foam::functionObjectList::errorHandlingType
352Foam::functionObjectList::getOrDefaultErrorHandling
356 const errorHandlingType deflt
366 <<
"The sub-dictionary '" << key
367 <<
"' masks error handling for functions" <<
endl;
371 const word enumName(eptr->
get<word>());
373 if (!errorHandlingNames_.found(enumName))
377 << enumName <<
" is not in enumeration: "
378 << errorHandlingNames_ <<
nl
382 return errorHandlingNames_.get(enumName);
415 parentDict_(parentDict),
416 propsDictPtr_(nullptr),
417 objectsRegistryPtr_(nullptr),
418 execution_(execution),
442 bool modifiedControlDict =
false;
446 modifiedControlDict =
true;
464 modifiedControlDict =
true;
477 modifiedControlDict =
true;
494 if (modifiedControlDict)
503 functionsPtr->start();
520 propsDictPtr_.reset(
nullptr);
521 createPropertiesDict();
529 createPropertiesDict();
532 return *propsDictPtr_;
541 createPropertiesDict();
544 return *propsDictPtr_;
550 if (!objectsRegistryPtr_)
552 createOutputRegistry();
555 return *objectsRegistryPtr_;
561 if (!objectsRegistryPtr_)
563 createOutputRegistry();
566 return *objectsRegistryPtr_;
573 errorHandling_.clear();
587 if (funcObj.name() == objName)
608 updated_ = execution_ =
false;
635 auto errIter = errorHandling_.cbegin();
639 const errorHandlingType errorHandling = *errIter;
642 const word& objName = funcObj.name();
646 errorHandling == errorHandlingType::WARN
647 || errorHandling == errorHandlingType::IGNORE
655 bool hadError =
false;
663 "functionObject::" + objName +
"::execute"
666 ok = funcObj.execute() && ok;
676 errorHandling != errorHandlingType::IGNORE
677 && (nWarnings = ++warnings_(objName)) <=
maxWarnings
683 <<
"--> execute() function object '"
688 Info<<
nl <<
"... silencing further warnings";
709 "functionObject::" + objName +
":write"
712 ok = funcObj.write() && ok;
721 errorHandling != errorHandlingType::IGNORE
722 && (nWarnings = ++warnings_(objName)) <=
maxWarnings
728 <<
"--> write() function object '"
733 Info<<
nl <<
"... silencing further warnings";
753 "functionObject::" + objName +
"::execute"
756 ok = funcObj.execute() && ok;
764 "functionObject::" + objName +
":write"
767 ok = funcObj.write() && ok;
774 if (time_.writeTime())
779 propsDictPtr_->writeObject
794 bool ok = execution_;
802 ok = funcObj.execute(subIndex) && ok;
816 bool ok = execution_;
818 if (ok && functionNames.
size())
826 ok = funcObj.execute(subIndex) && ok;
846 auto errIter = errorHandling_.cbegin();
850 const errorHandlingType errorHandling = *errIter;
853 const word& objName = funcObj.name();
863 addProfiling(fo,
"functionObject::" + objName +
"::end");
864 ok = funcObj.end() && ok;
873 errorHandling != errorHandlingType::IGNORE
874 && (nWarnings = ++warnings_(objName)) <=
maxWarnings
880 <<
"--> end() function object '"
885 Info<<
nl <<
"... silencing further warnings";
915 const word& objName = funcObj.name();
922 "functionObject::" + objName +
"::adjustTimeStep"
925 ok = funcObj.adjustTimeStep() && ok;
937 createPropertiesDict();
940 updated_ = execution_;
949 const entry* entryPtr =
958 errorHandling_.clear();
963 else if (!entryPtr->
isDict())
968 <<
"'functions' entry is not a dictionary"
978 errorHandling_.resize
980 functionsDict.size(),
981 errorHandlingType::DEFAULT
993 functionObject::dictionaryConstructorTablePtr_
997 const errorHandlingType errorHandlingFallback =
998 getOrDefaultErrorHandling
1002 errorHandlingType::DEFAULT
1007 for (
const entry& dEntry : functionsDict)
1009 const word& key = dEntry.keyword();
1011 if (!dEntry.isDict())
1015 if (key ==
"useNamePrefix")
1017 Switch sw(dEntry.stream().peekFirst());
1025 <<
"Entry '" << key <<
"' is not a valid switch"
1029 else if (key !=
"errors" && key !=
"libs")
1032 <<
"Entry '" << key <<
"' is not a dictionary"
1044 const errorHandlingType errorHandling =
1045 getOrDefaultErrorHandling
1049 errorHandlingFallback
1052 errorHandling_[nFunc] = errorHandling;
1056 label oldIndex = -1;
1059 const bool needsTimeControl =
1068 if (enabled && newDigs[nFunc] != digests_[oldIndex])
1070 const bool wasTimeControl =
1071 isA<functionObjects::timeControl>(*objPtr);
1073 if (needsTimeControl != wasTimeControl)
1078 objPtr.
reset(
nullptr);
1087 "functionObject::" + objPtr->name() +
"::read"
1090 enabled = objPtr->read(
dict);
1097 objPtr.
reset(
nullptr);
1102 if (enabled && !objPtr)
1114 "functionObject::" + key +
"::new"
1116 if (needsTimeControl)
1130 objPtr.
reset(
nullptr);
1132 switch (errorHandling)
1134 case errorHandlingType::IGNORE:
1137 case errorHandlingType::STRICT:
1143 case errorHandlingType::DEFAULT:
1145 if (isA<Foam::IOerror>(err))
1156 case errorHandlingType::WARN:
1161 <<
"--> loading function object '"
1176 objPtr.
reset(
nullptr);
1184 newPtrs.
set(nFunc, objPtr);
1185 newIndices.
insert(key, nFunc);
1192 errorHandling_.resize(nFunc);
1197 digests_.transfer(newDigs);
1198 indices_.transfer(newIndices);
1213 bool changed = funcObj.filesModified();
1227 funcObj.updateMesh(mpm);
1239 funcObj.movePoints(
mesh);
Functions used by OpenFOAM that are specific to POSIX compliant operating systems and need to be repl...
Enum is a wrapper around a list of names/values that represent particular enumeration (or int) values...
bool insert(const Key &key)
Insert a new entry, not overwriting existing entries.
A HashTable similar to std::unordered_map.
List< Key > sortedToc() const
The table of contents (the keys) in sorted order.
bool insert(const Key &key, const T &obj)
Copy insert a new entry, not overwriting existing entries.
IOdictionary is derived from dictionary and IOobject to give the dictionary automatic IO functionalit...
Defines the attributes of an object for which implicit objectRegistry management is supported,...
The IOstreamOption is a simple container for options an IOstream can normally have.
static unsigned int precision_
Default precision.
Generic input stream using a standard (STL) stream.
Input from string buffer, using a ISstream. Always UNCOMPRESSED.
void exit()
Job end with "exit" termination.
A 1D array of objects of type <T>, where the size of the vector is known and used for subscript bound...
void resize(const label len)
Adjust allocated size of list.
unsigned int remove()
Remove and return the last element.
A list of pointers to objects of type <T>, with allocation/deallocation management of the pointers....
const T * set(const label i) const
void clear()
Clear the PtrList. Delete allocated entries and set size to zero.
void resize(const label newLen)
Adjust size of PtrList.
A simple wrapper around bool so that it can be read as a word: true/false, on/off,...
bool good() const noexcept
True if the Switch represents a valid enumeration.
Class to control time during OpenFOAM simulations that is also the top-level objectRegistry.
static autoPtr< Time > New()
Construct (dummy) Time - no functionObjects or libraries.
static word timeName(const scalar t, const int precision=precision_)
A 2-tuple for storing two objects of dissimilar types. The container is similar in purpose to std::pa...
A 1D vector of objects of type <T>, where the size of the vector is known and can be used for subscri...
bool empty() const noexcept
True if the UList is empty (ie, size() is zero)
void size(const label n)
Older name for setAddressableSize.
static bool & parRun() noexcept
Test if this a parallel run.
Extract command arguments and options from the supplied argc and argv parameters.
label size() const noexcept
The number of arguments.
bool found(const word &optName) const
Return true if the named option is found.
List< T > getList(const label index) const
Get a List of values from the argument at index.
T getOrDefault(const word &optName, const T &deflt) const
Get a value from the named option if present, or return default.
Pointer management similar to std::unique_ptr, with some additional methods and type checking.
void reset(autoPtr< T > &&other) noexcept
Delete managed object and set to new given pointer.
A keyword and a list of tokens is a 'dictionaryEntry'.
A list of keyword definitions, which are a keyword followed by a number of values (eg,...
T get(const word &keyword, enum keyType::option matchOpt=keyType::REGEX) const
dictionary * findDict(const word &keyword, enum keyType::option matchOpt=keyType::REGEX)
Find and return a sub-dictionary pointer if present.
bool merge(const dictionary &dict)
Merge entries from the given dictionary.
T getOrDefault(const word &keyword, const T &deflt, enum keyType::option matchOpt=keyType::REGEX) const
entry * findEntry(const word &keyword, enum keyType::option matchOpt=keyType::REGEX)
Find for an entry (non-const access) with the given keyword.
bool found(const word &keyword, enum keyType::option matchOpt=keyType::REGEX) const
Search for an entry (const access) with the given keyword.
entry * add(entry *entryPtr, bool mergeEntry=false)
Add a new entry.
entry * set(entry *entryPtr)
Assign a new entry, overwriting any existing entry.
SHA1Digest digest() const
Return the SHA1 digest of the dictionary contents.
A keyword and a list of tokens is an 'entry'.
virtual bool isDict() const noexcept
Return true if this entry is a dictionary.
virtual const dictionary & dict() const =0
Return dictionary, if entry is a dictionary.
Class to handle errors and exceptions in a simple, consistent stream-based manner.
static void printStack(Ostream &os)
Helper function to print a stack.
virtual void write(Ostream &os, const bool withTitle=true) const
Print error message.
static bool useAbort()
True if FOAM_ABORT is on.
bool throwing() const noexcept
Return the current exception throwing state (on or off)
A class for handling file names.
static const fileName null
An empty fileName.
List of function objects with start(), execute() and end() functions that is called for each object.
static fileName findDict(const word &funcName)
void off()
Switch the function objects off.
objectRegistry & storedObjects()
bool filesModified() const
Did any file get changed during execution?
label findObjectID(const word &objName) const
Find the ID of a given function object by name, -1 if not found.
bool adjustTimeStep()
Called at the end of Time::adjustDeltaT() if adjustTime is true.
bool start()
Called at the start of the time-loop.
void clear()
Clear the list of function objects.
void resetPropertiesDict()
Reset/read properties dictionary for current time.
functionObjects::properties & propsDict()
bool status() const
Return the execution status (on/off) of the function objects.
label triggerIndex() const
Return the current trigger index (read from the propsDict)
bool execute()
Called at each ++ or += of the time-loop.
static bool readFunctionObject(const string &funcNameArgs0, dictionary &functionsDict, HashSet< wordRe > &requiredFields, const word ®ion=word::null)
static fileName functionObjectDictPath
bool end()
Called when Time::run() determines that the time-loop exits.
void on()
Switch the function objects on.
bool read()
Read and set the function objects if their data have changed.
Abstract base-class for Time/database function objects.
static bool defaultUseNamePrefix
Global default for useNamePrefix.
Storage for function object properties, derived from IOdictionary. Provides functionality to read/wri...
Wrapper around functionObjects to add time control.
static bool entriesPresent(const dictionary &dict)
Helper function to identify if a timeControl object is present.
virtual void validate()
Validate the turbulence fields after construction.
Class containing mesh-to-mesh mapping information after a change in polyMesh topology.
void movePoints()
Update for new mesh geometry.
void updateMesh()
Update for new mesh topology.
Registry of regIOobjects.
Mesh consisting of general polyhedral cells.
transferModelList & transfer()
Transfer.
A wordRe is a Foam::word, but can contain a regular expression for matching words or strings.
A List of wordRe with additional matching capabilities.
A class for handling words, derived from Foam::string.
fileName path(UMean.rootPath()/UMean.caseName()/"graphs"/UMean.instance())
runTime controlDict().readEntry("adjustTimeStep"
Foam::word regionName(Foam::polyMesh::defaultRegion)
#define FatalIOErrorInFunction(ios)
Report an error message using Foam::FatalIOError.
Functions to search 'etc' directories for configuration files etc.
static constexpr const uint32_t maxWarnings
Max number of warnings (per functionObject)
#define IOWarningInFunction(ios)
Report an IO warning using Foam::Warning.
#define WarningInFunction
Report a warning using Foam::Warning.
bool match(const UList< wordRe > &patterns, const std::string &text)
Return true if text matches one of the regular expressions.
label splitFunctionArgs(const std::string &str, wordRes &args, List< Tuple2< word, string > > &namedArgs)
Split out arguments (named or unnamed) from an input string.
string expand(const std::string &s, const HashTable< string > &mapping, const char sigil='$')
const fileOperation & fileHandler()
Get current file handler.
bool read(const char *buf, int32_t &val)
Same as readInt32.
prefixOSstream Perr
OSstream wrapped stderr (std::cerr) with parallel prefix.
static void exitNow(const error &err)
Mimic exit handling of the error class.
messageStream Info
Information stream (stdout output on master, null elsewhere)
Ostream & endl(Ostream &os)
Add newline and flush stream.
fileNameList readDir(const fileName &directory, const fileName::Type type=fileName::FILE, const bool filtergz=true, const bool followLink=true)
Read a directory and return the entries as a fileName List.
bool isFile(const fileName &name, const bool checkGzip=true, const bool followLink=true)
Does the name exist as a FILE in the file system?
HashSet< word, Hash< word > > wordHashSet
A HashSet of words, uses string hasher.
T returnReduce(const T &value, const BinaryOp &bop, const int tag=UPstream::msgType(), const label comm=UPstream::worldComm)
Reduce (copy) and return value.
fileNameList findEtcDirs(const fileName &name, unsigned short location=0777, const bool findFirst=false)
Search for directories from user/group/other etc locations.
errorManipArg< error, int > exit(error &err, const int errNo=1)
fileName search(const word &file, const fileName &directory)
Recursively search the given directory for the file.
constexpr char nl
The newline '\n' character (0x0a)
#define addProfiling(name, descr)
Define profiling trigger with specified name and description string.
Foam::argList args(argc, argv)
IOdictionary propsDict(dictIO)