Go to the documentation of this file.
59 #ifndef expressions_exprDriver_H
60 #define expressions_exprDriver_H
87 const dictionary&
dict_;
131 template<
typename TableType>
141 template<
class TableType>
167 const bool gaussian =
false
270 virtual const exprResult&
result()
const
276 virtual exprResult&
result()
343 inline virtual const exprResult&
variable(
const word&
name)
const;
349 const expressions::exprString& expr,
378 label expectedSize = -1
392 const bool mandatory =
true
400 virtual unsigned parse
402 const std::string& expr,
404 size_t len = std::string::npos
413 bool isPointVal =
false
421 bool isPointVal =
false
471 bool mandatory =
false
488 bool mandatory =
false
498 const word& keyword =
""
virtual void updateSpecialVariables(bool force=false)
Examine current variable values and update stored variables.
int stashedTokenId() const
Get "look-behind" parsing context (internal bookkeeping)
bool prevIterIsOldTime_
Use value of previous iteration when oldTime is requested.
virtual ~exprDriver()=default
Destructor.
label ListType::const_reference val
bool debugParser_
Request debugging for parser.
void addVariables(const expressions::exprString &expr, bool clear=true)
Add/set string expressions for variables.
static expressions::exprString readExpression(const word &name, const dictionary &dict)
Read an expression string and do substitutions.
bool searchInMemory_
Search in registry before looking on disk.
A class for handling words, derived from Foam::string.
bool isLocalVariable(const word &name, bool isPointVal, label expectedSize=-1) const
Test existence of a local variable.
A class for managing temporary objects.
virtual unsigned parse(const std::string &expr, size_t pos=0, size_t len=std::string::npos)=0
Execute the parser.
virtual bool readDict(const dictionary &dict)
Read variables, tables etc.
void setSearchBehaviour(bool cacheReadFields, bool searchInMemory, bool searchFiles)
Set search behaviour.
const word & valueType() const
Basic type for the field or single value.
tmp< Field< Type > > newField(const Type &val=pTraits< Type >::zero) const
Return a new field with the size()
bool searchFiles_
Search on disk (eg, for a standalone application)
void operator=(const exprDriver &)=delete
No copy assignment.
void evaluateVariable(const word &varName, const expressions::exprString &expr)
tmp< Field< Type > > getLocalVariable(const word &name, label expectSize, const bool mandatory=true) const
Retrieve local/global variable as a tmp field.
virtual word getResultType() const
The result type as word - same as result().valueType()
static point getPositionOfMaximum(const scalarField &vals, const pointField &locs)
Return the location of the max value.
int resetStashedTokenId(int tokenId=0) const
Reset "look-behind" parsing context (mutable operation)
bool debugScanner_
Request debugging for scanner.
const dictionary & dict_
The dictionary with all input data/specification.
void setDebugging(bool scannerDebug, bool parserDebug)
Set the scanner/parser debug.
static List< expressions::exprString > readVariableStrings(const dictionary &dict, const word &name="variables", bool mandatory=false)
Read the list of variable strings.
bool searchInMemory() const
bool allowShadowing_
Allow variable names to mask field names.
virtual label pointSize() const
The underlying point field size for the expression.
Specialisations of Field<T> for scalar, vector and tensor.
static const dictionary null
An empty dictionary, which is also the parent for all dictionaries.
static point getPositionOfMinimum(const scalarField &vals, const pointField &locs)
Return the location of the min value.
TypeName("exprDriver")
Runtime type information.
virtual bool hasVariable(const word &name) const
True if named variable exists.
bool cacheReadFields() const
tmp< Field< Type > > newPointField(const Type &val=pTraits< Type >::zero) const
Return a new field with the pointSize()
virtual exprResult getRemoteResult(const exprDriver &other) const
Get the result from another driver.
tmp< Field< Type > > getResult(bool isPointVal=false)
Return the expression result as a tmp field.
intWM_LABEL_SIZE_t label
A label is an int32_t or int64_t as specified by the pre-processor macro WM_LABEL_SIZE.
A polymorphic field/result from evaluating an expression.
label setVariableStrings(const dictionary &dict, bool mandatory=false)
Read "variables" and assigns to the list of expression strings.
static Type weightedAverage(const scalarField &weights, const Field< Type > &fld)
The (global) weighted average of a field, with stabilisation.
word name(const complex &c)
Return string representation of complex.
void T(FieldField< Field, Type > &f1, const FieldField< Field, Type > &f2)
virtual exprResult & result()
Non-const access to expression result.
void addUniformVariable(const word &name, const T &val)
Add a uniform variable from an outside caller.
Type evaluateUniform(const expressions::exprString &expr, bool isPointVal=false)
Evaluate the expression and return a single value.
HashTable< exprResult > variables_
The variables table.
Base driver for parsing (field) values.
bool prevIterIsOldTime() const
void fill_random(scalarField &field, label seed=0, const bool gaussian=false) const
Fill a random field.
bool debugParser() const
Read access to parser debug.
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))
virtual exprResult & variable(const word &name)
Non-const access to the named variable (sub-classes only)
bool debugScanner() const
Read access to scanner debug.
A list of keyword definitions, which are a keyword followed by a number of values (eg,...
int stashedTokenId_
Internal bookkeeping as "look-behind" parsing context.
virtual void clearVariables()
Clear temporary variables and resets from expression strings.
static void writeTable(Ostream &os, const word &name, const HashTable< TableType > &tbl)
Write an interpolation table.
static bool readTable(const word &name, const dictionary &dict, HashTable< TableType > &tbl, bool clear=true)
Read an interpolation table.
exprDriver(bool cacheReadFields=false, bool searchInMemory=true, bool searchFiles=false, const dictionary &dict=dictionary::null)
Null constructor, and null construct with search preferences.
bool cacheReadFields_
Keep fields read from disc in memory.
List< expressions::exprString > variableStrings_
Variable definitions, as read from a dictionary.
A HashTable similar to std::unordered_map.
const dictionary & dict() const
The dictionary with all input data/specification.
tmp< Field< Type > > evaluate(const expressions::exprString &expr, bool isPointVal=false)
Evaluate the expression and return the field.
A 1D array of objects of type <T>, where the size of the vector is known and used for subscript bound...
Traits class for primitives.
virtual const exprResult & result() const
Const access to expression result.
Ostream & writeVariableStrings(Ostream &os, const word &keyword="") const
Write "variables".
A 1D vector of objects of type <T>, where the size of the vector is known and can be used for subscri...
virtual void evaluateVariableRemote(string remote, const word &varName, const expressions::exprString &expr)
void clearResult()
Clear the result.
virtual label size() const
The underlying field size for the expression.
An Ostream is an abstract base class for all output systems (streams, files, token lists,...
static Type weightedSum(const scalarField &weights, const Field< Type > &fld)
The (global) weighted sum (integral) of a field.
virtual bool update()
Update things.
exprResult result_
The result.
dimensionedScalar pos(const dimensionedScalar &ds)