exprDriver.H
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) 2010-2018 Bernhard Gschaider
9  Copyright (C) 2019-2022 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 Class
28  Foam::expressions::exprDriver
29 
30 Description
31  Base driver for parsing (field) values.
32 
33  Largely based on code and ideas from swak4foam
34 
35  Properties
36  \table
37  Property | Description | Required | Default
38  variables | List of variables for expressions | no | ()
39  functions<scalar> | Dictionary of scalar Function1 | no | {}
40  functions<vector> | Dictionary of vector Function1 | no | {}
41  allowShadowing | Allow variables to shadow field names | no | false
42  \endtable
43 
44  Debug Properties
45  \table
46  Property | Description | Required | Default
47  debug.driver | Debug level (int) for base driver | no |
48  debug.scanner | Add debug for scanner | no | false
49  debug.parser | Add debug for parser | no | false
50  \endtable
51 
52  The \c functions<scalar> and \c functions<vector> entries are
53  dictionaries of Foam::Function1 definitions that can either be used
54  to establish a time-varying quantity, to remap a field of scalar
55  values, or both.
56 
57 SourceFiles
58  exprDriverI.H
59  exprDriverContextI.H
60  exprDriver.C
61  exprDriverFields.C
62  exprDriverFunctions.C
63  exprDriverIO.C
64  exprDriverTemplates.C
65 
66 \*---------------------------------------------------------------------------*/
67 
68 #ifndef Foam_expressions_exprDriver_H
69 #define Foam_expressions_exprDriver_H
70 
71 #include "exprResult.H"
72 #include "exprString.H"
73 #include "exprTraits.H"
74 #include "pointField.H"
75 #include "primitiveFields.H"
76 #include "objectRegistry.H"
77 #include "HashTable.H"
78 #include "HashSet.H"
79 #include "Function1.H"
80 
81 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
82 
83 namespace Foam
84 {
85 
86 // Forward Declarations
87 class TimeState;
88 
89 namespace expressions
90 {
91 
92 /*---------------------------------------------------------------------------*\
93  Class exprDriver Declaration
94 \*---------------------------------------------------------------------------*/
95 
96 class exprDriver
97 {
98 public:
99 
100  // Data Types
101 
102  //- Search/caching controls
103  enum searchControls
104  {
105  NO_SEARCH = 0,
106  SEARCH_REGISTRY = 1,
107  SEARCH_FILES = 2,
108  CACHE_READ_FIELDS = 4,
110  };
111 
112 
113  //- Externally defined context fields
114  typedef HashTable<const regIOobject*> contextObjectTableType;
115 
116 
117 private:
118 
119  // Private Member Functions
120 
121  //- Get search/caching controls from dictionary entries
122  static int getSearchControls(const dictionary& dict);
123 
124  //- Read/reset Function1 entries
125  void resetFunctions(const dictionary& dict);
126 
127  //- Helper for lookup of Function1 in table
128  template<class Type>
129  static const Function1<Type>* getFunction1Ptr
130  (
131  const word& name,
132  const HashTable<refPtr<Function1<Type>>>& tbl,
133  wordList* listFailure = nullptr
134  );
135 
137 protected:
138 
139  // Protected Data
140 
141  // Stored Data
142 
143  //- The dictionary with all input data/specification
144  const dictionary& dict_;
146  //- The result
149  //- Variable definitions, as read from a dictionary
152  //- The variables table
154 
155  //- Function1 mappings/timelines (scalar),
156  //- evaluated at the simulation time or with arbitrary scalars
159  //- Function1 mappings/timelines (vector),
160  //- evaluated at the simulation time or with arbitrary scalars
162 
163  //- Externally defined context fields
165 
166  //- Special-purpose scalar reference argument
167  scalar arg1Value_;
168 
169  //- Reference to the time-state
170  mutable const TimeState* timeStatePtr_;
171 
172  //- Pointer to an object registry (for functions etc).
173  const objectRegistry* obrPtr_;
174 
175 
176  // Controls, tracing etc.
177 
178  //- Internal bookkeeping as "look-behind" parsing context
179  mutable int stashedTokenId_;
180 
181  //- Request debugging for scanner
182  bool debugScanner_;
183 
184  //- Request debugging for parser
185  bool debugParser_;
186 
187  //- Allow variable names to mask field names
188  bool allowShadowing_;
189 
190  //- Use value of previous iteration when oldTime is requested
191  bool prevIterIsOldTime_;
192 
193  //- Registry/disk/caching control
195 
197  // Protected Member Functions
198 
199  inline bool searchRegistry() const noexcept;
200  inline bool searchFiles() const noexcept;
201  inline bool cacheReadFields() const noexcept;
202 
203  //- Reset the time-state reference
204  void resetTimeReference(const TimeState* ts);
205 
206  //- Reset the time-state reference
207  void resetTimeReference(const TimeState& ts);
208 
209  //- Write scalar/vector Function1 entries in dictionary format
210  void writeFunctions(Ostream& os) const;
212 
213  // Variables
214 
215  //- Non-const access to the named variable (sub-classes only)
216  inline virtual exprResult& variable(const word& name);
218 
219  // Fields
220 
221  //- Fill a random field
222  //
223  // \param field the field to populate
224  // \param seed the seed value. If zero or negative, use as an offset
225  // to the current timeIndex (if a time-state is available)
226  // \param gaussian generate a Gaussian distribution
227  void fill_random
228  (
230  label seed = 0,
231  const bool gaussian = false
232  ) const;
234  //- The (global) weighted average of a field, with stabilisation
235  template<class Type>
236  static Type weightedAverage
237  (
238  const scalarField& weights,
239  const Field<Type>& fld
240  );
241 
242  //- The (global) weighted sum (integral) of a field
243  template<class Type>
244  static Type weightedSum
245  (
246  const scalarField& weights,
247  const Field<Type>& fld
248  );
249 
250  //- Return the location of the min value
252  (
253  const scalarField& vals,
254  const pointField& locs
255  );
257  //- Return the location of the max value
259  (
260  const scalarField& vals,
261  const pointField& locs
262  );
263 
264 
265  // Updating
267  //- Update things
268  virtual bool update();
269 
270  //- Examine current variable values and update stored variables
271  virtual void updateSpecialVariables(bool force=false);
272 
273 
274  // Results
275 
276  //- Get the result from another driver.
277  // Override to allow mapping
278  virtual exprResult getRemoteResult(const exprDriver& other) const;
279 
280 
281 public:
282 
283  //- Runtime type information
284  TypeName("exprDriver");
285 
286 
287  // Generated Methods
288 
289  //- No copy construct
290  exprDriver(const exprDriver&) = delete;
291 
292  //- No copy assignment
293  void operator=(const exprDriver&) = delete;
294 
295 
296  // Constructors
297 
298  //- Default construct, and default construct with search preferences
299  explicit exprDriver
300  (
302  const dictionary& dict = dictionary::null
303  );
304 
305  //- Copy construct with new dictionary reference
306  exprDriver(const exprDriver& rhs, const dictionary& dict);
307 
308  //- Construct from a dictionary
309  explicit exprDriver(const dictionary& dict);
310 
311 
312  //- Destructor
313  virtual ~exprDriver() = default;
314 
315 
316  // Public Member Functions
317 
318  //- The natural field size for the expression
319  virtual label size() const
320  {
321  return 1;
322  }
323 
324  //- The point field size for the expression
325  virtual label pointSize() const
326  {
327  return 1;
328  }
329 
330  //- Reference to the current time-state (can be nullptr)
331  const TimeState* timeState() const noexcept;
332 
333  //- The current time value
334  virtual scalar timeValue() const;
335 
336  //- The current deltaT value
337  virtual scalar deltaT() const;
338 
339 
340  //- The dictionary with all input data/specification
341  const dictionary& dict() const noexcept
342  {
343  return dict_;
344  }
345 
346  //- Const access to expression result
347  const exprResult& result() const noexcept
348  {
349  return result_;
350  }
351 
352  //- Non-const access to expression result
353  exprResult& result() noexcept
354  {
355  return result_;
356  }
357 
358  //- Clear the result
359  void clearResult();
360 
361  //- Return the expression result as a tmp field
362  // This also clears the result and associated memory.
363  template<class Type>
364  tmp<Field<Type>> getResult(bool wantPointData=false);
365 
366  //- The result type as word - same as result().valueType()
367  const word& getResultType() const noexcept
368  {
369  return result_.valueType();
370  }
371 
372 
373  // External References
374 
375  //- Reset the objectRegistry (for functions)
376  void resetDb(const objectRegistry* obrPtr = nullptr);
377 
378  //- Reset the objectRegistry (for functions)
379  void resetDb(const objectRegistry& db);
380 
381 
382  // Specials
383 
384  //- Get special-purpose scalar reference argument.
385  // Typically available as \c arg() in an expression and
386  // may correspond to table index, time value etc.
387  inline scalar argValue() const noexcept;
388 
389 
390  // General Controls
391 
392  //- Get "look-behind" parsing context (internal bookkeeping)
393  inline int stashedTokenId() const noexcept;
394 
395  //- Reset "look-behind" parsing context (mutable operation)
396  // \return the previous value
397  inline int resetStashedTokenId(int tokenId=0) const noexcept;
398 
399 
400  //- Set the scanner/parser debug
401  void setDebugging(bool scannerDebug, bool parserDebug);
402 
403  //- Set the scanner/parser debug to match the input
404  void setDebugging(const exprDriver& rhs);
405 
406  //- Toggle CACHE_READ_FIELDS control
407  bool setCaching(bool on) noexcept;
408 
409  //- Set search behaviour,
410  //- with additional CACHE_READ_FIELDS toggle on
411  void setSearchBehaviour
412  (
413  enum searchControls search,
414  const bool caching = false
415  );
416 
417  //- Set search behaviour to be identical to rhs
418  void setSearchBehaviour(const exprDriver& rhs);
419 
420  //- Read access to scanner debug
421  inline bool debugScanner() const noexcept;
422 
423  //- Read access to parser debug
424  inline bool debugParser() const noexcept;
425 
426  bool prevIterIsOldTime() const { return prevIterIsOldTime_; }
427 
428 
429  // Variables
430 
431  //- Clear temporary variables, reset from expression strings
432  virtual void clearVariables();
433 
434  //- Set special-purpose scalar reference argument.
435  // Typically available as \c arg() in an expression and
436  // may corrspond to table index, time value etc.
437  inline void setArgument(const scalar val) noexcept;
438 
439  //- True if named variable exists
440  inline virtual bool hasVariable(const word& name) const;
441 
442  //- Return const-access to the named variable
443  inline virtual const exprResult& variable(const word& name) const;
444 
445  //- Add/set string expressions for variables
446  // Can include multiple definitions inline
447  void addVariables
448  (
449  const expressions::exprString& expr,
450  bool clear = true
451  );
452 
453  //- Add/set string expressions for variables
454  // Can include multiple definitions inline
455  void addVariables
456  (
457  const UList<expressions::exprString>& list,
458  bool clear = true
459  );
460 
461  //- Add a uniform variable from an outside caller
462  template<class T>
463  inline void addUniformVariable
464  (
465  const word& name,
466  const T& val
467  );
468 
469 
470  // Context fields (similar to objectRegistry)
471 
472  //- True if any context fields are defined
473  inline bool hasContextObjects() const;
474 
475  //- Find named context field, if it exists
476  inline const regIOobject* cfindContextIOobject(const word& name) const;
477 
478  //- Find context field object of specified type
479  // \return nullptr if not found
480  template<class ObjType>
481  const ObjType* cfindContextObject(const word& name) const;
482 
483  //- Add the object to the context
484  inline void addContextObject(const word& name, const regIOobject*);
485 
486  //- Add the object to the context
487  inline void addContextObject(const regIOobject*);
488 
489  //- Remove the object from the context
490  inline void removeContextObject(const word& name);
492  //- Remove the object from the context
493  inline void removeContextObject(const regIOobject*);
494 
495  //- Read access to the object context
496  inline const contextObjectTableType& contextObjects() const noexcept;
497 
498  //- Write access to the object context
500 
501 
502  // Scalar mappings (timelines / lookups)
503 
504  //- Named mapping with given type exists
505  template<class Type>
506  bool isFunction(const word& name) const;
507 
508  //- Evaluate named mapping for the given time/value.
509  //- Zero for undefined/unknown
510  template<class Type>
511  Type getFunctionValue(const word& name, const scalar x) const;
513  //- Fill result with values remapped according to the named Function1
514  template<class Type>
515  void fillFunctionValues
516  (
517  Field<Type>& result,
518  const word& name,
519  const scalarField& input
520  ) const;
521 
522 
523  // Fields
524 
525  //- Test existence of a local variable
526  template<class T>
527  bool isLocalVariable
528  (
529  const word& name,
530  bool wantPointData = false,
531  label expectedSize = -1
532  ) const;
533 
534  //- Retrieve local/global variable as a tmp field
535  //
536  // \param name The name of the local/global field
537  // \param expectSize The size check on the variable, -1 to ignore
538  // \param mandatory A missing variable is Fatal, or return
539  // an invalid tmp
540  template<class Type>
541  tmp<Field<Type>> getLocalVariable
542  (
543  const word& name,
544  label expectSize,
545  const bool mandatory = true
546  ) const;
547 
548 
549  // Evaluation
550 
551  //- Execute the parser.
552  // The return value currently has no meaning.
553  virtual unsigned parse
554  (
555  const std::string& expr,
556  size_t pos = 0,
557  size_t len = std::string::npos
558  ) = 0;
559 
560  //- Evaluate the expression and return the field.
561  // This also clears the result and associated memory.
562  template<class Type>
563  inline tmp<Field<Type>>
564  evaluate
565  (
566  const expressions::exprString& expr,
567  bool wantPointData = false
568  );
569 
570  //- Evaluate the expression and return a single value.
571  // Does not clear the result.
572  template<class Type>
573  inline Type evaluateUniform
574  (
575  const expressions::exprString& expr,
576  bool wantPointData = false
577  );
578 
579 
580  //- Evaluate the expression
581  //- and save as the specified named variable
582  void evaluateVariable
583  (
584  const word& varName,
585  const expressions::exprString& expr
586  );
587 
588  //- Evaluate an expression on a remote
589  //- and save as the specified named variable
590  virtual void evaluateVariableRemote
591  (
592  string remote,
593  const word& varName,
594  const expressions::exprString& expr
595  );
596 
598  // Fields
599 
600  //- Return a new field with the size()
601  template<class Type>
602  tmp<Field<Type>>
603  newField(const Type& val = pTraits<Type>::zero) const;
604 
605  //- Return a new field with the pointSize()
606  template<class Type>
607  tmp<Field<Type>>
608  newPointField(const Type& val = pTraits<Type>::zero) const;
609 
610 
611  // Reading
612 
613  //- Read an expression string and do substitutions
614  static expressions::exprString readExpression
615  (
616  const word& name,
617  const dictionary& dict
618  );
619 
620  //- Read the list of variable strings
621  // (or initialize with a single string)
622  static List<expressions::exprString> readVariableStrings
623  (
624  const dictionary& dict,
625  const word& name = "variables",
626  bool mandatory = false
627  );
628 
629  //- Read an expression string (with the current dictionary)
630  //- and do substitutions
631  expressions::exprString readExpression(const word& name);
632 
633 
634  //- Read variables, tables etc.
635  // Also usable for objects not constructed from a dictionary.
636  virtual bool readDict(const dictionary& dict);
637 
638  //- Read "variables" and assigns to the list of expression strings
639  // \return the number variable strings read.
640  label setVariableStrings
641  (
642  const dictionary& dict,
643  bool mandatory = false
644  );
645 
646 
647  // Writing
648 
649  //- Write "variables"
651  (
652  Ostream& os,
653  const word& keyword = ""
654  ) const;
655 };
656 
657 
658 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
659 
660 } // End namespace expressions
661 } // End namespace Foam
662 
663 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
664 
665 #include "exprDriverI.H"
666 #include "exprDriverContextI.H"
667 
668 #ifdef NoRepository
669  #include "exprDriverTemplates.C"
670 #endif
671 
672 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
673 
674 #endif
675 
676 // ************************************************************************* //
bool allowShadowing_
Allow variable names to mask field names.
Definition: exprDriver.H:266
void fill_random(scalarField &field, label seed=0, const bool gaussian=false) const
Fill a random field.
bool searchRegistry() const noexcept
Definition: exprDriverI.H:137
void resetTimeReference(const TimeState *ts)
Reset the time-state reference.
Definition: exprDriver.C:123
tmp< Field< Type > > getResult(bool wantPointData=false)
Return the expression result as a tmp field.
tmp< Field< Type > > newPointField(const Type &val=pTraits< Type >::zero) const
Return a new field with the pointSize()
HashTable< exprResult > variables_
The variables table.
Definition: exprDriver.H:211
void removeContextObject(const word &name)
Remove the object from the context.
rDeltaTY field()
virtual bool hasVariable(const word &name) const
True if named variable exists.
Definition: exprDriverI.H:37
Ostream & writeVariableStrings(Ostream &os, const word &keyword="") const
Write "variables".
Definition: exprDriverIO.C:112
The time value with time-stepping information, user-defined remapping, etc.
Definition: TimeState.H:47
bool hasContextObjects() const
True if any context fields are defined.
void addContextObject(const word &name, const regIOobject *)
Add the object to the context.
A list of keyword definitions, which are a keyword followed by a number of values (eg...
Definition: dictionary.H:129
bool debugScanner() const noexcept
Read access to scanner debug.
Definition: exprDriverI.H:125
const word & getResultType() const noexcept
The result type as word - same as result().valueType()
Definition: exprDriver.H:512
A polymorphic field/result from evaluating an expression.
Definition: exprResult.H:121
A 1D array of objects of type <T>, where the size of the vector is known and used for subscript bound...
Definition: BitOps.H:56
searchControls searchCtrl_
Registry/disk/caching control.
Definition: exprDriver.H:276
static List< expressions::exprString > readVariableStrings(const dictionary &dict, const word &name="variables", bool mandatory=false)
Read the list of variable strings.
Definition: exprDriverIO.C:89
virtual label size() const
The natural field size for the expression.
Definition: exprDriver.H:443
scalar arg1Value_
Special-purpose scalar reference argument.
Definition: exprDriver.H:233
virtual bool readDict(const dictionary &dict)
Read variables, tables etc.
Definition: exprDriver.C:290
virtual unsigned parse(const std::string &expr, size_t pos=0, size_t len=std::string::npos)=0
Execute the parser.
A traits class, which is primarily used for primitives and vector-space.
Definition: pTraits.H:75
const regIOobject * cfindContextIOobject(const word &name) const
Find named context field, if it exists.
void addUniformVariable(const word &name, const T &val)
Add a uniform variable from an outside caller.
const word & valueType() const noexcept
Basic type for the field or single value.
Definition: exprResultI.H:192
virtual void clearVariables()
Clear temporary variables, reset from expression strings.
Definition: exprDriver.C:324
tmp< Field< Type > > newField(const Type &val=pTraits< Type >::zero) const
Return a new field with the size()
void setSearchBehaviour(enum searchControls search, const bool caching=false)
Set search behaviour, with additional CACHE_READ_FIELDS toggle on.
Definition: exprDriver.C:535
virtual void evaluateVariableRemote(string remote, const word &varName, const expressions::exprString &expr)
Evaluate an expression on a remote and save as the specified named variable.
Definition: exprDriver.C:350
void setArgument(const scalar val) noexcept
Set special-purpose scalar reference argument.
Definition: exprDriverI.H:24
virtual void updateSpecialVariables(bool force=false)
Examine current variable values and update stored variables.
Definition: exprDriver.C:320
static point getPositionOfMaximum(const scalarField &vals, const pointField &locs)
Return the location of the max value.
Type evaluateUniform(const expressions::exprString &expr, bool wantPointData=false)
Evaluate the expression and return a single value.
Definition: exprDriverI.H:94
void addVariables(const expressions::exprString &expr, bool clear=true)
Add/set string expressions for variables.
Definition: exprDriver.C:372
bool isFunction(const word &name) const
Named mapping with given type exists.
contextObjectTableType contextObjects_
Externally defined context fields.
Definition: exprDriver.H:228
searchControls
Search/caching controls.
Definition: exprDriver.H:145
void fillFunctionValues(Field< Type > &result, const word &name, const scalarField &input) const
Fill result with values remapped according to the named Function1.
dimensionedScalar pos(const dimensionedScalar &ds)
const TimeState * timeState() const noexcept
Reference to the current time-state (can be nullptr)
Definition: exprDriver.C:247
Type getFunctionValue(const word &name, const scalar x) const
Evaluate named mapping for the given time/value. Zero for undefined/unknown.
word name(const expressions::valueTypeCode typeCode)
A word representation of a valueTypeCode. Empty for expressions::valueTypeCode::INVALID.
Definition: exprTraits.C:127
int resetStashedTokenId(int tokenId=0) const noexcept
Reset "look-behind" parsing context (mutable operation)
Definition: exprDriverI.H:115
scalar argValue() const noexcept
Get special-purpose scalar reference argument.
Definition: exprDriverI.H:30
int stashedTokenId_
Internal bookkeeping as "look-behind" parsing context.
Definition: exprDriver.H:251
A class for handling words, derived from Foam::string.
Definition: word.H:63
bool setCaching(bool on) noexcept
Toggle CACHE_READ_FIELDS control.
Definition: exprDriver.C:506
exprDriver(const exprDriver &)=delete
No copy construct.
static Istream & input(Istream &is, IntRange< T > &range)
Definition: IntRanges.C:33
const ObjType * cfindContextObject(const word &name) const
Find context field object of specified type.
A variant of Foam::string with expansion of dictionary variables into a comma-separated form...
Definition: exprString.H:55
patchWriters clear()
const contextObjectTableType & contextObjects() const noexcept
Read access to the object context.
void clearResult()
Clear the result.
Definition: exprDriver.C:308
const exprResult & result() const noexcept
Const access to expression result.
Definition: exprDriver.H:483
label setVariableStrings(const dictionary &dict, bool mandatory=false)
Read "variables" and assigns to the list of expression strings.
Definition: exprDriverIO.C:100
A HashTable similar to std::unordered_map.
Definition: HashTable.H:108
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:105
tmp< Field< Type > > getLocalVariable(const word &name, label expectSize, const bool mandatory=true) const
Retrieve local/global variable as a tmp field.
int stashedTokenId() const noexcept
Get "look-behind" parsing context (internal bookkeeping)
Definition: exprDriverI.H:108
static expressions::exprString readExpression(const word &name, const dictionary &dict)
Read an expression string and do substitutions.
Definition: exprDriverIO.C:68
An Ostream is an abstract base class for all output systems (streams, files, token lists...
Definition: Ostream.H:56
const direction noexcept
Definition: Scalar.H:258
A Vector of values with scalar precision, where scalar is float/double depending on the compilation f...
static Type weightedAverage(const scalarField &weights, const Field< Type > &fld)
The (global) weighted average of a field, with stabilisation.
bool debugScanner_
Request debugging for scanner.
Definition: exprDriver.H:256
OBJstream os(runTime.globalPath()/outputName)
HashTable< const regIOobject * > contextObjectTableType
Externally defined context fields.
Definition: exprDriver.H:158
virtual exprResult getRemoteResult(const exprDriver &other) const
Get the result from another driver.
Definition: exprDriver.C:362
void T(FieldField< Field, Type > &f1, const FieldField< Field, Type > &f2)
Base driver for parsing (field) values.
Definition: exprDriver.H:136
virtual bool update()
Update things.
Definition: exprDriver.C:314
Search disk (eg, standalone app)
Definition: exprDriver.H:149
gmvFile<< "tracers "<< particles.size()<< nl;for(const passiveParticle &p :particles){ gmvFile<< p.position().x()<< ' ';}gmvFile<< nl;for(const passiveParticle &p :particles){ gmvFile<< p.position().y()<< ' ';}gmvFile<< nl;for(const passiveParticle &p :particles){ gmvFile<< p.position().z()<< ' ';}gmvFile<< nl;for(const word &name :lagrangianScalarNames){ IOField< scalar > fld(IOobject(name, runTime.timeName(), cloud::prefix, mesh, IOobject::MUST_READ, IOobject::NO_WRITE))
Specialisations of Field<T> for scalar, vector and tensor.
bool debugParser() const noexcept
Read access to parser debug.
Definition: exprDriverI.H:131
List< word > wordList
List of word.
Definition: fileName.H:59
bool prevIterIsOldTime_
Use value of previous iteration when oldTime is requested.
Definition: exprDriver.H:271
HashTable< refPtr< Function1< vector > > > vectorFuncs_
Function1 mappings/timelines (vector), evaluated at the simulation time or with arbitrary scalars...
Definition: exprDriver.H:223
void writeFunctions(Ostream &os) const
Write scalar/vector Function1 entries in dictionary format.
static Type weightedSum(const scalarField &weights, const Field< Type > &fld)
The (global) weighted sum (integral) of a field.
const dictionary & dict_
The dictionary with all input data/specification.
Definition: exprDriver.H:196
void resetDb(const objectRegistry *obrPtr=nullptr)
Reset the objectRegistry (for functions)
Definition: exprDriver.C:135
virtual scalar deltaT() const
The current deltaT value.
Definition: exprDriver.C:275
bool isLocalVariable(const word &name, bool wantPointData=false, label expectedSize=-1) const
Test existence of a local variable.
const dictionary & dict() const noexcept
The dictionary with all input data/specification.
Definition: exprDriver.H:475
TypeName("exprDriver")
Runtime type information.
regIOobject is an abstract class derived from IOobject to handle automatic object registration with t...
Definition: regIOobject.H:66
static point getPositionOfMinimum(const scalarField &vals, const pointField &locs)
Return the location of the min value.
List< expressions::exprString > variableStrings_
Variable definitions, as read from a dictionary.
Definition: exprDriver.H:206
A class representing the concept of 0 (zero) that can be used to avoid manipulating objects known to ...
Definition: zero.H:57
exprResult result_
The result.
Definition: exprDriver.H:201
const objectRegistry * obrPtr_
Pointer to an object registry (for functions etc).
Definition: exprDriver.H:243
fileName search(const word &file, const fileName &directory)
Recursively search the given directory for the file.
Definition: fileName.C:642
HashTable< refPtr< Function1< scalar > > > scalarFuncs_
Function1 mappings/timelines (scalar), evaluated at the simulation time or with arbitrary scalars...
Definition: exprDriver.H:217
const TimeState * timeStatePtr_
Reference to the time-state.
Definition: exprDriver.H:238
bool cacheReadFields() const noexcept
Definition: exprDriverI.H:149
virtual label pointSize() const
The point field size for the expression.
Definition: exprDriver.H:451
A class for managing temporary objects.
Definition: HashPtrTable.H:50
Registry of regIOobjects.
virtual exprResult & variable(const word &name)
Non-const access to the named variable (sub-classes only)
Definition: exprDriverI.H:57
tmp< Field< Type > > evaluate(const expressions::exprString &expr, bool wantPointData=false)
Evaluate the expression and return the field.
void evaluateVariable(const word &varName, const expressions::exprString &expr)
Evaluate the expression and save as the specified named variable.
Definition: exprDriver.C:332
bool searchFiles() const noexcept
Definition: exprDriverI.H:143
void setDebugging(bool scannerDebug, bool parserDebug)
Set the scanner/parser debug.
Definition: exprDriver.C:486
Namespace for OpenFOAM.
bool debugParser_
Request debugging for parser.
Definition: exprDriver.H:261
virtual scalar timeValue() const
The current time value.
Definition: exprDriver.C:261