Go to the documentation of this file.
45 "caseDicts/postProcessing"
51 void Foam::functionObjectList::createStateDict()
const
61 "functionObjectProperties",
63 "uniform"/word(
"functionObjects"),
73 void Foam::functionObjectList::createOutputRegistry()
const
75 objectsRegistryPtr_.reset
81 "functionObjectObjects",
98 autoPtr<functionObject> oldptr;
100 auto iter = indices_.find(key);
107 oldptr = this->release(oldIndex);
108 indices_.erase(iter);
119 void Foam::functionObjectList::listDir
137 listDir(dir/d, available);
148 listDir(d, available);
152 <<
"Available configured functionObjects:"
171 dictFile =
search(funcName, d);
172 if (!dictFile.empty())
184 const string& funcNameArgs,
197 word funcName(funcNameArgs);
203 bool hasNamedArg =
false;
211 word::const_iterator iter = funcNameArgs.begin();
212 iter != funcNameArgs.end();
222 funcName = funcNameArgs.substr(start, i - start);
227 else if (
c ==
',' ||
c ==
')')
238 funcNameArgs.substr(start, i - start)
251 funcNameArgs.substr(start, i - start)
272 funcNameArgs.substr(start, i - start)
288 <<
"Cannot find functionObject file " << funcName <<
endl;
294 ISstream& fileStream = fileStreamPtr();
298 dictionary& funcDict = (funcDictPtr ? *funcDictPtr : funcsDict);
306 funcDict.
set(
"field",
args[0]);
315 else if (funcDict.
found(
"field"))
319 else if (funcDict.
found(
"fields"))
329 namedArg.first() +
' ' + namedArg.second() +
';'
338 funcDict.
set(
"region", region);
344 functionsDict.
merge(funcArgsDict);
352 Foam::functionObjectList::functionObjectList
364 objectsRegistryPtr_(),
365 execution_(execution),
370 Foam::functionObjectList::functionObjectList
381 parentDict_(parentDict),
383 objectsRegistryPtr_(),
384 execution_(execution),
408 bool modifiedControlDict =
false;
412 modifiedControlDict =
true;
430 modifiedControlDict =
true;
443 modifiedControlDict =
true;
447 for (
const word& funcName : funcNames)
462 if (modifiedControlDict)
471 functionsPtr->
start();
482 stateDict().readIfPresent(
"triggerIndex", triggeri);
491 stateDictPtr_.clear();
498 if (!stateDictPtr_.valid())
503 return *stateDictPtr_;
509 if (!stateDictPtr_.valid())
514 return *stateDictPtr_;
520 if (!objectsRegistryPtr_.valid())
522 createOutputRegistry();
525 return *objectsRegistryPtr_;
531 if (!objectsRegistryPtr_.valid())
533 createOutputRegistry();
536 return *objectsRegistryPtr_;
555 if (funcObj.name() ==
name)
576 updated_ = execution_ =
false;
605 const word& objName = funcObj.name();
607 addProfiling(fo,
"functionObject::" + objName +
"::execute");
609 ok = funcObj.execute() && ok;
613 addProfiling(fo,
"functionObject::" + objName +
"::write");
615 ok = funcObj.write() && ok;
621 if (time_.writeTime())
626 stateDictPtr_->writeObject
641 bool ok = execution_;
647 ok = funcObj.execute(subIndex) && ok;
661 bool ok = execution_;
663 if (ok && functionNames.
size())
669 ok = funcObj.execute(subIndex) && ok;
691 const word& objName = funcObj.name();
693 addProfiling(fo,
"functionObject::" + objName +
"::end");
695 ok = funcObj.end() && ok;
716 const word& objName = funcObj.name();
718 addProfiling(fo,
"functionObject::" + objName +
"::adjustTimeStep");
720 ok = funcObj.adjustTimeStep() && ok;
730 if (!stateDictPtr_.valid())
735 updated_ = execution_;
744 const entry* entryPtr =
756 else if (!entryPtr->
isDict())
761 <<
"'functions' entry is not a dictionary"
774 const_cast<Time&
>(time_).libs().open
778 functionObject::dictionaryConstructorTablePtr_
783 for (
const entry& dEntry : functionsDict)
785 const word& key = dEntry.keyword();
787 if (!dEntry.isDict())
792 <<
"Entry " << key <<
" is not a dictionary" <<
endl;
811 if (enabled && newDigs[nFunc] != digests_[oldIndex])
816 "functionObject::" + objPtr->
name() +
"::read"
821 if (isA<functionObjects::timeControl>(objPtr()))
872 "functionObject::" + key +
"::new"
897 <<
"--> while loading function object '" << key <<
"'"
919 newPtrs.set(nFunc, objPtr);
920 newIndices.insert(key, nFunc);
926 newDigs.resize(nFunc);
931 digests_.transfer(newDigs);
932 indices_.transfer(newIndices);
946 bool changed = funcObj.filesModified();
960 funcObj.updateMesh(mpm);
972 funcObj.movePoints(
mesh);
A keyword and a list of tokens is an 'entry'.
dictionary * findDict(const word &keyword, enum keyType::option matchOpt=keyType::REGEX)
Find and return a sub-dictionary pointer if present.
IOdictionary is derived from dictionary and IOobject to give the dictionary automatic IO functionalit...
void reset(T *p=nullptr) noexcept
Delete managed object and set to new given pointer.
void movePoints(const polyMesh &mesh)
Update for changes of mesh.
Defines the attributes of an object for which implicit objectRegistry management is supported,...
A keyword and a list of tokens is a 'dictionaryEntry'.
#define InfoInFunction
Report an information message using Foam::Info.
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.
bool status() const
Return the execution status (on/off) of the function objects.
Class to control time during OpenFOAM simulations that is also the top-level objectRegistry.
bool adjustTimeStep()
Called at the end of Time::adjustDeltaT() if adjustTime is true.
static fileName findDict(const word &funcName)
A class for handling words, derived from Foam::string.
A class for handling file names.
T returnReduce(const T &Value, const BinaryOp &bop, const int tag=Pstream::msgType(), const label comm=UPstream::worldComm)
static autoPtr< functionObject > New(const word &name, const Time &runTime, const dictionary &dict)
Select from dictionary, based on its "type" entry.
T getOrDefault(const word &optName, const T &deflt) const
Get a value from the named option if present, or return default.
void on()
Switch the function objects on.
bool found(const word &keyword, enum keyType::option matchOpt=keyType::REGEX) const
Search for an entry (const access) with the given keyword.
bool read(const char *buf, int32_t &val)
Same as readInt32.
fileNameList findEtcDirs(const fileName &name, unsigned short location=0777, const bool findFirst=false)
Search for directories from user/group/other etc locations.
IOdictionary & stateDict()
static word timeName(const scalar t, const int precision=precision_)
Wrapper around functionObjects to add time control.
Generic input stream using a standard (STL) stream.
void updateMesh(const mapPolyMesh &mpm)
Update for changes of mesh.
static word validate(const std::string &s, const bool prefix=false)
Construct validated word (no invalid characters).
Extract command arguments and options from the supplied argc and argv parameters.
bool isFile(const fileName &name, const bool checkGzip=true, const bool followLink=true)
Does the name exist as a FILE in the file system?
const fileOperation & fileHandler()
Get current file handler.
void append(const T &val)
Append an element at the end of the list.
bool valid() const noexcept
True if the managed pointer is non-null.
Ostream & endl(Ostream &os)
Add newline and flush stream.
static unsigned int precision_
Default precision.
T get(const word &keyword, enum keyType::option matchOpt=keyType::REGEX) const
entry * set(entry *entryPtr)
Assign a new entry, overwriting any existing entry.
bool execute()
Called at each ++ or += of the time-loop.
List of function objects with start(), execute() and end() functions that is called for each object.
A wordRe is a Foam::word, but can contain a regular expression for matching words or strings.
label findObjectID(const word &name) const
Find the ID of a given function object by name, -1 if not found.
bool start()
Called at the start of the time-loop.
Mesh consisting of general polyhedral cells.
Abstract base-class for Time/database function objects.
void clear()
Clear the list of function objects.
static const dictionary null
An empty dictionary, which is also the parent for all dictionaries.
Registry of regIOobjects.
string expand(const std::string &s, const HashTable< string, word, string::hash > &mapping, const char sigil='$')
bool merge(const dictionary &dict)
Merge entries from the given dictionary.
virtual bool isDict() const
Return true if this entry is a dictionary.
void off()
Switch the function objects off.
label triggerIndex() const
Return the current trigger index (read from the stateDict)
messageStream Info
Information stream (uses stdout - output is on the master only)
word name(const complex &c)
Return string representation of complex.
T * release() noexcept
Return pointer to the managed object and release ownership.
runTime controlDict().readEntry("adjustTimeStep"
The IOstreamOption is a simple container for options an IOstream can normally have.
static fileName functionObjectDictPath
graph_traits< Graph >::vertices_size_type size_type
virtual bool read(const dictionary &dict)
Read and set the function object if its data have changed.
#define addProfiling(name, descr)
Define profiling trigger with specified name and description string.
A list of keyword definitions, which are a keyword followed by a number of values (eg,...
const dictionary & controlDict() const
Return read access to the controlDict dictionary.
static autoPtr< functionObjectList > New(const argList &args, const Time &runTime, dictionary &controlDict, HashSet< wordRe > &requiredFields)
Construct and return a functionObjectList for an application.
void clear()
Clear the PtrList. Delete allocated entries and set size to zero.
Input from string buffer, using a ISstream.
virtual const dictionary & dict() const =0
Return dictionary, if entry is a dictionary.
List< Key > sortedToc() const
The table of contents (the keys) in sorted order.
static const fileName null
An empty fileName.
errorManipArg< error, int > exit(error &err, const int errNo=1)
void resize(const label newLen)
Adjust size of PtrList.
Functions to search 'etc' directories for configuration files etc.
label size() const noexcept
The number of arguments.
bool match(const UList< wordRe > &patterns, const std::string &text)
Return true if text matches one of the regular expressions.
static bool readFunctionObject(const string &funcNameArgs0, dictionary &functionsDict, HashSet< wordRe > &requiredFields, const word ®ion=word::null)
const word & name() const
Return the name of this functionObject.
A 1D array of objects of type <T>, where the size of the vector is known and used for subscript bound...
A 1D vector of objects of type <T>, where the size of the vector is known and can be used for subscri...
A List of wordRe with additional matching capabilities.
bool insert(const Key &key)
Insert a new entry, not overwriting existing entries.
fileName path(UMean.rootPath()/UMean.caseName()/"graphs"/UMean.instance())
fileName search(const word &file, const fileName &directory)
Recursively search the given directory for the file.
List< T > getList(const label index) const
Get a List of values from the argument at index.
void clear() noexcept
Same as reset(nullptr)
Class containing mesh-to-mesh mapping information after a change in polyMesh topology.
const dimensionedScalar c
Speed of light in a vacuum.
HashSet< word > wordHashSet
A HashSet with word keys.
void size(const label n) noexcept
Override size to be inconsistent with allocated storage.
entry * add(entry *entryPtr, bool mergeEntry=false)
Add a new entry.
static bool entriesPresent(const dictionary &dict)
Helper function to identify if a timeControl object is present.
#define FatalIOErrorInFunction(ios)
Report an error message using Foam::FatalIOError.
void write(Ostream &os, const bool includeTitle=true) const
Print error message.
SHA1Digest digest() const
Return the SHA1 digest of the dictionary contents.
#define IOWarningInFunction(ios)
Report an IO warning using Foam::Warning.
A 2-tuple for storing two objects of dissimilar types. The container is similar in purpose to std::pa...
bool read()
Read and set the function objects if their data have changed.
T getOrDefault(const word &keyword, const T &deflt, enum keyType::option matchOpt=keyType::REGEX) const
void resetState()
Reset/read state dictionary for current time.
Foam::argList args(argc, argv)
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 throwExceptions(bool doThrow)
Activate/deactivate exception throwing.
#define WarningInFunction
Report a warning using Foam::Warning.
Class to handle errors and exceptions in a simple, consistent stream-based manner.
bool end()
Called when Time::run() determines that the time-loop exits.
objectRegistry & storedObjects()
void transfer(PtrList< T > &list)
Transfer into this list and annul the argument list.
bool found(const word &optName) const
Return true if the named option is found.
bool filesModified() const
Did any file get changed during execution?