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