functionObjectList.C
Go to the documentation of this file.
1 /*---------------------------------------------------------------------------*\
2  ========= |
3  \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
4  \\ / O peration | Website: https://openfoam.org
5  \\ / A nd | Copyright (C) 2011-2021 OpenFOAM Foundation
6  \\/ M anipulation |
7 -------------------------------------------------------------------------------
8 License
9  This file is part of OpenFOAM.
10 
11  OpenFOAM is free software: you can redistribute it and/or modify it
12  under the terms of the GNU General Public License as published by
13  the Free Software Foundation, either version 3 of the License, or
14  (at your option) any later version.
15 
16  OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
17  ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
18  FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
19  for more details.
20 
21  You should have received a copy of the GNU General Public License
22  along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
23 
24 \*---------------------------------------------------------------------------*/
25 
26 #include "functionObjectList.H"
27 #include "argList.H"
29 #include "dictionaryEntry.H"
30 #include "stringOps.H"
31 #include "etcFiles.H"
32 #include "wordAndDictionary.H"
33 
34 
35 /* * * * * * * * * * * * * * * Static Member Data * * * * * * * * * * * * * */
36 
38 (
39  "caseDicts/postProcessing"
40 );
41 
42 
43 // * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * * //
44 
45 Foam::functionObject* Foam::functionObjectList::remove
46 (
47  const word& key,
48  label& oldIndex
49 )
50 {
51  functionObject* ptr = 0;
52 
53  // Find index of existing functionObject
54  HashTable<label>::iterator fnd = indices_.find(key);
55 
56  if (fnd != indices_.end())
57  {
58  oldIndex = fnd();
59 
60  // Retrieve the pointer and remove it from the old list
61  ptr = this->set(oldIndex, 0).ptr();
62  indices_.erase(fnd);
63  }
64  else
65  {
66  oldIndex = -1;
67  }
68 
69  return ptr;
70 }
71 
72 
73 void Foam::functionObjectList::listDir
74 (
75  const fileName& dir,
76  HashSet<word>& foMap
77 )
78 {
79  // Search specified directory for functionObject configuration files
80  {
81  fileNameList foFiles(fileHandler().readDir(dir));
82  forAll(foFiles, f)
83  {
84  if (foFiles[f].ext().empty())
85  {
86  foMap.insert(foFiles[f]);
87  }
88  }
89  }
90 
91  // Recurse into sub-directories
92  {
94  forAll(foDirs, fd)
95  {
96  listDir(dir/foDirs[fd], foMap);
97  }
98  }
99 }
100 
101 
103 {
104  HashSet<word> foMap;
105 
107 
108  forAll(etcDirs, ed)
109  {
110  listDir(etcDirs[ed], foMap);
111  }
112 
113  Info<< nl
114  << "Available configured functionObjects:"
115  << foMap.sortedToc()
116  << nl;
117 }
118 
119 
121 (
122  const word& funcName,
123  const word& region
124 )
125 {
126  // First check if there is a functionObject dictionary file in the
127  // region system directory
128  {
129  const fileName dictFile
130  (
131  stringOps::expand("$FOAM_CASE")/"system"/region/funcName
132  );
133 
134  if (isFile(dictFile))
135  {
136  return dictFile;
137  }
138  }
139 
140  // Next, if the region is specified, check if there is a functionObject
141  // dictionary file in the global system directory
142  if (region != word::null)
143  {
144  const fileName dictFile
145  (
146  stringOps::expand("$FOAM_CASE")/"system"/funcName
147  );
148 
149  if (isFile(dictFile))
150  {
151  return dictFile;
152  }
153  }
154 
155  // Finally, check etc directories
156  {
158 
159  forAll(etcDirs, i)
160  {
161  const fileName dictFile(search(funcName, etcDirs[i]));
162 
163  if (!dictFile.empty())
164  {
165  return dictFile;
166  }
167  }
168  }
169 
170  return fileName::null;
171 }
172 
173 
175 Foam::functionObjectList::unsetEntries(const dictionary& funcDict)
176 {
177  const wordRe unsetPattern("<.*>");
178  unsetPattern.compile();
179 
180  List<Tuple2<word, string>> unsetArgs;
181 
182  forAllConstIter(IDLList<entry>, funcDict, iter)
183  {
184  if (iter().isStream())
185  {
186  ITstream& its = iter().stream();
187  OStringStream oss;
188  bool isUnset = false;
189 
190  forAll(its, i)
191  {
192  oss << its[i];
193  if (its[i].isWord() && unsetPattern.match(its[i].wordToken()))
194  {
195  isUnset = true;
196  }
197  }
198 
199  if (isUnset)
200  {
201  unsetArgs.append
202  (
204  (
205  iter().keyword(),
206  oss.str()
207  )
208  );
209  }
210  }
211  else
212  {
213  List<Tuple2<word, string>> subUnsetArgs =
214  unsetEntries(iter().dict());
215 
216  forAll(subUnsetArgs, i)
217  {
218  unsetArgs.append
219  (
221  (
222  iter().keyword() + '/' + subUnsetArgs[i].first(),
223  subUnsetArgs[i].second()
224  )
225  );
226  }
227  }
228  }
229 
230  return unsetArgs;
231 }
232 
233 
235 (
236  const string& funcArgs,
237  dictionary& functionsDict,
238  const Pair<string>& contextTypeAndValue,
239  HashSet<word>& requiredFields,
240  const word& region
241 )
242 {
243  word funcType;
245  List<Tuple2<word, string>> namedArgs;
246 
247  dictArgList(funcArgs, funcType, args, namedArgs);
248 
249  // Search for the functionObject dictionary
250  fileName path = findDict(funcType, region);
251 
252  if (path == fileName::null)
253  {
255  << "Cannot find functionObject file " << funcType << endl;
256  return false;
257  }
258 
259  // Read the functionObject dictionary
260  // IFstream fileStream(path);
261  autoPtr<ISstream> fileStreamPtr(fileHandler().NewIFstream(path));
262  ISstream& fileStream = fileStreamPtr();
263 
264  // Delay processing the functionEntries
265  // until after the function argument entries have been added
267  dictionary funcsDict(funcType, functionsDict, fileStream);
269 
270  dictionary* funcDictPtr = &funcsDict;
271 
272  if (funcsDict.found(funcType) && funcsDict.isDict(funcType))
273  {
274  funcDictPtr = &funcsDict.subDict(funcType);
275  }
276 
277  dictionary& funcDict = *funcDictPtr;
278 
279  // Store the funcDict as read for error reporting context
280  const dictionary funcDict0(funcDict);
281 
282  // Insert the 'field' and/or 'fields' and 'objects' entries corresponding
283  // to both the arguments and the named arguments
285  forAll(args, i)
286  {
287  fieldArgs.append(wordAndDictionary(args[i], dictionary::null));
288  }
289  forAll(namedArgs, i)
290  {
291  if (namedArgs[i].first() == "field")
292  {
293  IStringStream iss(namedArgs[i].second());
294  fieldArgs.append(wordAndDictionary(iss));
295  }
296  if
297  (
298  namedArgs[i].first() == "fields"
299  || namedArgs[i].first() == "objects"
300  )
301  {
302  IStringStream iss(namedArgs[i].second());
303  fieldArgs.append(List<wordAndDictionary>(iss));
304  }
305  }
306  if (fieldArgs.size() == 1)
307  {
308  funcDict.set("field", fieldArgs[0].first());
309  funcDict.merge(fieldArgs[0].second());
310  }
311  if (fieldArgs.size() >= 1)
312  {
313  funcDict.set("fields", fieldArgs);
314  funcDict.set("objects", fieldArgs);
315  }
316 
317  // Insert non-field arguments
318  forAll(namedArgs, i)
319  {
320  if
321  (
322  namedArgs[i].first() != "field"
323  && namedArgs[i].first() != "fields"
324  && namedArgs[i].first() != "objects"
325  )
326  {
327  const Pair<word> dAk(dictAndKeyword(namedArgs[i].first()));
328  dictionary& subDict(funcDict.scopedDict(dAk.first()));
329  IStringStream entryStream
330  (
331  dAk.second() + ' ' + namedArgs[i].second() + ';'
332  );
333  subDict.set(entry::New(entryStream).ptr());
334  }
335  }
336 
337  // Insert the region name if specified
338  if (region != word::null)
339  {
340  funcDict.set("region", region);
341  }
342 
343  // Set the name of the function entry to that specified by the optional
344  // funcName argument otherwise automatically generate a unique name
345  // from the function type and arguments
346  const word funcName
347  (
348  funcDict.lookupOrDefault("funcName", string::validate<word>(funcArgs))
349  );
350 
351  // Check for anything in the configuration that has not been set
352  List<Tuple2<word, string>> unsetArgs = unsetEntries(funcDict);
353  bool hasUnsetError = false;
354  forAll(unsetArgs, i)
355  {
356  if
357  (
358  unsetArgs[i].first() != "fields"
359  && unsetArgs[i].first() != "objects"
360  )
361  {
362  hasUnsetError = true;
363  }
364  }
365  if (!hasUnsetError)
366  {
367  forAll(unsetArgs, i)
368  {
369  funcDict.set(unsetArgs[i].first(), wordList());
370  }
371  }
372  else
373  {
374  FatalIOErrorInFunction(funcDict0)
375  << nl;
376 
377  forAll(unsetArgs, i)
378  {
379  FatalIOErrorInFunction(funcDict0)
380  << "Essential value for keyword '" << unsetArgs[i].first()
381  << "' not set" << nl;
382  }
383 
384  FatalIOErrorInFunction(funcDict0)
385  << nl << "In function entry:" << nl
386  << " " << funcArgs.c_str() << nl
387  << nl << "In " << contextTypeAndValue.first().c_str() << ":" << nl
388  << " " << contextTypeAndValue.second().c_str() << nl;
389 
390  word funcType;
392  List<Tuple2<word, string>> namedArgs;
393  dictArgList(funcArgs, funcType, args, namedArgs);
394 
395  string argList;
396  forAll(args, i)
397  {
398  args[i].strip(" \n");
399  argList += (argList.size() ? ", " : "") + args[i];
400  }
401  forAll(namedArgs, i)
402  {
403  namedArgs[i].second().strip(" \n");
404  argList +=
405  (argList.size() ? ", " : "")
406  + namedArgs[i].first() + " = " + namedArgs[i].second();
407  }
408  forAll(unsetArgs, i)
409  {
410  unsetArgs[i].second().strip(" \n");
411  argList +=
412  (argList.size() ? ", " : "")
413  + unsetArgs[i].first() + " = " + unsetArgs[i].second();
414  }
415 
416  FatalIOErrorInFunction(funcDict0)
417  << nl << "The function entry should be:" << nl
418  << " " << funcType << '(' << argList.c_str() << ')'
419  << exit(FatalIOError);
420  }
421 
422  // Re-parse the funcDict to execute the functionEntries
423  // now that the function argument entries have been added
424  dictionary funcArgsDict;
425  funcArgsDict.add(funcName, funcDict);
426  {
427  OStringStream os;
428  funcArgsDict.write(os);
429  funcArgsDict = dictionary
430  (
431  funcType,
432  functionsDict,
433  IStringStream(os.str())()
434  );
435  }
436 
437  // Lookup the field, fields and objects entries from the now expanded
438  // funcDict and insert into the requiredFields
439  dictionary& expandedFuncDict = funcArgsDict.subDict(funcName);
440  if (functionObject::debug)
441  {
443  << nl << incrIndent << indent
444  << funcArgs << expandedFuncDict
445  << decrIndent << endl;
446  }
447  if (expandedFuncDict.found("field"))
448  {
449  requiredFields.insert(word(expandedFuncDict.lookup("field")));
450  }
451  if (expandedFuncDict.found("fields"))
452  {
453  List<wordAndDictionary> fields(expandedFuncDict.lookup("fields"));
454  forAll(fields, i)
455  {
456  requiredFields.insert(fields[i].first());
457  }
458  }
459  if (expandedFuncDict.found("objects"))
460  {
461  List<wordAndDictionary> objects(expandedFuncDict.lookup("objects"));
462  forAll(objects, i)
463  {
464  requiredFields.insert(objects[i].first());
465  }
466  }
467 
468  // Merge this functionObject dictionary into functionsDict
469  functionsDict.merge(funcArgsDict);
470  functionsDict.subDict(funcName).name() = funcDict.name();
471 
472  return true;
473 }
474 
475 
476 // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
477 
479 (
480  const Time& t,
481  const bool execution
482 )
483 :
485  digests_(),
486  indices_(),
487  time_(t),
488  parentDict_(t.controlDict()),
489  execution_(execution),
490  updated_(false)
491 {}
492 
493 
495 (
496  const Time& t,
497  const dictionary& parentDict,
498  const bool execution
499 )
500 :
502  digests_(),
503  indices_(),
504  time_(t),
505  parentDict_(parentDict),
506  execution_(execution),
507  updated_(false)
508 {}
509 
510 
512 (
513  const argList& args,
514  const Time& runTime,
515  dictionary& controlDict,
516  HashSet<word>& requiredFields
517 )
518 {
519  autoPtr<functionObjectList> functionsPtr;
520 
521  controlDict.add
522  (
523  dictionaryEntry("functions", controlDict, dictionary::null)
524  );
525 
526  dictionary& functionsDict = controlDict.subDict("functions");
527 
528  word region = word::null;
529 
530  // Set the region name if specified
531  if (args.optionFound("region"))
532  {
533  region = args["region"];
534  }
535 
536  if
537  (
538  args.optionFound("dict")
539  || args.optionFound("func")
540  || args.optionFound("funcs")
541  )
542  {
543  if (args.optionFound("dict"))
544  {
545  controlDict.merge
546  (
548  (
549  IOobject
550  (
551  args["dict"],
552  runTime,
554  )
555  )
556  );
557  }
558 
559  if (args.optionFound("func"))
560  {
562  (
563  args["func"],
564  functionsDict,
565  {"command", args.commandLine()},
566  requiredFields,
567  region
568  );
569  }
570 
571  if (args.optionFound("funcs"))
572  {
573  wordList funcs(args.optionLookup("funcs")());
574 
575  forAll(funcs, i)
576  {
578  (
579  funcs[i],
580  functionsDict,
581  {"command", args.commandLine()},
582  requiredFields,
583  region
584  );
585  }
586  }
587 
588  functionsPtr.reset(new functionObjectList(runTime, controlDict));
589  }
590  else
591  {
592  functionsPtr.reset(new functionObjectList(runTime));
593  }
594 
595  functionsPtr->read();
596 
597  return functionsPtr;
598 }
599 
600 
601 // * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * //
602 
604 {}
605 
606 
607 // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
608 
610 {
612  digests_.clear();
613  indices_.clear();
614  updated_ = false;
615 }
616 
617 
619 {
620  forAll(*this, oi)
621  {
622  if (operator[](oi).name() == name)
623  {
624  return oi;
625  }
626  }
627 
628  return -1;
629 }
630 
631 
633 {
634  execution_ = true;
635 }
636 
637 
639 {
640  // For safety, also force a read() when execution is turned back on
641  updated_ = execution_ = false;
642 }
643 
644 
646 {
647  return execution_;
648 }
649 
650 
652 {
653  bool ok = read();
654 
655  if (execution_)
656  {
657  forAll(*this, oi)
658  {
659  if (operator[](oi).executeAtStart())
660  {
661  ok = operator[](oi).execute() && ok;
662  ok = operator[](oi).write() && ok;
663  }
664  }
665  }
666 
667  return ok;
668 }
669 
670 
672 {
673  bool ok = true;
674 
675  if (execution_)
676  {
677  if (!updated_)
678  {
679  read();
680  }
681 
682  forAll(*this, oi)
683  {
684  ok = operator[](oi).execute() && ok;
685  ok = operator[](oi).write() && ok;
686  }
687  }
688 
689  return ok;
690 }
691 
692 
694 {
695  bool ok = true;
696 
697  if (execution_)
698  {
699  if (!updated_)
700  {
701  read();
702  }
703 
704  forAll(*this, oi)
705  {
706  ok = operator[](oi).end() && ok;
707  }
708  }
709 
710  return ok;
711 }
712 
713 
715 {
716  scalar result = vGreat;
717 
718  if (execution_)
719  {
720  if (!updated_)
721  {
722  read();
723  }
724 
725  forAll(*this, oi)
726  {
727  result = min(result, operator[](oi).timeToNextWrite());
728  }
729  }
730 
731  return result;
732 }
733 
734 
736 {
737  bool ok = true;
738  updated_ = execution_;
739 
740  // Avoid reading/initialising if execution is off
741  if (!execution_)
742  {
743  return true;
744  }
745 
746  // Update existing and add new functionObjects
747  const entry* entryPtr = parentDict_.lookupEntryPtr
748  (
749  "functions",
750  false,
751  false
752  );
753 
754  if (entryPtr)
755  {
756  PtrList<functionObject> newPtrs;
757  List<SHA1Digest> newDigs;
758  HashTable<label> newIndices;
759 
760  label nFunc = 0;
761 
762  if (!entryPtr->isDict())
763  {
764  FatalIOErrorInFunction(parentDict_)
765  << "'functions' entry is not a dictionary"
766  << exit(FatalIOError);
767  }
768 
769  const dictionary& functionsDict = entryPtr->dict();
770 
771  libs.open
772  (
773  functionsDict,
774  "libs",
775  functionObject::dictionaryConstructorTablePtr_
776  );
777 
778  newPtrs.setSize(functionsDict.size());
779  newDigs.setSize(functionsDict.size());
780 
781  forAllConstIter(dictionary, functionsDict, iter)
782  {
783  const word& key = iter().keyword();
784 
785  if (!iter().isDict())
786  {
787  if (key != "libs")
788  {
789  IOWarningInFunction(parentDict_)
790  << "Entry " << key << " is not a dictionary" << endl;
791  }
792 
793  continue;
794  }
795 
796  const dictionary& dict = iter().dict();
797  bool enabled = dict.lookupOrDefault("enabled", true);
798 
799  newDigs[nFunc] = dict.digest();
800 
801  label oldIndex;
802  functionObject* objPtr = remove(key, oldIndex);
803 
804  if (objPtr)
805  {
806  if (enabled)
807  {
808  // Dictionary changed for an existing functionObject
809  if (newDigs[nFunc] != digests_[oldIndex])
810  {
811  ok = objPtr->read(dict) && ok;
812  }
813  }
814  else
815  {
816  // Delete the disabled functionObject
817  delete objPtr;
818  objPtr = nullptr;
819  continue;
820  }
821  }
822  else if (enabled)
823  {
825 
828  try
829  {
830  if
831  (
832  dict.found("writeControl")
833  || dict.found("outputControl")
834  )
835  {
836  foPtr.set
837  (
838  new functionObjects::timeControl(key, time_, dict)
839  );
840  }
841  else
842  {
843  foPtr = functionObject::New(key, time_, dict);
844  }
845  }
846  catch (Foam::IOerror& ioErr)
847  {
848  Info<< ioErr << nl << endl;
849  ::exit(1);
850  }
851  catch (Foam::error& err)
852  {
854  << "Caught FatalError " << err << nl << endl;
855  }
858 
859  if (foPtr.valid())
860  {
861  objPtr = foPtr.ptr();
862  }
863  else
864  {
865  ok = false;
866  }
867  }
868 
869  // Insert active functionObjects into the list
870  if (objPtr)
871  {
872  newPtrs.set(nFunc, objPtr);
873  newIndices.insert(key, nFunc);
874  nFunc++;
875  }
876  }
877 
878  newPtrs.setSize(nFunc);
879  newDigs.setSize(nFunc);
880 
881  // Updating the PtrList of functionObjects deletes any
882  // existing unused functionObjects
884  digests_.transfer(newDigs);
885  indices_.transfer(newIndices);
886  }
887  else
888  {
890  digests_.clear();
891  indices_.clear();
892  }
893 
894  return ok;
895 }
896 
897 
899 {
900  if (execution_)
901  {
902  forAll(*this, oi)
903  {
904  operator[](oi).updateMesh(mpm);
905  }
906  }
907 }
908 
909 
911 {
912  if (execution_)
913  {
914  forAll(*this, oi)
915  {
916  operator[](oi).movePoints(mesh);
917  }
918  }
919 }
920 
921 
922 // ************************************************************************* //
Template class for intrusive linked lists.
Definition: ILList.H:50
bool read()
Read and set the function objects if their data have changed.
void write(Ostream &, const bool subDict=true) const
Write dictionary, normally with sub-dictionary formatting.
Definition: dictionaryIO.C:207
A HashTable with keys but without contents.
Definition: HashSet.H:59
dictionary dict
bool found(const word &, bool recursive=false, bool patternMatch=true) const
Search dictionary for given keyword.
Definition: dictionary.C:643
#define forAll(list, i)
Loop across all elements in list.
Definition: UList.H:434
string expand(const string &, const HashTable< string, word, string::hash > &mapping, const char sigil='$')
Expand occurrences of variables according to the mapping.
Definition: stringOps.C:69
intWM_LABEL_SIZE_t label
A label is an int32_t or int64_t as specified by the pre-processor macro WM_LABEL_SIZE.
Definition: label.H:59
A class for handling file names.
Definition: fileName.H:79
Ostream & indent(Ostream &os)
Indent stream.
Definition: Ostream.H:221
const entry * lookupEntryPtr(const word &, bool recursive, bool patternMatch) const
Find and return an entry data stream pointer if present.
Definition: dictionary.C:682
bool set(const label) const
Is element set.
Definition: PtrListI.H:65
functionObjectList(const Time &runTime, const bool execution=true)
Construct from Time and the execution setting.
const dictionary & scopedDict(const word &) const
Find and return a sub-dictionary by scoped lookup.
Definition: dictionary.C:1057
SHA1Digest digest() const
Return the SHA1 digest of the dictionary contents.
Definition: dictionary.C:609
errorManipArg< error, int > exit(error &err, const int errNo=1)
Definition: errorManip.H:124
void reset(T *=nullptr)
If object pointer already set, delete object and set to given.
Definition: autoPtrI.H:114
static iteratorEnd end()
iteratorEnd set to beyond the end of any HashTable
Definition: HashTable.H:112
void off()
Switch the function objects off.
scalar timeToNextWrite()
Return the time to the next write.
error FatalError
A list of keyword definitions, which are a keyword followed by any number of values (e...
Definition: dictionary.H:156
A 2-tuple for storing two objects of different types.
Definition: HashTable.H:65
A 1D array of objects of type <T>, where the size of the vector is known and used for subscript bound...
Definition: HashTable.H:59
static void list()
Print a list of functionObject configuration files in.
bool isFile(const fileName &, const bool checkVariants=true, const bool followLink=true)
Does the name exist as a file in the file system?
Definition: POSIX.C:555
void size(const label)
Override size to be inconsistent with allocated storage.
Definition: ListI.H:164
static const fileName null
An empty fileName.
Definition: fileName.H:97
static bool New(dictionary &parentDict, Istream &)
Construct from Istream and insert into dictionary.
Definition: entryIO.C:92
const T & operator[](const label) const
Return element const reference.
Definition: UPtrListI.H:96
bool empty() const
Return true if the UPtrList is empty (ie, size() is zero)
Definition: UPtrListI.H:36
Ostream & endl(Ostream &os)
Add newline and flush stream.
Definition: Ostream.H:251
bool optionFound(const word &opt) const
Return true if the named option is found.
Definition: argListI.H:114
virtual const dictionary & dict() const =0
Return dictionary if this entry is a dictionary.
void on()
Switch the function objects on.
void transfer(HashTable< T, Key, Hash > &)
Transfer the contents of the argument table into this table.
Definition: HashTable.C:513
Info<< "Calculating turbulent flame speed field St\"<< endl;volScalarField St(IOobject("St", runTime.timeName(), mesh, IOobject::NO_READ, IOobject::AUTO_WRITE), flameWrinkling->Xi() *Su);multivariateSurfaceInterpolationScheme< scalar >::fieldTable fields
Definition: createFields.H:228
T * ptr()
Return object pointer for reuse.
Definition: autoPtrI.H:90
Abstract base-class for Time/database functionObjects.
bool insert(const Key &key)
Insert a new entry.
Definition: HashSet.H:111
A keyword and a list of tokens is a &#39;dictionaryEntry&#39;.
Tuple of a word and dictionary, used to read in per-field options for function objects in the followi...
Class to control time during OpenFOAM simulations that is also the top-level objectRegistry.
Definition: Time.H:68
bool start()
Called at the start of the time-loop.
dlLibraryTable libs
Table of loaded dynamic libraries.
bool compile() const
Compile the regular expression.
Definition: wordReI.H:161
Class containing mesh-to-mesh mapping information after a change in polyMesh topology.
Definition: mapPolyMesh.H:158
bool isDict(const word &) const
Check if entry is a sub-dictionary.
Definition: dictionary.C:936
bool add(entry *, bool mergeEntry=false)
Add a new entry.
Definition: dictionary.C:1133
bool erase(const iterator &)
Erase a hashedEntry specified by given iterator.
Definition: HashTable.C:371
IOdictionary is derived from dictionary and IOobject to give the dictionary automatic IO functionalit...
Definition: IOdictionary.H:53
const dictionary & subDict(const word &) const
Find and return a sub-dictionary.
Definition: dictionary.C:982
Class to handle errors and exceptions in a simple, consistent stream-based manner.
Definition: error.H:66
bool insert(const Key &, const T &newElmt)
Insert a new hashedEntry.
Definition: HashTableI.H:80
iterator find(const Key &)
Find and return an iterator set at the hashedEntry.
Definition: HashTable.C:142
bool execute()
Called at each ++ or += of the time-loop.
Pair< word > dictAndKeyword(const word &scopedName)
Extracts dict name and keyword.
Definition: dictionary.C:1776
static int disableFunctionEntries
Definition: entry.H:86
dynamicFvMesh & mesh
An ordered pair of two objects of type <T> with first() and second() elements.
Definition: contiguous.H:49
const fileName & name() const
Return the dictionary name.
Definition: dictionary.H:109
void throwExceptions()
Definition: error.H:122
A 1D vector of objects of type <T> that resizes itself as necessary to accept the new objects...
Definition: DynamicList.H:56
A class for handling words, derived from string.
Definition: word.H:59
Functions to search &#39;etc&#39; directories for configuration files etc.
Extract command arguments and options from the supplied argc and argv parameters. ...
Definition: argList.H:102
void clear()
Clear all entries from table.
Definition: HashTable.C:468
void append(const T &)
Append an element at the end of the list.
Definition: ListI.H:178
static const dictionary null
Null dictionary.
Definition: dictionary.H:242
DynamicList< T, SizeInc, SizeMult, SizeDiv > & append(const T &)
Append an element at the end of the list.
Definition: DynamicListI.H:296
static const word null
An empty word.
Definition: word.H:77
const fileOperation & fileHandler()
Get current file handler.
fileNameList readDir(const fileName &, const fileType=fileType::file, const bool filterVariants=true, const bool followLink=true)
Read a directory and return the entries as a string list.
Definition: POSIX.C:662
bool valid() const
Return true if the autoPtr valid (ie, the pointer is set)
Definition: autoPtrI.H:83
forAllConstIter(PtrDictionary< phaseModel >, mixture.phases(), phase)
Definition: pEqn.H:29
A wordRe is a word, but can also have a regular expression for matching words.
Definition: wordRe.H:74
Report an I/O error.
Definition: error.H:196
void setSize(const label)
Reset size of PtrList. If extending the PtrList, new entries are.
Definition: PtrList.C:131
virtual bool isDict() const
Return true if this entry is a dictionary.
Definition: entry.H:156
virtual bool read(const dictionary &)
Read and set the functionObject if its data have changed.
static const char nl
Definition: Ostream.H:260
objects
void set(T *)
Set pointer to that given.
Definition: autoPtrI.H:99
Ostream & decrIndent(Ostream &os)
Decrement the indent level.
Definition: Ostream.H:235
labelList f(nPoints)
bool open(const fileName &libName, const bool verbose=true)
Open the named library, optionally with warnings if problems occur.
dimensioned< Type > min(const dimensioned< Type > &, const dimensioned< Type > &)
word name(const complex &)
Return a string representation of a complex.
Definition: complex.C:47
const Type & second() const
Return second.
Definition: Pair.H:110
void clear()
Clear the list of function objects.
List< word > wordList
A List of words.
Definition: fileName.H:54
void setSize(const label)
Reset size of List.
Definition: List.C:281
bool status() const
Return the execution status (on/off) of the function objects.
Generic input stream.
Definition: ISstream.H:52
T lookupOrDefault(const word &, const T &, bool recursive=false, bool patternMatch=true) const
Find and return a T,.
#define WarningInFunction
Report a warning using Foam::Warning.
#define FatalIOErrorInFunction(ios)
Report an error message using Foam::FatalIOError.
Definition: error.H:335
Input from memory buffer stream.
Definition: IStringStream.H:49
List< Key > sortedToc() const
Return the table of contents as a sorted list.
Definition: HashTable.C:217
void transfer(PtrList< T > &)
Transfer the contents of the argument PtrList into this PtrList.
Definition: PtrList.C:189
static autoPtr< functionObject > New(const word &name, const Time &, const dictionary &)
Select from dictionary, based on its "type" entry.
string str() const
Return the string.
const dictionary & controlDict() const
Return the control dict.
Definition: Time.H:267
void set(entry *)
Assign a new entry, overwrite any existing entry.
Definition: dictionary.C:1271
void clear()
Clear the PtrList, i.e. set size to zero deleting all the.
Definition: PtrList.C:174
messageStream Info
bool merge(const dictionary &)
Merge entries from the given dictionary.
Definition: dictionary.C:1418
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.
An auto-pointer similar to the STL auto_ptr but with automatic casting to a reference to the type and...
Definition: PtrList.H:52
Mesh consisting of general polyhedral cells.
Definition: polyMesh.H:74
label findObjectID(const word &name) const
Find the ID of a given function object by name.
void updateMesh(const mapPolyMesh &mpm)
Update for changes of mesh.
static bool readFunctionObject(const string &funcArgs, dictionary &functionsDict, const Pair< string > &contextTypeAndValue, HashSet< word > &requiredFields, const word &region=word::null)
Read the specified functionObject configuration dictionary.
static autoPtr< functionObjectList > New(const argList &args, const Time &runTime, dictionary &controlDict, HashSet< word > &requiredFields)
Construct and return a functionObjectList for an application.
const string & commandLine() const
Return the command line string.
Definition: argListI.H:30
friend class iterator
Declare friendship with the iterator.
Definition: HashTable.H:194
Foam::argList args(argc, argv)
void movePoints(const polyMesh &mesh)
Update for changes of mesh.
List< fileName > fileNameList
A List of fileNames.
Definition: fileNameList.H:50
Ostream & incrIndent(Ostream &os)
Increment the indent level.
Definition: Ostream.H:228
IOobject defines the attributes of an object for which implicit objectRegistry management is supporte...
Definition: IOobject.H:92
const Type & first() const
Return first.
Definition: Pair.H:98
static fileName functionObjectDictPath
Default relative path to the directory structure.
bool end()
Called when Time::run() determines that the time-loop exits.
Output to memory buffer stream.
Definition: OStringStream.H:49
void dictArgList(const string &funcArgs, word &funcName, wordReList &args, List< Tuple2< word, string >> &namedArgs)
Parse dictionary substitution argument list.
Definition: dictionary.C:1617
bool match(const std::string &, bool literalMatch=false) const
Smart match as regular expression or as a string.
Definition: wordReI.H:202
Input token stream.
Definition: ITstream.H:49
A keyword and a list of tokens is an &#39;entry&#39;.
Definition: entry.H:65
static fileName findDict(const word &funcName, const word &region=word::null)
Search for functionObject dictionary file for given region.
void dontThrowExceptions()
Definition: error.H:127
fileName path(UMean.rootPath()/UMean.caseName()/functionObjects::writeFile::outputPrefix/"graphs"/UMean.instance())
IStringStream optionLookup(const word &opt) const
Return an IStringStream from the named option.
Definition: argListI.H:120
IOerror FatalIOError
#define InfoInFunction
Report an information message using Foam::Info.
fileNameList findEtcDirs(const fileName &local=fileName::null)
Search for directories from user/group/shipped directories.
Definition: etcFiles.C:32
T & first()
Return reference to the first element of the list.
Definition: UPtrListI.H:43