setExprFields.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) 2019-2022 OpenCFD Ltd.
9 -------------------------------------------------------------------------------
10 License
11  This file is part of OpenFOAM.
12 
13  OpenFOAM is free software: you can redistribute it and/or modify it
14  under the terms of the GNU General Public License as published by
15  the Free Software Foundation, either version 3 of the License, or
16  (at your option) any later version.
17 
18  OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
19  ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
20  FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
21  for more details.
22 
23  You should have received a copy of the GNU General Public License
24  along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
25 
26 Application
27  setExprFields
28 
29 Group
30  grpPreProcessingUtilities
31 
32 Description
33  Set values on a selected set of cells/patch-faces via a dictionary.
34 
35 Note
36  Based on funkySetFields from
37  Bernhard Gschaider <bgschaid@hfd-research.com>
38 
39 \*---------------------------------------------------------------------------*/
40 
41 #include "argList.H"
42 #include "Time.H"
43 #include "fvMesh.H"
44 #include "pointMesh.H"
45 #include "volFields.H"
46 #include "surfaceFields.H"
47 #include "pointFields.H"
48 #include "exprOps.H"
49 #include "volumeExprDriver.H"
50 #include "timeSelector.H"
51 #include "readFields.H"
52 
53 
54 using namespace Foam;
55 
57 
58 word fieldGeoType(const FieldAssociation geoType)
59 {
60  switch (geoType)
61  {
62  case FieldAssociation::POINT_DATA : return "points"; break;
63  case FieldAssociation::FACE_DATA : return "faces"; break;
64  case FieldAssociation::VOLUME_DATA : return "cells"; break;
65  default: break;
66  }
67  return "unknown";
68 }
69 
70 
71 //- Simple control structure to with collected switches to simplify passing
72 struct setExprFieldsControl
73 {
74  bool dryRun;
75  bool debugParsing;
76  bool cacheVariables;
77  bool hasDimensions;
78  bool createNew;
79  bool keepPatches;
80  bool correctPatches;
81  bool correctBCs;
82  IOstreamOption streamOpt;
83 };
84 
85 
86 template<class Type>
88 (
89  bool correctBCs,
91 )
92 {
93  if (correctBCs)
94  {
95  Info<< "Correcting boundary conditions: " << field.name() << nl;
96  field.correctBoundaryConditions();
97  }
98 }
99 
100 
101 template<class Type>
103 (
104  bool correctBCs,
106 )
107 {
108  if (correctBCs)
109  {
110  Info<< "Correcting boundary conditions: " << field.name() << nl;
111  field.correctBoundaryConditions();
112  }
113 }
114 
115 
116 template<class Type>
118 (
119  bool correctBCs,
121 )
122 {}
123 
124 
125 template<class GeoField>
126 bool setField
127 (
128  const word& fieldName,
129  const GeoField& evaluated,
130  const boolField& fieldMask,
131  const dimensionSet& dims,
132  const wordList& valuePatches,
133 
134  const setExprFieldsControl& ctrl
135 )
136 {
137  Info<< "setField(" << fieldName << "): "
139 
140  const auto& mesh = evaluated.mesh();
141 
142  tmp<GeoField> toutput;
143 
144  if (ctrl.createNew)
145  {
146  // Create with zero
147  toutput = GeoField::New
148  (
149  fieldName,
150  mesh,
152  );
153  }
154  else
155  {
156  // Read
157  toutput = tmp<GeoField>::New
158  (
159  IOobject
160  (
161  fieldName,
162  mesh.thisDb().time().timeName(),
163  mesh.thisDb(),
166  false // No register
167  ),
168  mesh
169  );
170  }
171 
172  auto& output = toutput.ref();
173 
174  label numValuesChanged = 0;
175 
176  // Internal field
177  if (fieldMask.empty())
178  {
179  // No field-mask - set entire internal field
180  numValuesChanged = output.size();
181 
182  output.primitiveFieldRef() = evaluated;
183  }
184  else
185  {
186  auto& internal = output.primitiveFieldRef();
187 
188  forAll(internal, idx)
189  {
190  if (fieldMask[idx])
191  {
192  internal[idx] = evaluated[idx];
193  ++numValuesChanged;
194  }
195  }
196  }
197 
198  // Boundary fields
199  forAll(evaluated.boundaryField(), patchi)
200  {
201  auto& pf = output.boundaryFieldRef()[patchi];
202 
203  if (pf.patch().coupled())
204  {
205  pf == evaluated.boundaryField()[patchi];
206  }
207  }
208 
209  doCorrectBoundaryConditions(ctrl.correctBCs, output);
210 
211  const label numTotal = returnReduce(output.size(), sumOp<label>());
212  reduce(numValuesChanged, sumOp<label>());
213 
214  if (numValuesChanged == numTotal)
215  {
216  Info<< "Set all ";
217  }
218  else
219  {
220  Info<< "Set " << numValuesChanged << " of ";
221  }
222  Info<< numTotal << " values" << endl;
223 
224  if (ctrl.hasDimensions)
225  {
226  Info<< "Setting dimensions to " << dims << endl;
227  output.dimensions().reset(dims);
228  }
229 
230  if (ctrl.dryRun)
231  {
232  Info<< "(dry-run): Writing to " << output.name() << nl;
233  }
234  else
235  {
236  Info<< "Writing to " << output.name() << nl;
237  output.writeObject(ctrl.streamOpt, true);
238  }
239 
240  return true;
241 }
242 
243 
244 void evaluate
245 (
246  const fvMesh& mesh,
247  const word& fieldName,
248  const expressions::exprString& valueExpr_,
249  const expressions::exprString& maskExpr_,
250  const dictionary& dict,
251  const dimensionSet& dims,
252  const wordList& valuePatches,
253 
254  const setExprFieldsControl& ctrl
255 )
256 {
257  word oldFieldType;
258 
259  if (ctrl.createNew)
260  {
261  Info<< "Set new field: " << fieldName;
262  }
263  else
264  {
265  IOobject io
266  (
267  fieldName,
268  mesh.thisDb().time().timeName(),
269  mesh.thisDb(),
272  );
273  io.typeHeaderOk<IOobject>(false);
274 
276  {
278  << "Field '" << fieldName
279  << "' seems to be missing. Use 'create'" << nl
280  << exit(FatalError);
281  }
282 
283  oldFieldType = io.headerClassName();
284 
285  Info<< "Modify field: " << fieldName
286  << " (type: " << oldFieldType << ')';
287  }
288 
289 
290  Info<< " time=" << mesh.thisDb().time().timeName() << nl
291  << "Expression:" << nl
292  << ">>>>" << nl
293  << valueExpr_.c_str() << nl
294  << "<<<<" << nl;
295 
296  bool evalFieldMask =
297  (maskExpr_.size() && maskExpr_ != "true" && maskExpr_ != "1");
298 
299  if (evalFieldMask)
300  {
301  Info<< "field-mask:" << nl
302  << ">>>>" << nl
303  << maskExpr_.c_str() << nl
304  << "<<<<" << nl;
305  }
306 
307  if (ctrl.keepPatches)
308  {
309  Info<< "Keeping patches unaltered" << endl;
310  }
311  else if (!valuePatches.empty())
312  {
313  Info<< "Setting patches " << flatOutput(valuePatches)
314  << " to fixed value" << endl;
315  }
316 
317  Info<< endl;
318 
320 
321  driver.setCaching(ctrl.cacheVariables);
322 
323  driver.readDict(dict);
324 
325  if (ctrl.debugParsing)
326  {
327  Info<< "Parsing expression: " << valueExpr_ << "\nand field-mask "
328  << maskExpr_ << nl << endl;
329  driver.setDebugging(true, true);
330  }
331 
332 
333  driver.clearVariables();
334 
335 
336  // Handle "field-mask" evaluation
337 
338  boolField fieldMask;
340 
341  if (evalFieldMask)
342  {
343  if (ctrl.debugParsing)
344  {
345  Info<< "Parsing field-mask:" << maskExpr_ << endl;
346  }
347 
348  driver.parse(maskExpr_);
349  if (ctrl.debugParsing)
350  {
351  Info<< "Parsed field-mask" << endl;
352  }
353 
354  if (driver.isLogical())
355  {
356  auto& result = driver.result();
357  if (result.is_bool())
358  {
359  fieldMask = result.getResult<bool>();
360  maskFieldAssoc = driver.fieldAssociation();
361  }
362  }
363 
364  // Slightly pedantic...
365  driver.clearField();
366  driver.clearResult();
367 
368  evalFieldMask = (maskFieldAssoc != FieldAssociation::NO_DATA);
369 
370  if (!evalFieldMask)
371  {
373  << " mask: " << maskExpr_
374  << " does not evaluate to a logical expression: "
375  << driver.resultType() << nl
376  #ifdef FULLDEBUG
377  << "contents: " << fieldMask
378  #endif
379  << exit(FatalError);
380  }
381 
382  if (ctrl.debugParsing)
383  {
384  Info<< "Field-mask evaluates to "
385  << fieldMask << nl;
386  }
387  }
388 
389  if (ctrl.debugParsing)
390  {
391  Info<< "Parsing expression:" << valueExpr_ << endl;
392  }
393 
394  driver.parse(valueExpr_);
395 
396  if (ctrl.debugParsing)
397  {
398  Info<< "Parsed expression" << endl;
399  }
400 
401  if (evalFieldMask && maskFieldAssoc != driver.fieldAssociation())
402  {
404  << "Mismatch between field-mask geometric type ("
405  << fieldGeoType(maskFieldAssoc) << ") and" << nl
406  << "expression geometric type ("
407  << fieldGeoType(driver.fieldAssociation()) << ')' << nl
408  << nl
409  << "expression: " << valueExpr_ << nl
410  << "field-mask: " << maskExpr_ << nl
411  << nl
412  << exit(FatalError);
413  }
414 
415  if (!oldFieldType.empty() && driver.resultType() != oldFieldType)
416  {
418  << "Inconsistent types: " << fieldName << " is "
419  << oldFieldType
420  << " but the expression evaluates to "
421  << driver.resultType()
422  << exit(FatalError);
423  }
424 
425  Info<< "Dispatch ... " << driver.resultType() << nl;
426 
427 
428  bool applied = false;
429  switch (driver.fieldAssociation())
430  {
431  #undef doLocalCode
432  #define doLocalCode(GeoField) \
433  { \
434  const auto* ptr = driver.isResultType<GeoField>(); \
435  if (ptr) \
436  { \
437  applied = setField \
438  ( \
439  fieldName, \
440  *ptr, \
441  fieldMask, \
442  dims, \
443  valuePatches, \
444  ctrl \
445  ); \
446  break; \
447  } \
448  }
449 
451  {
457  break;
458  }
460  {
466  break;
467  }
469  {
475  break;
476  }
477 
478  default: break;
479  #undef doLocalCode
480  }
481 
482  if (!applied)
483  {
485  << "Expression evaluates to an unsupported type: "
486  << driver.resultType() << nl << nl
487  << "Expression " << valueExpr_ << nl << endl
488  << exit(FatalError);
489  }
490 }
491 
492 
493 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
494 
495 int main(int argc, char *argv[])
496 {
497  // Normally without functionObjects, with -withFunctionObjects to enable
499 
500  // No -constant, no special treatment for 0/
502 
504  (
505  "ascii",
506  "Write in ASCII format instead of the controlDict setting"
507  );
509  (
510  "dict",
511  "file",
512  "Alternative dictionary for setExprFieldsDict"
513  );
515  (
516  "Evaluate but do not write"
517  );
519  (
520  "Additional verbosity",
521  true // Advanced option
522  );
524  (
525  "load-fields",
526  "wordList",
527  "Specify field or fields to preload. Eg, 'T' or '(p T U)'",
528  true // Advanced option
529  );
531  (
532  "field",
533  "name",
534  "The field to create/overwrite"
535  " (command-line operation)",
536  true // Advanced option
537  );
539  (
540  "expression",
541  "expr",
542  "The expression to evaluate"
543  " (command-line operation)",
544  true // Advanced option
545  );
547  (
548  "field-mask",
549  "logic",
550  "The field mask (logical condition) when to apply the expression"
551  " (command-line operation)",
552  true // Advanced option
553  );
554  argList::addOptionCompat("field-mask", {"condition", 2106});
556  (
557  "dimensions",
558  "dims",
559  "The dimensions for created fields"
560  " (command-line operation)",
561  true // Advanced option
562  );
563 
565  (
566  "debug-parser",
567  "Additional debugging information",
568  true // Advanced option
569  );
571  (
572  "no-variable-cache",
573  "Disable caching of expression variables",
574  true // Advanced option
575  );
577  (
578  "create",
579  "Create a new field"
580  " (command-line operation)",
581  true // Advanced option
582  );
584  (
585  "keepPatches",
586  "Leave patches unaltered"
587  " (command-line operation)",
588  true // Advanced option
589  );
591  (
592  "value-patches",
593  "(patches)",
594  "A list of patches that receive a fixed value"
595  " (command-line operation)",
596  true // Advanced option
597  );
599  (
600  "dummy-phi",
601  "Provide a zero phi field"
602  " (command-line operation)",
603  true // Advanced option
604  );
605 
606  // Future?
607  #if 0
609  (
610  "noCorrectPatches",
611  ""
612  );
614  (
615  "correctResultBoundaryFields",
616  "",
617  true
618  );
619  #endif
620 
621  #include "addRegionOption.H"
622  #include "setRootCase.H"
623 
624  #include "createTime.H"
625 
626  const word dictName("setExprFieldsDict");
627 
629 
630  if (times.empty())
631  {
633  << "No times selected." << nl
634  << exit(FatalError);
635  }
636 
637  // Disable dimension checking during operations
638  dimensionSet::checking(false);
639 
640  #include "createNamedMesh.H"
641 
643 
644  autoPtr<IOdictionary> exprDictPtr;
645 
646  // Sort out conflicts
647 
648  const bool useCommandArgs = args.found("field");
649 
650  if (useCommandArgs)
651  {
652  bool fatalCombination = false;
653 
654  if (args.found("dict"))
655  {
656  fatalCombination = true;
658  << "Cannot specify both dictionary and command-line arguments"
659  << nl << endl;
660  }
661 
662  if (args.found("create") && args.found("keepPatches"))
663  {
664  fatalCombination = true;
666  << "Cannot specify both 'create' and 'keepPatches'" << nl
667  << endl;
668  }
669 
670  if (!args.found("expression"))
671  {
672  fatalCombination = true;
674  << "Missing mandatory 'expression' option'" << nl
675  << endl;
676  }
677  if (fatalCombination)
678  {
679  FatalError
680  << exit(FatalError);
681  }
682  }
683  else
684  {
685  // Carp about inapplicable options (non-fatal)
686 
687  wordHashSet badOptions
688  ({
689  "create", "keepPatches", "value-patches",
690  "field-mask", "expression", "dimensions"
691  });
692  badOptions.retain(args.options());
693 
694  if (!badOptions.empty())
695  {
696  // Non-fatal (warning)
698  << "Using a dictionary. Cannot specify these options:" << nl
699  << flatOutput(badOptions.sortedToc()) << nl
700  << endl;
701  }
702 
703  #include "setSystemMeshDictionaryIO.H"
704  exprDictPtr.reset(new IOdictionary(dictIO));
705  }
706 
707  forAll(times, timei)
708  {
709  runTime.setTime(times[timei], timei);
710 
711  Info<< "\nTime = " << runTime.timeName() << endl;
712 
713  mesh.readUpdate();
714 
715  // preload fields specified on command-line
716  if (timei == 0)
717  {
718  wordList preloadFields;
719  args.readListIfPresent("load-fields", preloadFields);
720  readFieldsHandler(mesh).execute(preloadFields);
721  }
722 
723  if (args.found("dummy-phi") && !dummyPhi)
724  {
725  Info<< "Adding a dummy phi" << endl;
726  dummyPhi.reset
727  (
729  (
730  IOobject
731  (
732  "phi",
733  mesh.thisDb().time().constant(),
734  mesh.thisDb(),
737  ),
738  mesh,
740  )
741  );
742  }
743 
745  {
747  }
748 
749  if (useCommandArgs)
750  {
751  const word fieldName(args.get<word>("field"));
752 
753  Info<< "Using command-line options for "
754  << fieldName << nl << endl;
755 
756  setExprFieldsControl ctrl;
757 
758  ctrl.dryRun = args.dryRun();
759  ctrl.debugParsing = args.found("debug-parser");
760  ctrl.cacheVariables = !args.found("no-variable-caching");
761 
762  ctrl.createNew = args.found("create");
763  ctrl.keepPatches = args.found("keepPatches");
764  ctrl.correctPatches = !args.found("noCorrectPatches");
765  ctrl.correctBCs = args.found("correctResultBoundaryFields");
766  ctrl.hasDimensions = args.found("dimensions");
767  ctrl.streamOpt.format(runTime.writeFormat());
768  if (args.found("ascii"))
769  {
770  ctrl.streamOpt.format(IOstreamOption::ASCII);
771  }
772 
773  expressions::exprString valueExpr_(args["expression"]);
774 
775  expressions::exprString maskExpr_;
776  args.readIfPresent("field-mask", maskExpr_);
777 
778  dimensionSet dims;
779  if (ctrl.hasDimensions)
780  {
781  ITstream is(args.lookup("dimensions"));
782  is >> dims;
783  }
784 
785  evaluate
786  (
787  mesh,
788  fieldName,
789  valueExpr_,
790  maskExpr_,
792  dims,
793  args.getList<word>("value-patches", false),
794 
795  ctrl
796  );
797  }
798  else if (exprDictPtr)
799  {
800  const dictionary& exprDict = *exprDictPtr;
801 
802  // preload fields specified in dictionary
803  {
804  wordList preloadFields;
805  exprDict.readIfPresent("readFields", preloadFields);
806  readFieldsHandler(mesh).execute(preloadFields);
807  }
808 
809  // Read set construct info from dictionary
810  PtrList<entry> actions(exprDict.lookup("expressions"));
811 
812  for (const entry& dEntry : actions)
813  {
814  if (!dEntry.isDict())
815  {
816  Info<< "Ignore non-dictionary entry: "
817  << dEntry.keyword() << nl;
818  continue;
819  }
820 
821  const dictionary& dict = dEntry.dict();
822 
823  setExprFieldsControl ctrl;
824 
825  ctrl.dryRun = args.dryRun();
826  ctrl.debugParsing = args.found("debug-parser");
827  ctrl.cacheVariables = !args.found("no-variable-caching");
828 
829  ctrl.createNew = dict.getOrDefault("create", false);
830  ctrl.keepPatches = dict.getOrDefault("keepPatches", false);
831 
832  ctrl.correctPatches = !args.found("noCorrectPatches");
833  ctrl.correctBCs = args.found("correctResultBoundaryFields");
834  ctrl.streamOpt.format(runTime.writeFormat());
835  if (args.found("ascii"))
836  {
837  ctrl.streamOpt.format(IOstreamOption::ASCII);
838  }
839 
840  if (ctrl.createNew && ctrl.keepPatches)
841  {
843  << "Cannot specify both 'create' and 'keepPatches'"
844  << nl << endl
845  << exit(FatalIOError);
846  }
847 
848  // Local override
850  (
851  "correctResultBoundaryFields",
852  ctrl.correctBCs
853  );
854 
855 
856  const word fieldName(dict.get<word>("field"));
857 
858  expressions::exprString valueExpr_("expression", dict);
859 
860  expressions::exprString maskExpr_;
861  {
862  const entry* eptr = dict.findCompat
863  (
864  "fieldMask", {{"condition", 2106}},
866  );
867 
868  if (eptr)
869  {
870  maskExpr_.readEntry(eptr->keyword(), dict);
871  maskExpr_.trim();
872  }
873  }
874 
875  // Optional: "dimensions"
876  dimensionSet dims;
877  ctrl.hasDimensions = dims.readIfPresent("dimensions", dict);
878 
879  if (args.verbose() && !timei)
880  {
881  // Report once
882  Info<< "Processing" << dict << nl;
883  }
884 
885  evaluate
886  (
887  mesh,
888  fieldName,
889  valueExpr_,
890  maskExpr_,
891  dict,
892  dims,
893  dict.getOrDefault<wordList>("valuePatches", wordList()),
894 
895  ctrl
896  );
897  }
898  }
899  else
900  {
902  << "No command-line or dictionary??" << nl << endl
903  << exit(FatalError);
904  }
905  }
906 
907  Info<< "\nEnd\n" << endl;
908 
909  return 0;
910 }
911 
912 
913 // ************************************************************************* //
Foam::surfaceFields.
ITstream & lookup(const word &keyword, enum keyType::option matchOpt=keyType::REGEX) const
Find and return an entry data stream. FatalIOError if not found, or not a stream. ...
Definition: dictionary.C:379
dictionary dict
static void noFunctionObjects(bool addWithOption=false)
Remove &#39;-noFunctionObjects&#39; option and ignore any occurrences.
Definition: argList.C:514
word fieldGeoType(const expressions::FieldAssociation geoType)
bool readEntry(const word &keyword, const dictionary &dict, IOobjectOption::readOption readOpt=IOobjectOption::MUST_READ)
Read/expand entry with dictionary variables, and strip any embedded C/C++ comments from the input...
Definition: exprString.C:67
rDeltaTY field()
virtual const fileName & name() const
The name of the stream.
Definition: IOstream.C:33
errorManipArg< error, int > exit(error &err, const int errNo=1)
Definition: errorManip.H:125
error FatalError
Error stream (stdout output on all processes), with additional &#39;FOAM FATAL ERROR&#39; header text and sta...
A list of keyword definitions, which are a keyword followed by a number of values (eg...
Definition: dictionary.H:120
#define FatalErrorInFunction
Report an error message using Foam::FatalError.
Definition: error.H:578
A simple field-loader, as per the readFields function object.
Definition: readFields.H:44
label retain(const HashTable< AnyType, Key, AnyHash > &other)
Retain table entries given by keys of the other hash-table.
T & ref() const
Return non-const reference to the contents of a non-null managed pointer.
Definition: tmpI.H:210
constexpr char nl
The newline &#39;\n&#39; character (0x0a)
Definition: Ostream.H:49
"ascii" (normal default)
bool empty() const noexcept
True if the UList is empty (ie, size() is zero)
Definition: UListI.H:420
const word dictName("faMeshDefinition")
engineTime & runTime
Ostream & endl(Ostream &os)
Add newline and flush stream.
Definition: Ostream.H:487
A traits class, which is primarily used for primitives.
Definition: pTraits.H:50
List< T > getList(const label index) const
Get a List of values from the argument at index.
Required Variables.
static void addBoolOption(const word &optName, const string &usage="", bool advanced=false)
Add a bool option to validOptions with usage information.
Definition: argList.C:365
static void addOptionCompat(const word &optName, std::pair< const char *, int > compat)
Specify an alias for the option name.
Definition: argList.C:409
Generic GeometricField class.
Definition: areaFieldsFwd.H:50
A simple container for options an IOstream can normally have.
Generic dimensioned Type class.
Ignore writing from objectRegistry::writeObject()
T get(const word &keyword, enum keyType::option matchOpt=keyType::REGEX) const
Find and return a T. FatalIOError if not found, or if the number of tokens is incorrect.
tmp< DimensionedField< TypeR, GeoMesh > > New(const tmp< DimensionedField< TypeR, GeoMesh >> &tdf1, const word &name, const dimensionSet &dimensions, const bool initCopy=false)
Global function forwards to reuseTmpDimensionedField::New.
static void doCorrectBoundaryConditions(bool correctBCs, VolumeField< Type > &field)
T returnReduce(const T &value, const BinaryOp &bop, const int tag=UPstream::msgType(), const label comm=UPstream::worldComm)
Perform reduction on a copy, using specified binary operation.
bool start()
Called at the start of the time-loop.
bool allowFunctionObjects() const
The controlDict &#39;functions&#39; entry is allowed to be used.
Definition: argList.C:1817
void trim()
Inplace trim leading and trailing whitespace.
Definition: exprString.C:60
virtual const objectRegistry & thisDb() const
Return the object registry - resolve conflict polyMesh/lduMesh.
Definition: fvMesh.H:377
IOdictionary is derived from dictionary and IOobject to give the dictionary automatic IO functionalit...
Definition: IOdictionary.H:50
bool hasHeaderClass() const noexcept
True if headerClassName() is non-empty (after reading)
Definition: IOobjectI.H:206
#define forAll(list, i)
Loop across all elements in list.
Definition: stdFoam.H:413
void reset(T *p=nullptr) noexcept
Delete managed object and set to new given pointer.
Definition: autoPtrI.H:37
Dimension set for the base types, which can be used to implement rigorous dimension checking for alge...
Definition: dimensionSet.H:105
#define doLocalCode(GeoField)
IOobject io("surfaceFilmProperties", mesh.time().constant(), mesh, IOobject::READ_IF_PRESENT, IOobject::NO_WRITE, false)
const keyType & keyword() const noexcept
Return keyword.
Definition: entry.H:231
dynamicFvMesh & mesh
virtual readUpdateState readUpdate()
Update the mesh based on the mesh files saved in time.
Definition: fvMesh.C:668
surfacesMesh setField(triSurfaceToAgglom)
Operations involving expressions.
A class for handling words, derived from Foam::string.
Definition: word.H:63
static void addDryRunOption(const string &usage, bool advanced=false)
Enable a &#39;dry-run&#39; bool option, with usage information.
Definition: argList.C:495
const Time & time() const noexcept
Return time registry.
int dryRun() const noexcept
Return the dry-run flag.
Definition: argListI.H:109
string evaluate(label fieldWidth, const std::string &s, size_t pos=0, size_t len=std::string::npos)
String evaluation with specified (positive, non-zero) field width.
static void addVerboseOption(const string &usage, bool advanced=false)
Enable a &#39;verbose&#39; bool option, with usage information.
Definition: argList.C:505
static const dictionary null
An empty dictionary, which is also the parent for all dictionaries.
Definition: dictionary.H:465
static tmp< T > New(Args &&... args)
Construct tmp with forwarding arguments.
Definition: tmp.H:203
static void addOption(const word &optName, const string &param="", const string &usage="", bool advanced=false)
Add an option to validOptions with usage information.
Definition: argList.C:376
virtual void setTime(const Time &t)
Reset the time and time-index to those of the given time.
Definition: Time.C:977
String literal.
Definition: keyType.H:82
ITstream lookup(const word &optName) const
Return an input stream from the named option.
Definition: argListI.H:177
bool typeHeaderOk(const bool checkType=true, const bool search=true, const bool verbose=true)
Read header (uses typeFilePath to find file) and check its info.
static word timeName(const scalar t, const int precision=precision_)
Return time name of given scalar time formatted with the given precision.
Definition: Time.C:760
const word & constant() const noexcept
Return constant name.
Definition: TimePathsI.H:89
bool readIfPresent(const word &keyword, T &val, enum keyType::option matchOpt=keyType::REGEX) const
Find an entry if present, and assign to T val. FatalIOError if it is found and the number of tokens i...
bool readListIfPresent(const word &optName, List< T > &list) const
If named option is present, get a List of values treating a single entry like a list of size 1...
Definition: argListI.H:387
static instantList select0(Time &runTime, const argList &args)
Return the set of times selected based on the argList options and also set the runTime to the first i...
Definition: timeSelector.C:234
const entry * findCompat(const word &keyword, std::initializer_list< std::pair< const char *, int >> compat, enum keyType::option matchOpt) const
Find and return an entry pointer if present, or return a nullptr, using any compatibility names if ne...
IOstreamOption::streamFormat writeFormat() const noexcept
The write stream format.
Definition: Time.H:486
bool readIfPresent(const word &entryName, const dictionary &dict)
Update the dimensions from dictionary entry. FatalIOError if it is found and the number of tokens is ...
Definition: dimensionSet.H:359
const word & headerClassName() const noexcept
Return name of the class name read from header.
Definition: IOobjectI.H:168
T get(const label index) const
Get a value from the argument at index.
Definition: argListI.H:271
const functionObjectList & functionObjects() const
Return the list of function objects.
Definition: Time.H:662
static bool checking() noexcept
True if dimension checking is enabled (the usual default)
Definition: dimensionSet.H:241
#define FatalIOErrorInFunction(ios)
Report an error message using Foam::FatalIOError.
Definition: error.H:607
dimensioned< scalar > dimensionedScalar
Dimensioned scalar obtained from generic dimensioned type.
Mesh data needed to do the Finite Volume discretisation.
Definition: fvMesh.H:79
const HashTable< string > & options() const noexcept
Return options.
Definition: argListI.H:158
Nothing to be read.
void reduce(const List< UPstream::commsStruct > &comms, T &value, const BinaryOp &bop, const int tag, const label comm)
Reduce inplace (cf. MPI Allreduce) using specified communication schedule.
messageStream Info
Information stream (stdout output on master, null elsewhere)
static Ostream & output(Ostream &os, const IntRange< T > &range)
Definition: IntRanges.C:59
IOobject dictIO
Pointer management similar to std::unique_ptr, with some additional methods and type checking...
Definition: HashPtrTable.H:48
bool readIfPresent(const word &optName, T &val) const
Read a value from the named option if present.
Definition: argListI.H:316
T getOrDefault(const word &keyword, const T &deflt, enum keyType::option matchOpt=keyType::REGEX) const
Find and return a T, or return the given default value. FatalIOError if it is found and the number of...
A class for managing temporary objects.
Definition: HashPtrTable.H:50
Foam::argList args(argc, argv)
bool execute(const UList< word > &fieldNames)
Definition: readFields.H:181
Defines the attributes of an object for which implicit objectRegistry management is supported...
Definition: IOobject.H:166
Driver for volume, surface, point field expressions.
int verbose() const noexcept
Return the verbose flag.
Definition: argListI.H:121
bool found(const word &optName) const
Return true if the named option is found.
Definition: argListI.H:171
An input stream of tokens.
Definition: ITstream.H:48
static void addOptions(const bool constant=true, const bool withZero=false)
Add timeSelector options to argList::validOptions.
Definition: timeSelector.C:101
Namespace for OpenFOAM.
A keyword and a list of tokens is an &#39;entry&#39;.
Definition: entry.H:63
bool isHeaderClass() const
Check if headerClassName() equals Type::typeName.
Definition: IOobjectI.H:213
FlatOutput::OutputAdaptor< Container, Delimiters > flatOutput(const Container &obj, Delimiters delim)
Global flatOutput() function with specified output delimiters.
Definition: FlatOutput.H:225
IOerror FatalIOError
Error stream (stdout output on all processes), with additional &#39;FOAM FATAL IO ERROR&#39; header text and ...
static constexpr const zero Zero
Global zero (0)
Definition: zero.H:157