functionObjectList.C
Go to the documentation of this file.
1 /*---------------------------------------------------------------------------*\
2  ========= |
3  \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
4  \\ / O peration |
5  \\ / A nd | www.openfoam.com
6  \\/ M anipulation |
7 -------------------------------------------------------------------------------
8  Copyright (C) 2011-2017 OpenFOAM Foundation
9  Copyright (C) 2015-2019 OpenCFD Ltd.
10 -------------------------------------------------------------------------------
11 License
12  This file is part of OpenFOAM.
13 
14  OpenFOAM is free software: you can redistribute it and/or modify it
15  under the terms of the GNU General Public License as published by
16  the Free Software Foundation, either version 3 of the License, or
17  (at your option) any later version.
18 
19  OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
20  ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
21  FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
22  for more details.
23 
24  You should have received a copy of the GNU General Public License
25  along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
26 
27 \*---------------------------------------------------------------------------*/
28 
29 #include "functionObjectList.H"
30 #include "Time.H"
31 #include "mapPolyMesh.H"
32 #include "profiling.H"
33 #include "argList.H"
35 #include "dictionaryEntry.H"
36 #include "stringOps.H"
37 #include "Tuple2.H"
38 #include "etcFiles.H"
39 #include "IOdictionary.H"
40 
41 /* * * * * * * * * * * * * * * Static Member Data * * * * * * * * * * * * * */
42 
44 (
45  "caseDicts/postProcessing"
46 );
47 
48 
49 // * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * * //
50 
51 void Foam::functionObjectList::createStateDict() const
52 {
53  // Cannot set the state dictionary on construction since Time has not
54  // been fully initialised
55  stateDictPtr_.reset
56  (
57  new IOdictionary
58  (
59  IOobject
60  (
61  "functionObjectProperties",
62  time_.timeName(),
63  "uniform"/word("functionObjects"),
64  time_,
67  )
68  )
69  );
70 }
71 
72 
73 void Foam::functionObjectList::createOutputRegistry() const
74 {
75  objectsRegistryPtr_.reset
76  (
77  new objectRegistry
78  (
79  IOobject
80  (
81  "functionObjectObjects",
82  time_.timeName(),
83  time_,
86  )
87  )
88  );
89 }
90 
91 
92 Foam::autoPtr<Foam::functionObject> Foam::functionObjectList::remove
93 (
94  const word& key,
95  label& oldIndex
96 )
97 {
98  autoPtr<functionObject> oldptr;
99 
100  auto iter = indices_.find(key); // Index of existing functionObject
101 
102  if (iter.found())
103  {
104  oldIndex = *iter;
105 
106  // Remove pointer from the old list
107  oldptr = this->release(oldIndex);
108  indices_.erase(iter);
109  }
110  else
111  {
112  oldIndex = -1;
113  }
114 
115  return oldptr;
116 }
117 
118 
119 void Foam::functionObjectList::listDir
120 (
121  const fileName& dir,
122  wordHashSet& available
123 )
124 {
125  // Search specified directory for functionObject configuration files
126  for (const fileName& f : fileHandler().readDir(dir))
127  {
128  if (f.ext().empty())
129  {
130  available.insert(f);
131  }
132  }
133 
134  // Recurse into sub-directories
135  for (const fileName& d : fileHandler().readDir(dir, fileName::DIRECTORY))
136  {
137  listDir(dir/d, available);
138  }
139 }
140 
141 
143 {
144  wordHashSet available;
145 
146  for (const fileName& d : findEtcDirs(functionObjectDictPath))
147  {
148  listDir(d, available);
149  }
150 
151  Info<< nl
152  << "Available configured functionObjects:"
153  << available.sortedToc()
154  << nl;
155 }
156 
157 
159 {
160  // First check for functionObject dictionary file in globalCase system/
161 
162  fileName dictFile = stringOps::expand("<system>")/funcName;
163 
164  if (isFile(dictFile))
165  {
166  return dictFile;
167  }
168 
169  for (const fileName& d : findEtcDirs(functionObjectDictPath))
170  {
171  dictFile = search(funcName, d);
172  if (!dictFile.empty())
173  {
174  return dictFile;
175  }
176  }
177 
178  return fileName::null;
179 }
180 
181 
183 (
184  const string& funcNameArgs,
185  dictionary& functionsDict,
186  HashSet<wordRe>& requiredFields,
187  const word& region
188 )
189 {
190  // Parse the optional functionObject arguments:
191  // 'Q(U)' -> funcName = Q; args = (U); field = U
192  //
193  // Supports named arguments:
194  // 'patchAverage(patch=inlet, p)' -> funcName = patchAverage;
195  // args = (patch=inlet, p); field = p
196 
197  word funcName(funcNameArgs);
198 
199  int argLevel = 0;
201 
202  List<Tuple2<word, string>> namedArgs;
203  bool hasNamedArg = false;
204  word argName;
205 
207  word::size_type i = 0;
208 
209  for
210  (
211  word::const_iterator iter = funcNameArgs.begin();
212  iter != funcNameArgs.end();
213  ++iter
214  )
215  {
216  char c = *iter;
217 
218  if (c == '(')
219  {
220  if (argLevel == 0)
221  {
222  funcName = funcNameArgs.substr(start, i - start);
223  start = i+1;
224  }
225  ++argLevel;
226  }
227  else if (c == ',' || c == ')')
228  {
229  if (argLevel == 1)
230  {
231  if (hasNamedArg)
232  {
233  namedArgs.append
234  (
236  (
237  argName,
238  funcNameArgs.substr(start, i - start)
239  )
240  );
241  hasNamedArg = false;
242  }
243  else
244  {
245  args.append
246  (
247  wordRe
248  (
250  (
251  funcNameArgs.substr(start, i - start)
252  )
253  )
254  );
255  }
256  start = i+1;
257  }
258 
259  if (c == ')')
260  {
261  if (argLevel == 1)
262  {
263  break;
264  }
265  --argLevel;
266  }
267  }
268  else if (c == '=')
269  {
270  argName = word::validate
271  (
272  funcNameArgs.substr(start, i - start)
273  );
274 
275  start = i+1;
276  hasNamedArg = true;
277  }
278 
279  ++i;
280  }
281 
282  // Search for the functionObject dictionary
284 
285  if (path == fileName::null)
286  {
288  << "Cannot find functionObject file " << funcName << endl;
289  return false;
290  }
291 
292  // Read the functionObject dictionary
293  autoPtr<ISstream> fileStreamPtr(fileHandler().NewIFstream(path));
294  ISstream& fileStream = fileStreamPtr();
295 
296  dictionary funcsDict(fileStream);
297  dictionary* funcDictPtr = funcsDict.findDict(funcName);
298  dictionary& funcDict = (funcDictPtr ? *funcDictPtr : funcsDict);
299 
300 
301  // Insert the 'field' and/or 'fields' entry corresponding to the optional
302  // arguments or read the 'field' or 'fields' entry and add the required
303  // fields to requiredFields
304  if (args.size() == 1)
305  {
306  funcDict.set("field", args[0]);
307  funcDict.set("fields", args);
308  requiredFields.insert(args[0]);
309  }
310  else if (args.size() > 1)
311  {
312  funcDict.set("fields", args);
313  requiredFields.insert(args);
314  }
315  else if (funcDict.found("field"))
316  {
317  requiredFields.insert(funcDict.get<wordRe>("field"));
318  }
319  else if (funcDict.found("fields"))
320  {
321  requiredFields.insert(funcDict.get<wordRes>("fields"));
322  }
323 
324  // Insert named arguments
325  for (const Tuple2<word, string>& namedArg : namedArgs)
326  {
327  IStringStream entryStream
328  (
329  namedArg.first() + ' ' + namedArg.second() + ';'
330  );
331 
332  funcDict.set(entry::New(entryStream).ptr());
333  }
334 
335  // Insert the region name if specified
336  if (region != word::null)
337  {
338  funcDict.set("region", region);
339  }
340 
341  // Merge this functionObject dictionary into functionsDict
342  dictionary funcArgsDict;
343  funcArgsDict.add(word::validate(funcNameArgs), funcDict);
344  functionsDict.merge(funcArgsDict);
345 
346  return true;
347 }
348 
349 
350 // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
351 
352 Foam::functionObjectList::functionObjectList
353 (
354  const Time& runTime,
355  const bool execution
356 )
357 :
359  digests_(),
360  indices_(),
361  time_(runTime),
362  parentDict_(runTime.controlDict()),
363  stateDictPtr_(),
364  objectsRegistryPtr_(),
365  execution_(execution),
366  updated_(false)
367 {}
368 
369 
370 Foam::functionObjectList::functionObjectList
371 (
372  const Time& runTime,
373  const dictionary& parentDict,
374  const bool execution
375 )
376 :
378  digests_(),
379  indices_(),
380  time_(runTime),
381  parentDict_(parentDict),
382  stateDictPtr_(),
383  objectsRegistryPtr_(),
384  execution_(execution),
385  updated_(false)
386 {}
387 
388 
390 (
391  const argList& args,
392  const Time& runTime,
394  HashSet<wordRe>& requiredFields
395 )
396 {
397  // Merge any functions from the provided controlDict
398  controlDict.add
399  (
401  true
402  );
403 
404  dictionary& functionsDict = controlDict.subDict("functions");
405 
406  const word regionName = args.get<word>("region", "");
407 
408  bool modifiedControlDict = false;
409 
410  if (args.found("dict"))
411  {
412  modifiedControlDict = true;
413 
414  controlDict.merge
415  (
417  (
418  IOobject
419  (
420  args["dict"],
421  runTime,
423  )
424  )
425  );
426  }
427 
428  if (args.found("func"))
429  {
430  modifiedControlDict = true;
431 
432  readFunctionObject
433  (
434  args["func"],
435  functionsDict,
436  requiredFields,
437  regionName
438  );
439  }
440 
441  if (args.found("funcs"))
442  {
443  modifiedControlDict = true;
444 
445  wordList funcNames = args.getList<word>("funcs");
446 
447  for (const word& funcName : funcNames)
448  {
449  readFunctionObject
450  (
451  funcName,
452  functionsDict,
453  requiredFields,
454  regionName
455  );
456  }
457  }
458 
459 
460  autoPtr<functionObjectList> functionsPtr;
461 
462  if (modifiedControlDict)
463  {
464  functionsPtr.reset(new functionObjectList(runTime, controlDict));
465  }
466  else
467  {
468  functionsPtr.reset(new functionObjectList(runTime));
469  }
470 
471  functionsPtr->start();
472 
473  return functionsPtr;
474 }
475 
476 
477 // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
478 
480 {
481  label triggeri = labelMin;
482  stateDict().readIfPresent("triggerIndex", triggeri);
483 
484  return triggeri;
485 }
486 
487 
489 {
490  // Reset (re-read) the state dictionary
491  stateDictPtr_.clear();
492  createStateDict();
493 }
494 
495 
497 {
498  if (!stateDictPtr_.valid())
499  {
500  createStateDict();
501  }
502 
503  return *stateDictPtr_;
504 }
505 
506 
508 {
509  if (!stateDictPtr_.valid())
510  {
511  createStateDict();
512  }
513 
514  return *stateDictPtr_;
515 }
516 
517 
519 {
520  if (!objectsRegistryPtr_.valid())
521  {
522  createOutputRegistry();
523  }
524 
525  return *objectsRegistryPtr_;
526 }
527 
528 
530 {
531  if (!objectsRegistryPtr_.valid())
532  {
533  createOutputRegistry();
534  }
535 
536  return *objectsRegistryPtr_;
537 }
538 
539 
541 {
543  digests_.clear();
544  indices_.clear();
545  updated_ = false;
546 }
547 
548 
550 {
551  label id = 0;
552 
553  for (const functionObject& funcObj : functions())
554  {
555  if (funcObj.name() == name)
556  {
557  return id;
558  }
559 
560  ++id;
561  }
562 
563  return -1;
564 }
565 
566 
568 {
569  execution_ = true;
570 }
571 
572 
574 {
575  // For safety, also force a read() when execution is resumed
576  updated_ = execution_ = false;
577 }
578 
579 
581 {
582  return execution_;
583 }
584 
585 
587 {
588  return read();
589 }
590 
591 
593 {
594  bool ok = true;
595 
596  if (execution_)
597  {
598  if (!updated_)
599  {
600  read();
601  }
602 
603  for (functionObject& funcObj : functions())
604  {
605  const word& objName = funcObj.name();
606  {
607  addProfiling(fo, "functionObject::" + objName + "::execute");
608 
609  ok = funcObj.execute() && ok;
610  }
611 
612  {
613  addProfiling(fo, "functionObject::" + objName + "::write");
614 
615  ok = funcObj.write() && ok;
616  }
617  }
618  }
619 
620  // Force writing of state dictionary after function object execution
621  if (time_.writeTime())
622  {
623  label oldPrecision = IOstream::precision_;
625 
626  stateDictPtr_->writeObject
627  (
630  time_.writeCompression(),
631  true
632  );
633 
634  IOstream::precision_ = oldPrecision;
635  }
636 
637  return ok;
638 }
639 
640 
642 {
643  bool ok = execution_;
644 
645  if (ok)
646  {
647  for (functionObject& funcObj : functions())
648  {
649  ok = funcObj.execute(subIndex) && ok;
650  }
651  }
652 
653  return ok;
654 }
655 
656 
658 (
659  const UList<wordRe>& functionNames,
660  const label subIndex
661 )
662 {
663  bool ok = execution_;
664 
665  if (ok && functionNames.size())
666  {
667  for (functionObject& funcObj : functions())
668  {
669  if (stringOps::match(functionNames, funcObj.name()))
670  {
671  ok = funcObj.execute(subIndex) && ok;
672  }
673  }
674  }
675 
676  return ok;
677 }
678 
679 
681 {
682  bool ok = true;
683 
684  if (execution_)
685  {
686  if (!updated_)
687  {
688  read();
689  }
690 
691  for (functionObject& funcObj : functions())
692  {
693  const word& objName = funcObj.name();
694 
695  addProfiling(fo, "functionObject::" + objName + "::end");
696 
697  ok = funcObj.end() && ok;
698  }
699  }
700 
701  return ok;
702 }
703 
704 
706 {
707  bool ok = true;
708 
709  if (execution_)
710  {
711  if (!updated_)
712  {
713  read();
714  }
715 
716  for (functionObject& funcObj : functions())
717  {
718  const word& objName = funcObj.name();
719 
720  addProfiling(fo, "functionObject::" + objName + "::adjustTimeStep");
721 
722  ok = funcObj.adjustTimeStep() && ok;
723  }
724  }
725 
726  return ok;
727 }
728 
729 
731 {
732  if (!stateDictPtr_.valid())
733  {
734  createStateDict();
735  }
736 
737  updated_ = execution_;
738 
739  // Avoid reading/initializing if execution is off
740  if (!execution_)
741  {
742  return true;
743  }
744 
745  // Update existing and add new functionObjects
746  const entry* entryPtr =
747  parentDict_.findEntry("functions", keyType::LITERAL);
748 
749  bool ok = true;
750 
751  if (!entryPtr)
752  {
753  // No functions
755  digests_.clear();
756  indices_.clear();
757  }
758  else if (!entryPtr->isDict())
759  {
760  // Bad entry type
761  ok = false;
762  FatalIOErrorInFunction(parentDict_)
763  << "'functions' entry is not a dictionary"
764  << exit(FatalIOError);
765  }
766  else
767  {
768  const dictionary& functionsDict = entryPtr->dict();
769 
770  PtrList<functionObject> newPtrs(functionsDict.size());
771  List<SHA1Digest> newDigs(functionsDict.size());
772  HashTable<label> newIndices;
773 
774  addProfiling(fo, "functionObjects::read");
775 
776  const_cast<Time&>(time_).libs().open
777  (
778  functionsDict,
779  "libs",
780  functionObject::dictionaryConstructorTablePtr_
781  );
782 
783  label nFunc = 0;
784 
785  for (const entry& dEntry : functionsDict)
786  {
787  const word& key = dEntry.keyword();
788 
789  if (!dEntry.isDict())
790  {
791  if (key != "libs")
792  {
793  IOWarningInFunction(parentDict_)
794  << "Entry " << key << " is not a dictionary" << endl;
795  }
796 
797  continue;
798  }
799 
800  const dictionary& dict = dEntry.dict();
801 
802  bool enabled = dict.lookupOrDefault("enabled", true);
803 
804  newDigs[nFunc] = dict.digest();
805 
806  label oldIndex = -1;
807  autoPtr<functionObject> objPtr = remove(key, oldIndex);
808 
809  if (objPtr)
810  {
811  // Re-read if dictionary content changed for
812  // existing functionObject
813  if (enabled && newDigs[nFunc] != digests_[oldIndex])
814  {
816  (
817  fo2,
818  "functionObject::" + objPtr->name() + "::read"
819  );
820 
822  {
823  if (isA<functionObjects::timeControl>(objPtr()))
824  {
825  // Already a time control - normal read
826  enabled = objPtr->read(dict);
827  }
828  else
829  {
830  // Was not a time control - need to re-create
831  objPtr.reset
832  (
834  (
835  key,
836  time_,
837  dict
838  )
839  );
840 
841  enabled = true;
842  }
843  }
844  else
845  {
846  // Plain function object - normal read
847  enabled = objPtr->read(dict);
848  }
849 
850  ok = enabled && ok;
851  }
852 
853  if (!enabled)
854  {
855  // Delete disabled or an invalid(read) functionObject
856  objPtr.clear();
857  continue;
858  }
859  }
860  else if (enabled)
861  {
863 
864  // Throw FatalError, FatalIOError as exceptions
865  const bool throwingError = FatalError.throwExceptions();
866  const bool throwingIOerr = FatalIOError.throwExceptions();
867 
868  try
869  {
870  // New functionObject
872  (
873  fo2,
874  "functionObject::" + key + "::new"
875  );
877  {
878  foPtr.reset
879  (
880  new functionObjects::timeControl(key, time_, dict)
881  );
882  }
883  else
884  {
885  foPtr = functionObject::New(key, time_, dict);
886  }
887  }
888  catch (const Foam::IOerror& ioErr)
889  {
890  Info<< ioErr << nl << endl;
891  std::exit(1);
892  }
893  catch (const Foam::error& err)
894  {
895  // Bit of trickery to get the original message
896  err.write(Warning, false);
898  << nl
899  << "--> while loading function object '" << key << "'"
900  << nl << endl;
901  }
902 
903  // Restore previous exception throwing state
904  FatalError.throwExceptions(throwingError);
905  FatalIOError.throwExceptions(throwingIOerr);
906 
907  // Required functionObject to be valid on all processors
908  if (returnReduce(foPtr.valid(), andOp<bool>()))
909  {
910  objPtr.reset(foPtr.release());
911  }
912  else
913  {
914  ok = false;
915  }
916  }
917 
918  // Insert active functionObject into the list
919  if (objPtr)
920  {
921  newPtrs.set(nFunc, objPtr);
922  newIndices.insert(key, nFunc);
923  ++nFunc;
924  }
925  }
926 
927  newPtrs.resize(nFunc);
928  newDigs.resize(nFunc);
929 
930  // Updating PtrList of functionObjects deletes any
931  // existing unused functionObjects
933  digests_.transfer(newDigs);
934  indices_.transfer(newIndices);
935  }
936 
937  return ok;
938 }
939 
940 
942 {
943  bool ok = false;
944  if (execution_)
945  {
946  for (const functionObject& funcObj : functions())
947  {
948  bool changed = funcObj.filesModified();
949  ok = ok || changed;
950  }
951  }
952  return ok;
953 }
954 
955 
957 {
958  if (execution_)
959  {
960  for (functionObject& funcObj : functions())
961  {
962  funcObj.updateMesh(mpm);
963  }
964  }
965 }
966 
967 
969 {
970  if (execution_)
971  {
972  for (functionObject& funcObj : functions())
973  {
974  funcObj.movePoints(mesh);
975  }
976  }
977 }
978 
979 
980 // ************************************************************************* //
Foam::entry
A keyword and a list of tokens is an 'entry'.
Definition: entry.H:67
Foam::dictionary::findDict
dictionary * findDict(const word &keyword, enum keyType::option matchOpt=keyType::REGEX)
Find and return a sub-dictionary pointer if present.
Definition: dictionary.C:503
Foam::IOobject::NO_WRITE
Definition: IOobject.H:130
profiling.H
Foam::IOdictionary
IOdictionary is derived from dictionary and IOobject to give the dictionary automatic IO functionalit...
Definition: IOdictionary.H:54
runTime
engineTime & runTime
Definition: createEngineTime.H:13
Foam::autoPtr::reset
void reset(T *p=nullptr) noexcept
Delete managed object and set to new given pointer.
Definition: autoPtrI.H:158
Foam::functionObjectList::movePoints
void movePoints(const polyMesh &mesh)
Update for changes of mesh.
Definition: functionObjectList.C:968
Foam::IOobject
Defines the attributes of an object for which implicit objectRegistry management is supported,...
Definition: IOobject.H:104
Foam::dictionaryEntry
A keyword and a list of tokens is a 'dictionaryEntry'.
Definition: dictionaryEntry.H:65
InfoInFunction
#define InfoInFunction
Report an information message using Foam::Info.
Definition: messageStream.H:316
Foam::functionObjectList::list
static void list()
Definition: functionObjectList.C:142
Foam::entry::New
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.
Definition: entryIO.C:104
Foam::functionObjectList::status
bool status() const
Return the execution status (on/off) of the function objects.
Definition: functionObjectList.C:580
Foam::Time
Class to control time during OpenFOAM simulations that is also the top-level objectRegistry.
Definition: Time.H:73
Foam::functionObjectList::adjustTimeStep
bool adjustTimeStep()
Called at the end of Time::adjustDeltaT() if adjustTime is true.
Definition: functionObjectList.C:705
Foam::functionObjectList::findDict
static fileName findDict(const word &funcName)
Definition: functionObjectList.C:158
Foam::word
A class for handling words, derived from Foam::string.
Definition: word.H:62
Foam::fileName
A class for handling file names.
Definition: fileName.H:69
Foam::returnReduce
T returnReduce(const T &Value, const BinaryOp &bop, const int tag=Pstream::msgType(), const label comm=UPstream::worldComm)
Definition: PstreamReduceOps.H:94
Foam::functionObject::New
static autoPtr< functionObject > New(const word &name, const Time &runTime, const dictionary &dict)
Select from dictionary, based on its "type" entry.
Definition: functionObject.C:67
Tuple2.H
Foam::functionObjectList::on
void on()
Switch the function objects on.
Definition: functionObjectList.C:567
Foam::dictionary::found
bool found(const word &keyword, enum keyType::option matchOpt=keyType::REGEX) const
Search for an entry (const access) with the given keyword.
Definition: dictionary.C:359
mapPolyMesh.H
Foam::Warning
messageStream Warning
Foam::read
bool read(const char *buf, int32_t &val)
Same as readInt32.
Definition: int32.H:108
Foam::findEtcDirs
fileNameList findEtcDirs(const fileName &name, unsigned short location=0777, const bool findFirst=false)
Search for directories from user/group/other etc locations.
Definition: etcFiles.C:381
Foam::functionObjectList::stateDict
IOdictionary & stateDict()
Definition: functionObjectList.C:496
functionObjectList.H
Foam::Time::timeName
static word timeName(const scalar t, const int precision=precision_)
Definition: Time.C:764
Foam::functionObjects::timeControl
Wrapper around functionObjects to add time control.
Definition: timeControlFunctionObject.H:76
Foam::IOstreamOption::currentVersion
static const versionNumber currentVersion
The current version number.
Definition: IOstreamOption.H:193
Foam::ISstream
Generic input stream using standard (STL) streams.
Definition: ISstream.H:54
Foam::functionObjectList::updateMesh
void updateMesh(const mapPolyMesh &mpm)
Update for changes of mesh.
Definition: functionObjectList.C:956
Foam::word::validate
static word validate(const std::string &s, const bool prefix=false)
Construct validated word (no invalid characters).
Definition: word.C:45
Foam::argList
Extract command arguments and options from the supplied argc and argv parameters.
Definition: argList.H:123
Foam::isFile
bool isFile(const fileName &name, const bool checkGzip=true, const bool followLink=true)
Does the name exist as a FILE in the file system?
Definition: MSwindows.C:658
Foam::fileHandler
const fileOperation & fileHandler()
Get current file handler.
Definition: fileOperation.C:1181
Foam::List::append
void append(const T &val)
Append an element at the end of the list.
Definition: ListI.H:182
Foam::autoPtr::valid
bool valid() const noexcept
True if the managed pointer is non-null.
Definition: autoPtrI.H:107
Foam::FatalIOError
IOerror FatalIOError
Foam::endl
Ostream & endl(Ostream &os)
Add newline and flush stream.
Definition: Ostream.H:337
Foam::IOstream::precision_
static unsigned int precision_
Default precision.
Definition: IOstream.H:94
Foam::dictionary::get
T get(const word &keyword, enum keyType::option matchOpt=keyType::REGEX) const
Definition: dictionaryTemplates.C:81
Foam::dictionary::set
entry * set(entry *entryPtr)
Assign a new entry, overwriting any existing entry.
Definition: dictionary.C:842
Foam::dictionary::lookupOrDefault
T lookupOrDefault(const word &keyword, const T &deflt, enum keyType::option matchOpt=keyType::REGEX) const
Definition: dictionary.H:1241
Foam::functionObjectList::execute
bool execute()
Called at each ++ or += of the time-loop.
Definition: functionObjectList.C:592
Foam::HashSet< word >
Foam::argList::get
T get(const label index) const
Get a value from the argument at index.
Definition: argListI.H:257
Foam::functionObjectList
List of function objects with start(), execute() and end() functions that is called for each object.
Definition: functionObjectList.H:66
Foam::wordRe
A wordRe is a Foam::word, but can contain a regular expression for matching words or strings.
Definition: wordRe.H:72
Foam::functionObjectList::findObjectID
label findObjectID(const word &name) const
Find the ID of a given function object by name, -1 if not found.
Definition: functionObjectList.C:549
Foam::functionObjectList::start
bool start()
Called at the start of the time-loop.
Definition: functionObjectList.C:586
Foam::polyMesh
Mesh consisting of general polyhedral cells.
Definition: polyMesh.H:77
Foam::functionObject
Abstract base-class for Time/database function objects.
Definition: functionObject.H:229
Foam::functionObjectList::clear
void clear()
Clear the list of function objects.
Definition: functionObjectList.C:540
Foam::dictionary::null
static const dictionary null
An empty dictionary, which is also the parent for all dictionaries.
Definition: dictionary.H:385
Foam::objectRegistry
Registry of regIOobjects.
Definition: objectRegistry.H:60
regionName
Foam::word regionName
Definition: createNamedDynamicFvMesh.H:1
Foam::dictionary::merge
bool merge(const dictionary &dict)
Merge entries from the given dictionary.
Definition: dictionary.C:874
Foam::label
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:62
Foam::entry::isDict
virtual bool isDict() const
Return true if this entry is a dictionary.
Definition: entry.H:222
Foam::functionObjectList::off
void off()
Switch the function objects off.
Definition: functionObjectList.C:573
Foam::functionObjectList::triggerIndex
label triggerIndex() const
Return the current trigger index (read from the stateDict)
Definition: functionObjectList.C:479
Foam::Info
messageStream Info
Information stream (uses stdout - output is on the master only)
Foam::name
word name(const complex &c)
Return string representation of complex.
Definition: complex.C:76
Foam::autoPtr::release
T * release() noexcept
Return pointer to the managed object and release ownership.
Definition: autoPtrI.H:135
argList.H
controlDict
runTime controlDict().readEntry("adjustTimeStep"
Definition: debug.C:143
Foam::IOobject::READ_IF_PRESENT
Definition: IOobject.H:122
Foam::functionObjectList::functionObjectDictPath
static fileName functionObjectDictPath
Definition: functionObjectList.H:135
Foam::andOp
Definition: ops.H:233
Foam::PtrList< functionObject >
size_type
graph_traits< Graph >::vertices_size_type size_type
Definition: SloanRenumber.C:75
Foam::functionObject::read
virtual bool read(const dictionary &dict)
Read and set the function object if its data have changed.
Definition: functionObject.C:137
dict
dictionary dict
Definition: searchingEngine.H:14
addProfiling
#define addProfiling(name, descr)
Define profiling trigger with specified name and description string.
Definition: profilingTrigger.H:114
Foam::FatalError
error FatalError
Foam::dictionary
A list of keyword definitions, which are a keyword followed by a number of values (eg,...
Definition: dictionary.H:121
Foam::Time::controlDict
const dictionary & controlDict() const
Return read access to the controlDict dictionary.
Definition: Time.H:309
mesh
dynamicFvMesh & mesh
Definition: createDynamicFvMesh.H:6
Foam::functionObjectList::New
static autoPtr< functionObjectList > New(const argList &args, const Time &runTime, dictionary &controlDict, HashSet< wordRe > &requiredFields)
Construct and return a functionObjectList for an application.
Definition: functionObjectList.C:390
Foam::PtrList::clear
void clear()
Clear the PtrList. Delete allocated entries and set size to zero.
Definition: PtrListI.H:100
Foam::IStringStream
Input from string buffer, using a ISstream.
Definition: StringStream.H:112
Foam::entry::dict
virtual const dictionary & dict() const =0
Return dictionary, if entry is a dictionary.
Foam::HashTable::sortedToc
List< Key > sortedToc() const
The table of contents (the keys) in sorted order.
Definition: HashTable.C:136
dictionaryEntry.H
Foam::fileName::null
static const fileName null
An empty fileName.
Definition: fileName.H:97
Foam::exit
errorManipArg< error, int > exit(error &err, const int errNo=1)
Definition: errorManip.H:130
Foam::PtrList::resize
void resize(const label newLen)
Adjust size of PtrList.
Definition: PtrList.C:103
Foam::HashTable< label >
etcFiles.H
Functions to search 'etc' directories for configuration files etc.
IOdictionary.H
Time.H
Foam::autoPtr< Foam::functionObject >
Foam::argList::size
label size() const noexcept
The number of arguments.
Definition: argListI.H:127
Foam::stringOps::match
bool match(const UList< wordRe > &patterns, const std::string &text)
Return true if text matches one of the regular expressions.
Definition: stringOps.H:75
Foam::functionObjectList::readFunctionObject
static bool readFunctionObject(const string &funcNameArgs0, dictionary &functionsDict, HashSet< wordRe > &requiredFields, const word &region=word::null)
Definition: functionObjectList.C:183
Foam::IOstreamOption::ASCII
"ascii"
Definition: IOstreamOption.H:66
Foam::nl
constexpr char nl
Definition: Ostream.H:372
Foam::functionObject::name
const word & name() const
Return the name of this functionObject.
Definition: functionObject.C:131
f
labelList f(nPoints)
Foam::List< wordRe >
Foam::stringOps::expand
string expand(const std::string &str, const HashTable< string, word, string::hash > &mapping, const char sigil='$')
Definition: stringOps.C:739
Foam::start
label ListType::const_reference const label start
Definition: ListOps.H:408
Foam::UList
A 1D vector of objects of type <T>, where the size of the vector is known and can be used for subscri...
Definition: HashTable.H:103
timeControlFunctionObject.H
Foam::wordRes
A List of wordRe with additional matching capabilities.
Definition: wordRes.H:51
Foam::HashSet::insert
bool insert(const Key &key)
Insert a new entry, not overwriting existing entries.
Definition: HashSet.H:182
Foam::fileName::DIRECTORY
A directory.
Definition: fileName.H:80
path
fileName path(UMean.rootPath()/UMean.caseName()/"graphs"/UMean.instance())
Foam::search
fileName search(const word &file, const fileName &directory)
Recursively search the given directory for the file.
Definition: fileName.C:576
Foam::word::null
static const word null
An empty word.
Definition: word.H:77
Foam::IOobject::MUST_READ_IF_MODIFIED
Definition: IOobject.H:121
Foam::argList::getList
List< T > getList(const label index) const
Get a List of values from the argument at index.
Foam::labelMin
constexpr label labelMin
Definition: label.H:64
Foam::autoPtr::clear
void clear() noexcept
Delete managed object and set pointer to nullptr.
Definition: autoPtrI.H:151
Foam::mapPolyMesh
Class containing mesh-to-mesh mapping information after a change in polyMesh topology.
Definition: mapPolyMesh.H:160
Foam::constant::universal::c
const dimensionedScalar c
Speed of light in a vacuum.
Foam::wordHashSet
HashSet< word > wordHashSet
A HashSet with word keys.
Definition: HashSet.H:412
Foam::UList::size
void size(const label n) noexcept
Override size to be inconsistent with allocated storage.
Definition: UListI.H:360
Foam::IOerror
Report an I/O error.
Definition: error.H:218
Foam::dictionary::add
entry * add(entry *entryPtr, bool mergeEntry=false)
Add a new entry.
Definition: dictionary.C:703
Foam::functionObjects::timeControl::entriesPresent
static bool entriesPresent(const dictionary &dict)
Helper function to identify if a timeControl object is present.
Definition: timeControlFunctionObject.C:473
FatalIOErrorInFunction
#define FatalIOErrorInFunction(ios)
Report an error message using Foam::FatalIOError.
Definition: error.H:375
Foam::error::write
void write(Ostream &os, const bool includeTitle=true) const
Print error message.
Definition: error.C:300
Foam::keyType::LITERAL
String literal.
Definition: keyType.H:73
Foam::dictionary::digest
SHA1Digest digest() const
Return the SHA1 digest of the dictionary contents.
Definition: dictionary.C:227
IOWarningInFunction
#define IOWarningInFunction(ios)
Report an IO warning using Foam::Warning.
Definition: messageStream.H:306
Foam::Tuple2
A 2-tuple for storing two objects of dissimilar types. The container is similar in purpose to std::pa...
Definition: Tuple2.H:57
Foam::functionObjectList::read
bool read()
Read and set the function objects if their data have changed.
Definition: functionObjectList.C:730
Foam::functionObjectList::resetState
void resetState()
Reset/read state dictionary for current time.
Definition: functionObjectList.C:488
Foam::IOobject::NO_READ
Definition: IOobject.H:123
args
Foam::argList args(argc, argv)
stringOps.H
Foam::readDir
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.
Definition: MSwindows.C:707
Foam::error::throwExceptions
bool throwExceptions(bool doThrow)
Activate/deactivate exception throwing.
Definition: error.H:140
WarningInFunction
#define WarningInFunction
Report a warning using Foam::Warning.
Definition: messageStream.H:294
Foam::error
Class to handle errors and exceptions in a simple, consistent stream-based manner.
Definition: error.H:64
Foam::functionObjectList::end
bool end()
Called when Time::run() determines that the time-loop exits.
Definition: functionObjectList.C:680
Foam::functionObjectList::storedObjects
objectRegistry & storedObjects()
Definition: functionObjectList.C:518
Foam::PtrList::transfer
void transfer(PtrList< T > &list)
Transfer into this list and annul the argument list.
Definition: PtrListI.H:190
Foam::argList::found
bool found(const word &optName) const
Return true if the named option is found.
Definition: argListI.H:157
Foam::functionObjectList::filesModified
bool filesModified() const
Did any file get changed during execution?
Definition: functionObjectList.C:941