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  //- Return the location of the min value
236  (
237  const scalarField& vals,
238  const pointField& locs
239  );
240 
241  //- Return the location of the max value
243  (
244  const scalarField& vals,
245  const pointField& locs
246  );
247 
248 
249  // Updating
250 
251  //- Update things
252  virtual bool update();
253 
254  //- Examine current variable values and update stored variables
255  virtual void updateSpecialVariables(bool force=false);
257 
258  // Results
259 
260  //- Get the result from another driver.
261  // Override to allow mapping
262  virtual exprResult getRemoteResult(const exprDriver& other) const;
263 
264 
265 public:
267  //- Runtime type information
268  TypeName("exprDriver");
269 
270 
271  // Generated Methods
272 
273  //- No copy construct
274  exprDriver(const exprDriver&) = delete;
275 
276  //- No copy assignment
277  void operator=(const exprDriver&) = delete;
278 
279 
280  // Constructors
281 
282  //- Default construct, and default construct with search preferences
283  explicit exprDriver
284  (
286  const dictionary& dict = dictionary::null
287  );
288 
289  //- Copy construct with new dictionary reference
290  exprDriver(const exprDriver& rhs, const dictionary& dict);
291 
292  //- Construct from a dictionary
293  explicit exprDriver(const dictionary& dict);
294 
295 
296  //- Destructor
297  virtual ~exprDriver() = default;
298 
299 
300  // Public Member Functions
301 
302  //- The natural field size for the expression
303  virtual label size() const
304  {
305  return 1;
306  }
307 
308  //- The point field size for the expression
309  virtual label pointSize() const
310  {
311  return 1;
312  }
313 
314  //- Reference to the current time-state (can be nullptr)
315  const TimeState* timeState() const noexcept;
316 
317  //- The current time value
318  virtual scalar timeValue() const;
319 
320  //- The current deltaT value
321  virtual scalar deltaT() const;
322 
323 
324  //- The dictionary with all input data/specification
325  const dictionary& dict() const noexcept
326  {
327  return dict_;
328  }
329 
330  //- Const access to expression result
331  const exprResult& result() const noexcept
332  {
333  return result_;
334  }
335 
336  //- Non-const access to expression result
337  exprResult& result() noexcept
338  {
339  return result_;
340  }
341 
342  //- Clear the result
343  void clearResult();
344 
345  //- Return the expression result as a tmp field
346  // This also clears the result and associated memory.
347  template<class Type>
348  tmp<Field<Type>> getResult(bool wantPointData=false);
349 
350  //- The result type as word - same as result().valueType()
351  const word& getResultType() const noexcept
352  {
353  return result_.valueType();
354  }
355 
356 
357  // External References
358 
359  //- Reset the objectRegistry (for functions)
360  void resetDb(const objectRegistry* obrPtr = nullptr);
361 
362  //- Reset the objectRegistry (for functions)
363  void resetDb(const objectRegistry& db);
364 
365 
366  // Specials
367 
368  //- Get special-purpose scalar reference argument.
369  // Typically available as \c arg() in an expression and
370  // may correspond to table index, time value etc.
371  inline scalar argValue() const noexcept;
372 
373 
374  // General Controls
375 
376  //- Get "look-behind" parsing context (internal bookkeeping)
377  inline int stashedTokenId() const noexcept;
378 
379  //- Reset "look-behind" parsing context (mutable operation)
380  // \return the previous value
381  inline int resetStashedTokenId(int tokenId=0) const noexcept;
382 
383 
384  //- Set the scanner/parser debug
385  void setDebugging(bool scannerDebug, bool parserDebug);
386 
387  //- Set the scanner/parser debug to match the input
388  void setDebugging(const exprDriver& rhs);
389 
390  //- Toggle CACHE_READ_FIELDS control
391  bool setCaching(bool on) noexcept;
392 
393  //- Set search behaviour,
394  //- with additional CACHE_READ_FIELDS toggle on
395  void setSearchBehaviour
396  (
397  enum searchControls search,
398  const bool caching = false
399  );
400 
401  //- Set search behaviour to be identical to rhs
402  void setSearchBehaviour(const exprDriver& rhs);
403 
404  //- Read access to scanner debug
405  inline bool debugScanner() const noexcept;
406 
407  //- Read access to parser debug
408  inline bool debugParser() const noexcept;
409 
410  bool prevIterIsOldTime() const { return prevIterIsOldTime_; }
411 
412 
413  // Variables
414 
415  //- Clear temporary variables, reset from expression strings
416  virtual void clearVariables();
417 
418  //- Set special-purpose scalar reference argument.
419  // Typically available as \c arg() in an expression and
420  // may corrspond to table index, time value etc.
421  inline void setArgument(const scalar val) noexcept;
422 
423  //- True if named variable exists
424  inline virtual bool hasVariable(const word& name) const;
425 
426  //- Return const-access to the named variable
427  inline virtual const exprResult& variable(const word& name) const;
428 
429  //- Add/set string expressions for variables
430  // Can include multiple definitions inline
432  (
433  const expressions::exprString& expr,
434  bool clear = true
435  );
436 
437  //- Add/set string expressions for variables
438  // Can include multiple definitions inline
439  void addVariables
440  (
441  const UList<expressions::exprString>& list,
442  bool clear = true
443  );
444 
445  //- Add a uniform variable from an outside caller
446  template<class T>
447  inline void addUniformVariable
448  (
449  const word& name,
450  const T& val
451  );
452 
453 
454  // Context fields (similar to objectRegistry)
456  //- True if any context fields are defined
457  inline bool hasContextObjects() const;
458 
459  //- Find named context field, if it exists
460  inline const regIOobject* cfindContextIOobject(const word& name) const;
461 
462  //- Find context field object of specified type
463  // \return nullptr if not found
464  template<class ObjType>
465  const ObjType* cfindContextObject(const word& name) const;
466 
467  //- Add the object to the context
468  inline void addContextObject(const word& name, const regIOobject*);
469 
470  //- Add the object to the context
471  inline void addContextObject(const regIOobject*);
472 
473  //- Remove the object from the context
474  inline void removeContextObject(const word& name);
475 
476  //- Remove the object from the context
477  inline void removeContextObject(const regIOobject*);
478 
479  //- Read access to the object context
480  inline const contextObjectTableType& contextObjects() const noexcept;
481 
482  //- Write access to the object context
484 
485 
486  // Scalar mappings (timelines / lookups)
487 
488  //- Named mapping with given type exists
489  template<class Type>
490  bool isFunction(const word& name) const;
491 
492  //- Evaluate named mapping for the given time/value.
493  //- Zero for undefined/unknown
494  template<class Type>
495  Type getFunctionValue(const word& name, const scalar x) const;
496 
497  //- Fill result with values remapped according to the named Function1
498  template<class Type>
499  void fillFunctionValues
500  (
501  Field<Type>& result,
502  const word& name,
503  const scalarField& input
504  ) const;
505 
506 
507  // Fields
508 
509  //- Test existence of a local variable
510  template<class T>
511  bool isLocalVariable
512  (
513  const word& name,
514  bool wantPointData = false,
515  label expectedSize = -1
516  ) const;
517 
518  //- Retrieve local/global variable as a tmp field
519  //
520  // \param name The name of the local/global field
521  // \param expectSize The size check on the variable, -1 to ignore
522  // \param mandatory A missing variable is Fatal, or return
523  // an invalid tmp
524  template<class Type>
525  tmp<Field<Type>> getLocalVariable
526  (
527  const word& name,
528  label expectSize,
529  const bool mandatory = true
530  ) const;
531 
532 
533  // Evaluation
534 
535  //- Execute the parser.
536  // The return value currently has no meaning.
537  virtual unsigned parse
538  (
539  const std::string& expr,
540  size_t pos = 0,
541  size_t len = std::string::npos
542  ) = 0;
543 
544  //- Evaluate the expression and return the field.
545  // This also clears the result and associated memory.
546  template<class Type>
547  inline tmp<Field<Type>>
548  evaluate
549  (
550  const expressions::exprString& expr,
551  bool wantPointData = false
552  );
553 
554  //- Evaluate the expression and return a single value.
555  // Does not clear the result.
556  template<class Type>
557  inline Type evaluateUniform
558  (
559  const expressions::exprString& expr,
560  bool wantPointData = false
561  );
562 
563 
564  //- Evaluate the expression
565  //- and save as the specified named variable
566  void evaluateVariable
567  (
568  const word& varName,
569  const expressions::exprString& expr
570  );
571 
572  //- Evaluate an expression on a remote
573  //- and save as the specified named variable
574  virtual void evaluateVariableRemote
575  (
576  string remote,
577  const word& varName,
578  const expressions::exprString& expr
579  );
580 
581 
582  // Fields
583 
584  //- Return a new field with the size()
585  template<class Type>
586  tmp<Field<Type>>
587  newField(const Type& val = pTraits<Type>::zero) const;
588 
589  //- Return a new field with the pointSize()
590  template<class Type>
591  tmp<Field<Type>>
592  newPointField(const Type& val = pTraits<Type>::zero) const;
593 
594 
595  // Reading
596 
597  //- Read an expression string and do substitutions
598  static expressions::exprString readExpression
599  (
600  const word& name,
601  const dictionary& dict
602  );
603 
604  //- Read the list of variable strings
605  // (or initialize with a single string)
606  static List<expressions::exprString> readVariableStrings
607  (
608  const dictionary& dict,
609  const word& name = "variables",
610  bool mandatory = false
611  );
612 
613  //- Read an expression string (with the current dictionary)
614  //- and do substitutions
615  expressions::exprString readExpression(const word& name);
616 
617 
618  //- Read variables, tables etc.
619  // Also usable for objects not constructed from a dictionary.
620  virtual bool readDict(const dictionary& dict);
621 
622  //- Read "variables" and assigns to the list of expression strings
623  // \return the number variable strings read.
624  label setVariableStrings
625  (
626  const dictionary& dict,
627  bool mandatory = false
628  );
629 
630 
631  // Writing
632 
633  //- Write "variables"
635  (
636  Ostream& os,
637  const word& keyword = ""
638  ) const;
639 };
640 
641 
642 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
643 
644 } // End namespace expressions
645 } // End namespace Foam
646 
647 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
648 
649 #include "exprDriverI.H"
650 #include "exprDriverContextI.H"
651 
652 #ifdef NoRepository
653  #include "exprDriverTemplates.C"
654 #endif
655 
656 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
657 
658 #endif
659 
660 // ************************************************************************* //
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:492
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:423
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:61
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:534
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:505
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
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:463
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: scalarImpl.H:255
A Vector of values with scalar precision, where scalar is float/double depending on the compilation f...
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
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.
const dictionary & dict_
The dictionary with all input data/specification.
Definition: exprDriver.H:196
surface1 clear()
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:455
TypeName("exprDriver")
Runtime type information.
regIOobject is an abstract class derived from IOobject to handle automatic object registration with t...
Definition: regIOobject.H:68
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:431
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:485
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