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(),
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 
274  if (!io.typeHeaderOk<regIOobject>(false))
275  {
277  << "Field '" << fieldName
278  << "' seems to be missing. Use 'create'" << nl
279  << exit(FatalError);
280  }
281 
282  oldFieldType = io.headerClassName();
283 
284  Info<< "Modify field: " << fieldName
285  << " (type: " << oldFieldType << ')';
286  }
287 
288 
289  Info<< " time=" << mesh.thisDb().time().timeName() << nl
290  << "Expression:" << nl
291  << ">>>>" << nl
292  << valueExpr_.c_str() << nl
293  << "<<<<" << nl;
294 
295  bool evalFieldMask =
296  (maskExpr_.size() && maskExpr_ != "true" && maskExpr_ != "1");
297 
298  if (evalFieldMask)
299  {
300  Info<< "field-mask:" << nl
301  << ">>>>" << nl
302  << maskExpr_.c_str() << nl
303  << "<<<<" << nl;
304  }
305 
306  if (ctrl.keepPatches)
307  {
308  Info<< "Keeping patches unaltered" << endl;
309  }
310  else if (!valuePatches.empty())
311  {
312  Info<< "Setting patches " << flatOutput(valuePatches)
313  << " to fixed value" << endl;
314  }
315 
316  Info<< endl;
317 
319 
320  driver.setCaching(ctrl.cacheVariables);
321 
322  driver.readDict(dict);
323 
324  if (ctrl.debugParsing)
325  {
326  Info<< "Parsing expression: " << valueExpr_ << "\nand field-mask "
327  << maskExpr_ << nl << endl;
328  driver.setDebugging(true, true);
329  }
330 
331 
332  driver.clearVariables();
333 
334 
335  // Handle "field-mask" evaluation
336 
337  boolField fieldMask;
339 
340  if (evalFieldMask)
341  {
342  if (ctrl.debugParsing)
343  {
344  Info<< "Parsing field-mask:" << maskExpr_ << endl;
345  }
346 
347  driver.parse(maskExpr_);
348  if (ctrl.debugParsing)
349  {
350  Info<< "Parsed field-mask" << endl;
351  }
352 
353  if (driver.isLogical())
354  {
355  auto& result = driver.result();
356  if (result.is_bool())
357  {
358  fieldMask = result.getResult<bool>();
359  maskFieldAssoc = driver.fieldAssociation();
360  }
361  }
362 
363  // Slightly pedantic...
364  driver.clearField();
365  driver.clearResult();
366 
367  evalFieldMask = (maskFieldAssoc != FieldAssociation::NO_DATA);
368 
369  if (!evalFieldMask)
370  {
372  << " mask: " << maskExpr_
373  << " does not evaluate to a logical expression: "
374  << driver.resultType() << nl
375  #ifdef FULLDEBUG
376  << "contents: " << fieldMask
377  #endif
378  << exit(FatalError);
379  }
380 
381  if (ctrl.debugParsing)
382  {
383  Info<< "Field-mask evaluates to "
384  << fieldMask << nl;
385  }
386  }
387 
388  if (ctrl.debugParsing)
389  {
390  Info<< "Parsing expression:" << valueExpr_ << endl;
391  }
392 
393  driver.parse(valueExpr_);
394 
395  if (ctrl.debugParsing)
396  {
397  Info<< "Parsed expression" << endl;
398  }
399 
400  if (evalFieldMask && maskFieldAssoc != driver.fieldAssociation())
401  {
403  << "Mismatch between field-mask geometric type ("
404  << fieldGeoType(maskFieldAssoc) << ") and" << nl
405  << "expression geometric type ("
406  << fieldGeoType(driver.fieldAssociation()) << ')' << nl
407  << nl
408  << "expression: " << valueExpr_ << nl
409  << "field-mask: " << maskExpr_ << nl
410  << nl
411  << exit(FatalError);
412  }
413 
414  if (!oldFieldType.empty() && driver.resultType() != oldFieldType)
415  {
417  << "Inconsistent types: " << fieldName << " is "
418  << oldFieldType
419  << " but the expression evaluates to "
420  << driver.resultType()
421  << exit(FatalError);
422  }
423 
424  Info<< "Dispatch ... " << driver.resultType() << nl;
425 
426 
427  bool applied = false;
428  switch (driver.fieldAssociation())
429  {
430  #undef doLocalCode
431  #define doLocalCode(GeoField) \
432  { \
433  const auto* ptr = driver.isResultType<GeoField>(); \
434  if (ptr) \
435  { \
436  applied = setField \
437  ( \
438  fieldName, \
439  *ptr, \
440  fieldMask, \
441  dims, \
442  valuePatches, \
443  ctrl \
444  ); \
445  break; \
446  } \
447  }
448 
450  {
456  break;
457  }
459  {
465  break;
466  }
468  {
474  break;
475  }
476 
477  default: break;
478  #undef doLocalCode
479  }
480 
481  if (!applied)
482  {
484  << "Expression evaluates to an unsupported type: "
485  << driver.resultType() << nl << nl
486  << "Expression " << valueExpr_ << nl << endl
487  << exit(FatalError);
488  }
489 }
490 
491 
492 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
493 
494 int main(int argc, char *argv[])
495 {
496  // Normally without functionObjects, with -withFunctionObjects to enable
498 
499  // No -constant, no special treatment for 0/
501 
503  (
504  "ascii",
505  "Write in ASCII format instead of the controlDict setting"
506  );
508  (
509  "dict",
510  "file",
511  "Alternative dictionary for setExprFieldsDict"
512  );
514  (
515  "Evaluate but do not write"
516  );
518  (
519  "Additional verbosity",
520  true // Advanced option
521  );
523  (
524  "load-fields",
525  "wordList",
526  "Specify field or fields to preload. Eg, 'T' or '(p T U)'",
527  true // Advanced option
528  );
530  (
531  "field",
532  "name",
533  "The field to create/overwrite"
534  " (command-line operation)",
535  true // Advanced option
536  );
538  (
539  "expression",
540  "expr",
541  "The expression to evaluate"
542  " (command-line operation)",
543  true // Advanced option
544  );
546  (
547  "field-mask",
548  "logic",
549  "The field mask (logical condition) when to apply the expression"
550  " (command-line operation)",
551  true // Advanced option
552  );
553  argList::addOptionCompat("field-mask", {"condition", 2106});
555  (
556  "dimensions",
557  "dims",
558  "The dimensions for created fields"
559  " (command-line operation)",
560  true // Advanced option
561  );
562 
564  (
565  "debug-parser",
566  "Additional debugging information",
567  true // Advanced option
568  );
570  (
571  "no-variable-cache",
572  "Disable caching of expression variables",
573  true // Advanced option
574  );
576  (
577  "create",
578  "Create a new field"
579  " (command-line operation)",
580  true // Advanced option
581  );
583  (
584  "keepPatches",
585  "Leave patches unaltered"
586  " (command-line operation)",
587  true // Advanced option
588  );
590  (
591  "value-patches",
592  "(patches)",
593  "A list of patches that receive a fixed value"
594  " (command-line operation)",
595  true // Advanced option
596  );
598  (
599  "dummy-phi",
600  "Provide a zero phi field"
601  " (command-line operation)",
602  true // Advanced option
603  );
604 
605  // Future?
606  #if 0
608  (
609  "noCorrectPatches",
610  ""
611  );
613  (
614  "correctResultBoundaryFields",
615  "",
616  true
617  );
618  #endif
619 
620  #include "addRegionOption.H"
621  #include "setRootCase.H"
622 
623  #include "createTime.H"
624 
625  const word dictName("setExprFieldsDict");
626 
628 
629  if (times.empty())
630  {
632  << "No times selected." << nl
633  << exit(FatalError);
634  }
635 
636  // Disable dimension checking during operations
637  dimensionSet::checking(false);
638 
639  #include "createNamedMesh.H"
640 
642 
643  autoPtr<IOdictionary> exprDictPtr;
644 
645  // Sort out conflicts
646 
647  const bool useCommandArgs = args.found("field");
648 
649  if (useCommandArgs)
650  {
651  bool fatalCombination = false;
652 
653  if (args.found("dict"))
654  {
655  fatalCombination = true;
657  << "Cannot specify both dictionary and command-line arguments"
658  << nl << endl;
659  }
660 
661  if (args.found("create") && args.found("keepPatches"))
662  {
663  fatalCombination = true;
665  << "Cannot specify both 'create' and 'keepPatches'" << nl
666  << endl;
667  }
668 
669  if (!args.found("expression"))
670  {
671  fatalCombination = true;
673  << "Missing mandatory 'expression' option'" << nl
674  << endl;
675  }
676  if (fatalCombination)
677  {
678  FatalError
679  << exit(FatalError);
680  }
681  }
682  else
683  {
684  // Carp about inapplicable options (non-fatal)
685 
686  wordHashSet badOptions
687  ({
688  "create", "keepPatches", "value-patches",
689  "field-mask", "expression", "dimensions"
690  });
691  badOptions.retain(args.options());
692 
693  if (!badOptions.empty())
694  {
695  // Non-fatal (warning)
697  << "Using a dictionary. Cannot specify these options:" << nl
698  << flatOutput(badOptions.sortedToc()) << nl
699  << endl;
700  }
701 
702  #include "setSystemMeshDictionaryIO.H"
703  exprDictPtr.reset(new IOdictionary(dictIO));
704  }
705 
706  forAll(times, timei)
707  {
708  runTime.setTime(times[timei], timei);
709 
710  Info<< "\nTime = " << runTime.timeName() << endl;
711 
712  mesh.readUpdate();
713 
714  // preload fields specified on command-line
715  if (timei == 0)
716  {
717  wordList preloadFields;
718  args.readListIfPresent("load-fields", preloadFields);
719  readFieldsHandler(mesh).execute(preloadFields);
720  }
721 
722  if (args.found("dummy-phi") && !dummyPhi)
723  {
724  Info<< "Adding a dummy phi" << endl;
725  dummyPhi.reset
726  (
728  (
729  IOobject
730  (
731  "phi",
732  mesh.thisDb().time().constant(),
733  mesh.thisDb(),
736  ),
737  mesh,
739  )
740  );
741  }
742 
744  {
746  }
747 
748  if (useCommandArgs)
749  {
750  const word fieldName(args.get<word>("field"));
751 
752  Info<< "Using command-line options for "
753  << fieldName << nl << endl;
754 
755  setExprFieldsControl ctrl;
756 
757  ctrl.dryRun = args.dryRun();
758  ctrl.debugParsing = args.found("debug-parser");
759  ctrl.cacheVariables = !args.found("no-variable-caching");
760 
761  ctrl.createNew = args.found("create");
762  ctrl.keepPatches = args.found("keepPatches");
763  ctrl.correctPatches = !args.found("noCorrectPatches");
764  ctrl.correctBCs = args.found("correctResultBoundaryFields");
765  ctrl.hasDimensions = args.found("dimensions");
766  ctrl.streamOpt.format(runTime.writeFormat());
767  if (args.found("ascii"))
768  {
769  ctrl.streamOpt.format(IOstreamOption::ASCII);
770  }
771 
772  expressions::exprString valueExpr_(args["expression"]);
773 
774  expressions::exprString maskExpr_;
775  args.readIfPresent("field-mask", maskExpr_);
776 
777  dimensionSet dims;
778  if (ctrl.hasDimensions)
779  {
780  ITstream is(args.lookup("dimensions"));
781  is >> dims;
782  }
783 
784  evaluate
785  (
786  mesh,
787  fieldName,
788  valueExpr_,
789  maskExpr_,
791  dims,
792  args.getList<word>("value-patches", false),
793 
794  ctrl
795  );
796  }
797  else if (exprDictPtr)
798  {
799  const dictionary& exprDict = *exprDictPtr;
800 
801  // preload fields specified in dictionary
802  {
803  wordList preloadFields;
804  exprDict.readIfPresent("readFields", preloadFields);
805  readFieldsHandler(mesh).execute(preloadFields);
806  }
807 
808  // Read set construct info from dictionary
809  PtrList<entry> actions(exprDict.lookup("expressions"));
810 
811  for (const entry& dEntry : actions)
812  {
813  if (!dEntry.isDict())
814  {
815  Info<< "Ignore non-dictionary entry: "
816  << dEntry.keyword() << nl;
817  continue;
818  }
819 
820  const dictionary& dict = dEntry.dict();
821 
822  setExprFieldsControl ctrl;
823 
824  ctrl.dryRun = args.dryRun();
825  ctrl.debugParsing = args.found("debug-parser");
826  ctrl.cacheVariables = !args.found("no-variable-caching");
827 
828  ctrl.createNew = dict.getOrDefault("create", false);
829  ctrl.keepPatches = dict.getOrDefault("keepPatches", false);
830 
831  ctrl.correctPatches = !args.found("noCorrectPatches");
832  ctrl.correctBCs = args.found("correctResultBoundaryFields");
833  ctrl.streamOpt.format(runTime.writeFormat());
834  if (args.found("ascii"))
835  {
836  ctrl.streamOpt.format(IOstreamOption::ASCII);
837  }
838 
839  if (ctrl.createNew && ctrl.keepPatches)
840  {
842  << "Cannot specify both 'create' and 'keepPatches'"
843  << nl << endl
844  << exit(FatalIOError);
845  }
846 
847  // Local override
849  (
850  "correctResultBoundaryFields",
851  ctrl.correctBCs
852  );
853 
854 
855  const word fieldName(dict.get<word>("field"));
856 
857  expressions::exprString valueExpr_("expression", dict);
858 
859  expressions::exprString maskExpr_;
860  {
861  const entry* eptr = dict.findCompat
862  (
863  "fieldMask", {{"condition", 2106}},
865  );
866 
867  if (eptr)
868  {
869  maskExpr_.readEntry(eptr->keyword(), dict);
870  maskExpr_.trim();
871  }
872  }
873 
874  // Optional: "dimensions"
875  dimensionSet dims;
876  ctrl.hasDimensions = dims.readIfPresent("dimensions", dict);
877 
878  if (args.verbose() && !timei)
879  {
880  // Report once
881  Info<< "Processing" << dict << nl;
882  }
883 
884  evaluate
885  (
886  mesh,
887  fieldName,
888  valueExpr_,
889  maskExpr_,
890  dict,
891  dims,
892  dict.getOrDefault<wordList>("valuePatches", wordList()),
893 
894  ctrl
895  );
896  }
897  }
898  else
899  {
901  << "No command-line or dictionary??" << nl << endl
902  << exit(FatalError);
903  }
904  }
905 
906  Info<< "\nEnd\n" << endl;
907 
908  return 0;
909 }
910 
911 
912 // ************************************************************************* //
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:547
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:244
constexpr char nl
The newline &#39;\n&#39; character (0x0a)
Definition: Ostream.H:49
"ascii" (normal default)
bool empty() const noexcept
True if List is empty (ie, size() is zero)
Definition: UList.H:632
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:51
List< T > getList(const label index) const
Get a List of values from the argument at index.
tmp< DimensionedField< TypeR, GeoMesh > > New(const tmp< DimensionedField< TypeR, GeoMesh >> &tf1, const word &name, const dimensionSet &dimensions, const bool initCopy=false)
Global function forwards to reuseTmpDimensionedField::New.
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:374
static void addOptionCompat(const word &optName, std::pair< const char *, int > compat)
Specify an alias for the option name.
Definition: argList.C:418
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.
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:1941
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:378
IOdictionary is derived from dictionary and IOobject to give the dictionary automatic IO functionalit...
Definition: IOdictionary.H:50
#define forAll(list, i)
Loop across all elements in list.
Definition: stdFoam.H:414
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)
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:671
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:504
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 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:212
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:385
virtual void setTime(const Time &t)
Reset the time and time-index to those of the given time.
Definition: Time.C:997
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 void addVerboseOption(const string &usage="", bool advanced=false)
Enable a &#39;verbose&#39; bool option, with usage information.
Definition: argList.C:520
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:770
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:491
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:180
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:667
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.
regIOobject is an abstract class derived from IOobject to handle automatic object registration with t...
Definition: regIOobject.H:65
messageStream Info
Information stream (stdout output on master, null elsewhere)
static Ostream & output(Ostream &os, const IntRange< T > &range)
Definition: IntRanges.C:58
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...
IOobject io("surfaceFilmProperties", mesh.time().constant(), mesh, IOobject::READ_IF_PRESENT, IOobject::NO_WRITE, IOobject::NO_REGISTER)
A class for managing temporary objects.
Definition: HashPtrTable.H:50
Foam::argList args(argc, argv)
bool execute(const UList< word > &fieldNames)
Definition: readFields.H:180
Defines the attributes of an object for which implicit objectRegistry management is supported...
Definition: IOobject.H:171
Driver for volume, surface, point field expressions.
int verbose() const noexcept
Return the verbose flag.
Definition: argListI.H:121
Do not request registration (bool: false)
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
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:133