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-2022 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  return foMap.sortedToc();
114 }
115 
116 
118 (
119  const word& funcName,
120  const word& region
121 )
122 {
123  // First check if there is a functionObject dictionary file in the
124  // region system directory
125  {
126  const fileName dictFile
127  (
128  stringOps::expand("$FOAM_CASE")/"system"/region/funcName
129  );
130 
131  if (isFile(dictFile))
132  {
133  return dictFile;
134  }
135  }
136 
137  // Next, if the region is specified, check if there is a functionObject
138  // dictionary file in the global system directory
139  if (region != word::null)
140  {
141  const fileName dictFile
142  (
143  stringOps::expand("$FOAM_CASE")/"system"/funcName
144  );
145 
146  if (isFile(dictFile))
147  {
148  return dictFile;
149  }
150  }
151 
152  // Finally, check etc directories
153  {
155 
156  forAll(etcDirs, i)
157  {
158  const fileName dictFile(search(funcName, etcDirs[i]));
159 
160  if (!dictFile.empty())
161  {
162  return dictFile;
163  }
164  }
165  }
166 
167  return fileName::null;
168 }
169 
170 
172 Foam::functionObjectList::unsetEntries(const dictionary& funcDict)
173 {
174  const wordRe unsetPattern("<.*>");
175  unsetPattern.compile();
176 
177  List<Tuple2<word, string>> unsetArgs;
178 
179  forAllConstIter(IDLList<entry>, funcDict, iter)
180  {
181  if (iter().isStream())
182  {
183  ITstream& its = iter().stream();
184  OStringStream oss;
185  bool isUnset = false;
186 
187  forAll(its, i)
188  {
189  oss << its[i];
190  if (its[i].isWord() && unsetPattern.match(its[i].wordToken()))
191  {
192  isUnset = true;
193  }
194  }
195 
196  if (isUnset)
197  {
198  unsetArgs.append
199  (
201  (
202  iter().keyword(),
203  oss.str()
204  )
205  );
206  }
207  }
208  else
209  {
210  List<Tuple2<word, string>> subUnsetArgs =
211  unsetEntries(iter().dict());
212 
213  forAll(subUnsetArgs, i)
214  {
215  unsetArgs.append
216  (
218  (
219  iter().keyword() + '/' + subUnsetArgs[i].first(),
220  subUnsetArgs[i].second()
221  )
222  );
223  }
224  }
225  }
226 
227  return unsetArgs;
228 }
229 
230 
232 (
233  const string& funcArgs,
234  dictionary& functionsDict,
235  const Pair<string>& contextTypeAndValue,
236  const word& region
237 )
238 {
239  word funcType;
241  List<Tuple2<word, string>> namedArgs;
242 
243  dictArgList(funcArgs, funcType, args, namedArgs);
244 
245  // Search for the functionObject dictionary
246  fileName path = findDict(funcType, region);
247 
248  if (path == fileName::null)
249  {
250  FatalIOErrorInFunction(functionsDict)
251  << "Cannot find functionObject configuration file "
252  << funcType << nl << nl
253  << "Available configured functionObjects:"
254  << list()
255  << exit(FatalIOError);
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  // Merge this functionObject dictionary into functionsDict
438  functionsDict.merge(funcArgsDict);
439  functionsDict.subDict(funcName).name() = funcDict.name();
440 
441  return true;
442 }
443 
444 
445 // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
446 
448 (
449  const Time& t,
450  const bool execution
451 )
452 :
454  digests_(),
455  indices_(),
456  time_(t),
457  parentDict_(t.controlDict()),
458  execution_(execution),
459  updated_(false)
460 {}
461 
462 
464 (
465  const Time& t,
466  const dictionary& parentDict,
467  const bool execution
468 )
469 :
471  digests_(),
472  indices_(),
473  time_(t),
474  parentDict_(parentDict),
475  execution_(execution),
476  updated_(false)
477 {}
478 
479 
481 (
482  const argList& args,
483  const Time& runTime,
484  dictionary& controlDict
485 )
486 {
487  autoPtr<functionObjectList> functionsPtr;
488 
489  controlDict.add
490  (
491  dictionaryEntry("functions", controlDict, dictionary::null)
492  );
493 
494  dictionary& functionsDict = controlDict.subDict("functions");
495 
496  word region = word::null;
497 
498  // Set the region name if specified
499  if (args.optionFound("region"))
500  {
501  region = args["region"];
502  }
503 
504  if
505  (
506  args.optionFound("dict")
507  || args.optionFound("func")
508  || args.optionFound("funcs")
509  )
510  {
511  if (args.optionFound("dict"))
512  {
513  controlDict.merge
514  (
516  (
517  IOobject
518  (
519  args["dict"],
520  runTime,
522  )
523  )
524  );
525  }
526 
527  if (args.optionFound("func"))
528  {
530  (
531  args["func"],
532  functionsDict,
533  {"command", args.commandLine()},
534  region
535  );
536  }
537 
538  if (args.optionFound("funcs"))
539  {
540  wordList funcs(args.optionLookup("funcs")());
541 
542  forAll(funcs, i)
543  {
545  (
546  funcs[i],
547  functionsDict,
548  {"command", args.commandLine()},
549  region
550  );
551  }
552  }
553 
554  functionsPtr.reset(new functionObjectList(runTime, controlDict));
555  }
556  else
557  {
558  functionsPtr.reset(new functionObjectList(runTime));
559  }
560 
561  functionsPtr->read();
562 
563  return functionsPtr;
564 }
565 
566 
567 // * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * //
568 
570 {}
571 
572 
573 // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
574 
576 {
578  digests_.clear();
579  indices_.clear();
580  updated_ = false;
581 }
582 
583 
585 {
586  forAll(*this, oi)
587  {
588  if (operator[](oi).name() == name)
589  {
590  return oi;
591  }
592  }
593 
594  return -1;
595 }
596 
597 
599 {
600  execution_ = true;
601 }
602 
603 
605 {
606  // For safety, also force a read() when execution is turned back on
607  updated_ = execution_ = false;
608 }
609 
610 
612 {
613  return execution_;
614 }
615 
616 
618 {
619  bool ok = read();
620 
621  if (execution_)
622  {
623  forAll(*this, oi)
624  {
625  if (operator[](oi).executeAtStart())
626  {
627  ok = operator[](oi).execute() && ok;
628  ok = operator[](oi).write() && ok;
629  }
630  }
631  }
632 
633  return ok;
634 }
635 
636 
638 {
639  bool ok = true;
640 
641  if (execution_)
642  {
643  if (!updated_)
644  {
645  read();
646  }
647 
648  forAll(*this, oi)
649  {
650  ok = operator[](oi).execute() && ok;
651  ok = operator[](oi).write() && ok;
652  }
653  }
654 
655  return ok;
656 }
657 
658 
660 {
661  bool ok = true;
662 
663  if (execution_)
664  {
665  if (!updated_)
666  {
667  read();
668  }
669 
670  forAll(*this, oi)
671  {
672  ok = operator[](oi).end() && ok;
673  }
674  }
675 
676  return ok;
677 }
678 
679 
681 {
682  scalar result = vGreat;
683 
684  if (execution_)
685  {
686  if (!updated_)
687  {
688  read();
689  }
690 
691  forAll(*this, oi)
692  {
693  result = min(result, operator[](oi).timeToNextWrite());
694  }
695  }
696 
697  return result;
698 }
699 
700 
702 {
703  bool ok = true;
704  updated_ = execution_;
705 
706  // Avoid reading/initialising if execution is off
707  if (!execution_)
708  {
709  return true;
710  }
711 
712  // Update existing and add new functionObjects
713  const entry* entryPtr = parentDict_.lookupEntryPtr
714  (
715  "functions",
716  false,
717  false
718  );
719 
720  if (entryPtr)
721  {
722  PtrList<functionObject> newPtrs;
723  List<SHA1Digest> newDigs;
724  HashTable<label> newIndices;
725 
726  label nFunc = 0;
727 
728  if (!entryPtr->isDict())
729  {
730  FatalIOErrorInFunction(parentDict_)
731  << "'functions' entry is not a dictionary"
732  << exit(FatalIOError);
733  }
734 
735  const dictionary& functionsDict = entryPtr->dict();
736 
737  libs.open
738  (
739  functionsDict,
740  "libs",
741  functionObject::dictionaryConstructorTablePtr_
742  );
743 
744  newPtrs.setSize(functionsDict.size());
745  newDigs.setSize(functionsDict.size());
746 
747  forAllConstIter(dictionary, functionsDict, iter)
748  {
749  const word& key = iter().keyword();
750 
751  if (!iter().isDict())
752  {
753  if (key != "libs")
754  {
755  IOWarningInFunction(parentDict_)
756  << "Entry " << key << " is not a dictionary" << endl;
757  }
758 
759  continue;
760  }
761 
762  const dictionary& dict = iter().dict();
763  const bool enabled = dict.lookupOrDefault("enabled", true);
764 
765  newDigs[nFunc] = dict.digest();
766 
767  label oldIndex;
768  functionObject* objPtr = remove(key, oldIndex);
769 
770  if (objPtr)
771  {
772  if (enabled)
773  {
774  // Dictionary changed for an existing functionObject
775  if (newDigs[nFunc] != digests_[oldIndex])
776  {
777  ok = objPtr->read(dict) && ok;
778  }
779  }
780  else
781  {
782  // Delete the disabled functionObject
783  delete objPtr;
784  objPtr = nullptr;
785  continue;
786  }
787  }
788  else if (enabled)
789  {
791 
792  if
793  (
794  dict.found("writeControl")
795  || dict.found("outputControl")
796  )
797  {
798  foPtr.set
799  (
800  new functionObjects::timeControl(key, time_, dict)
801  );
802  }
803  else
804  {
805  foPtr = functionObject::New(key, time_, dict);
806  }
807 
808  if (foPtr.valid())
809  {
810  objPtr = foPtr.ptr();
811  }
812  else
813  {
814  ok = false;
815  }
816  }
817 
818  // Insert active functionObjects into the list
819  if (objPtr)
820  {
821  newPtrs.set(nFunc, objPtr);
822  newIndices.insert(key, nFunc);
823  nFunc++;
824  }
825  }
826 
827  newPtrs.setSize(nFunc);
828  newDigs.setSize(nFunc);
829 
830  // Updating the PtrList of functionObjects deletes any
831  // existing unused functionObjects
833  digests_.transfer(newDigs);
834  indices_.transfer(newIndices);
835  }
836  else
837  {
839  digests_.clear();
840  indices_.clear();
841  }
842 
843  return ok;
844 }
845 
846 
848 {
849  if (execution_)
850  {
851  forAll(*this, oi)
852  {
853  operator[](oi).movePoints(mesh);
854  }
855  }
856 }
857 
858 
860 {
861  if (execution_)
862  {
863  forAll(*this, oi)
864  {
865  operator[](oi).topoChange(map);
866  }
867  }
868 }
869 
870 
872 {
873  if (execution_)
874  {
875  forAll(*this, oi)
876  {
877  operator[](oi).mapMesh(map);
878  }
879  }
880 }
881 
882 
883 // ************************************************************************* //
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
virtual void topoChange(const polyTopoChangeMap &map)
Update topology using the given map.
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:663
#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
FvWallInfoData< WallInfo, label > label
A label is an int32_t or int64_t as specified by the pre-processor macro WM_LABEL_SIZE.
A class for handling file names.
Definition: fileName.H:79
const entry * lookupEntryPtr(const word &, bool recursive, bool patternMatch) const
Find and return an entry data stream pointer if present.
Definition: dictionary.C:702
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:1077
SHA1Digest digest() const
Return the SHA1 digest of the dictionary contents.
Definition: dictionary.C:629
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
void off()
Switch the function objects off.
scalar timeToNextWrite()
Return the time to the next write.
static bool readFunctionObject(const string &funcArgs, dictionary &functionsDict, const Pair< string > &contextTypeAndValue, const word &region=word::null)
Read the specified functionObject configuration dictionary.
A list of keyword definitions, which are a keyword followed by any number of values (e...
Definition: dictionary.H:156
#define forAllConstIter(Container, container, iter)
Iterate across all elements in the container object of type.
Definition: UList.H:477
static wordList list()
Return the list of functionObject configuration files in.
A 2-tuple for storing two objects of different types.
Definition: HashTable.H:65
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.
General time control for functionObjects.
void on()
Switch the function objects on.
virtual void mapMesh(const polyMeshMap &)
Update from another mesh using the given map.
T * ptr()
Return object pointer for reuse.
Definition: autoPtrI.H:90
Abstract base-class for Time/database functionObjects.
fvMesh & mesh
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:69
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
bool isDict(const word &) const
Check if entry is a sub-dictionary.
Definition: dictionary.C:956
bool add(entry *, bool mergeEntry=false)
Add a new entry.
Definition: dictionary.C:1153
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:1002
bool insert(const Key &, const T &newElmt)
Insert a new hashedEntry.
Definition: HashTableI.H:80
bool execute()
Called at each ++ or += of the time-loop.
Pair< word > dictAndKeyword(const word &scopedName)
Extracts dict name and keyword.
Definition: dictionary.C:1796
static int disableFunctionEntries
Definition: entry.H:86
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
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
Class containing mesh-to-mesh mapping information after a change in polyMesh topology.
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 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
virtual ~functionObjectList()
Destructor.
layerAndWeight min(const layerAndWeight &a, const layerAndWeight &b)
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
An STL-conforming hash table.
Definition: HashTable.H:61
bool valid() const
Return true if the autoPtr valid (ie, the pointer is set)
Definition: autoPtrI.H:83
A wordRe is a word, but can also have a regular expression for matching words.
Definition: wordRe.H:74
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
void set(T *)
Set pointer to that given.
Definition: autoPtrI.H:99
labelList f(nPoints)
bool open(const fileName &libName, const bool verbose=true)
Open the named library, optionally with warnings if problems occur.
word name(const complex &)
Return a string representation of a complex.
Definition: complex.C:47
labelList second(const UList< labelPair > &p)
Definition: patchToPatch.C:48
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.
static autoPtr< functionObjectList > New(const argList &args, const Time &runTime, dictionary &controlDict)
Construct and return a functionObjectList for an application.
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 FatalIOErrorInFunction(ios)
Report an error message using Foam::FatalIOError.
Definition: error.H:318
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:275
void set(entry *)
Assign a new entry, overwrite any existing entry.
Definition: dictionary.C:1291
void clear()
Clear the PtrList, i.e. set size to zero deleting all the.
Definition: PtrList.C:174
bool merge(const dictionary &)
Merge entries from the given dictionary.
Definition: dictionary.C:1438
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:76
label findObjectID(const word &name) const
Find the ID of a given function object by name.
const string & commandLine() const
Return the command line string.
Definition: argListI.H:30
Class containing mesh-to-mesh mapping information.
Definition: polyMeshMap.H:50
friend class iterator
Declare friendship with the iterator.
Definition: HashTable.H:194
Foam::argList args(argc, argv)
virtual void movePoints(const polyMesh &mesh)
Update topology using the given map.
List< fileName > fileNameList
A List of fileNames.
Definition: fileNameList.H:50
IOobject defines the attributes of an object for which implicit objectRegistry management is supporte...
Definition: IOobject.H:98
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:1637
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.
IStringStream optionLookup(const word &opt) const
Return an IStringStream from the named option.
Definition: argListI.H:120
IOerror FatalIOError
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