Go to the documentation of this file.
59 #ifndef expressions_exprDriver_H
60 #define expressions_exprDriver_H
87 const dictionary&
dict_;
132 template<
typename TableType>
142 template<
class TableType>
168 const bool gaussian =
false
253 virtual label
size()
const
271 virtual const exprResult&
result()
const
277 virtual exprResult&
result()
357 inline virtual const exprResult&
variable(
const word&
name)
const;
363 const expressions::exprString& expr,
391 bool wantPointData =
false,
392 label expectedSize = -1
406 const bool mandatory =
true
414 virtual unsigned parse
416 const std::string& expr,
418 size_t len = std::string::npos
427 bool wantPointData =
false
435 bool wantPointData =
false
485 bool mandatory =
false
502 bool mandatory =
false
512 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.
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.
Type evaluateUniform(const expressions::exprString &expr, bool wantPointData=false)
Evaluate the expression and return a single value.
A class for handling words, derived from Foam::string.
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 > > getResult(bool wantPointData=false)
Return the expression result as a tmp field.
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.
virtual void setArgument(const scalar val)
Set special-purpose scalar reference argument.
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.
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.
HashTable< exprResult > variables_
The variables table.
Base driver for parsing (field) values.
scalar arg1Value_
Special-purpose scalar reference argument.
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))
bool isLocalVariable(const word &name, bool wantPointData=false, label expectedSize=-1) const
Test existence of a local variable.
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.
scalar argValue() const
Set special-purpose scalar reference argument.
const dictionary & dict() const
The dictionary with all input data/specification.
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.
tmp< Field< Type > > evaluate(const expressions::exprString &expr, bool wantPointData=false)
Evaluate the expression and return the field.
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)