Go to the documentation of this file.
67 #ifndef expressions_exprDriver_H
68 #define expressions_exprDriver_H
121 static int getSearchControls(
const dictionary&
dict);
124 void resetFunctions(
const dictionary&
dict);
128 static const Function1<Type>* getFunction1Ptr
131 const HashTable<refPtr<Function1<Type>>>& tbl,
230 const
bool gaussian = false
318 virtual label
size()
const
336 virtual scalar
deltaT() const;
346 const exprResult&
result() const noexcept
352 exprResult&
result() noexcept
386 inline scalar
argValue() const noexcept;
413 const
bool caching = false
436 inline void setArgument(
const scalar val) noexcept;
479 template<
class ObjType>
529 bool wantPointData = false,
530 label expectedSize = -1
544 const
bool mandatory = true
552 virtual
unsigned parse
554 const std::
string& expr,
556 size_t len = std::
string::npos
566 bool wantPointData = false
575 bool wantPointData = false
625 bool mandatory = false
642 bool mandatory = false
652 const
word& keyword = ""
664 #include "exprDriverI.H"
virtual void updateSpecialVariables(bool force=false)
Examine current variable values and update stored variables.
contextObjectTableType contextObjects_
Externally defined context fields.
bool prevIterIsOldTime_
Use value of previous iteration when oldTime is requested.
searchControls searchCtrl_
Registry/disk/caching control.
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.
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.
virtual scalar deltaT() const
The current deltaT value.
const contextObjectTableType & contextObjects() const noexcept
Read access to the object context.
virtual scalar timeValue() const
The current time value.
A class for managing temporary objects.
bool setCaching(bool on) noexcept
Toggle CACHE_READ_FIELDS control.
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.
bool debugParser() const noexcept
Read access to parser debug.
HashTable< refPtr< Function1< vector > > > vectorFuncs_
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()
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.
const exprResult & result() const noexcept
Const access to expression result.
static point getPositionOfMaximum(const scalarField &vals, const pointField &locs)
Return the location of the max value.
bool debugScanner_
Request debugging for scanner.
const dictionary & dict_
The dictionary with all input data/specification.
const TimeState * timeState() const noexcept
Reference to the current time-state (can be nullptr)
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 allowShadowing_
Allow variable names to mask field names.
virtual label pointSize() const
The point field size for the expression.
Specialisations of Field<T> for scalar, vector and tensor.
Top level data entry class for use in dictionaries. Provides a mechanism to specify a variable as a c...
int stashedTokenId() const noexcept
Get "look-behind" parsing context (internal bookkeeping)
void setArgument(const scalar val) noexcept
Set special-purpose scalar reference argument.
List< word > wordList
A List of words.
static point getPositionOfMinimum(const scalarField &vals, const pointField &locs)
Return the location of the min value.
TypeName("exprDriver")
Runtime type information.
Registry of regIOobjects.
virtual bool hasVariable(const word &name) const
True if named variable exists.
scalar argValue() const noexcept
Get special-purpose scalar reference argument.
HashTable< const regIOobject * > contextObjectTableType
Externally defined context fields.
void resetTimeReference(const TimeState *ts)
Reset the time-state reference.
const ObjType * cfindContextObject(const word &name) const
Find context field object of specified type.
The time value with time-stepping information, user-defined remapping, etc.
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.
Cache fields read from disk.
A polymorphic field/result from evaluating an expression.
const word & valueType() const noexcept
Basic type for the field or single value.
searchControls
Search/caching controls.
label setVariableStrings(const dictionary &dict, bool mandatory=false)
Read "variables" and assigns to the list of expression strings.
Search disk (eg, standalone app)
static Type weightedAverage(const scalarField &weights, const Field< Type > &fld)
The (global) weighted average of a field, with stabilisation.
void writeFunctions(Ostream &os) const
Write scalar/vector Function1 entries in dictionary format.
void T(FieldField< Field, Type > &f1, const FieldField< Field, Type > &f2)
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 fillFunctionValues(Field< Type > &result, const word &name, const scalarField &input) const
Fill result with values remapped according to the named Function1.
void fill_random(scalarField &field, label seed=0, const bool gaussian=false) const
Fill a random field.
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.
int resetStashedTokenId(int tokenId=0) const noexcept
Reset "look-behind" parsing context (mutable operation)
virtual exprResult & variable(const word &name)
Non-const access to the named variable (sub-classes only)
A list of keyword definitions, which are a keyword followed by a number of values (eg,...
void setSearchBehaviour(enum searchControls search, const bool caching=false)
int stashedTokenId_
Internal bookkeeping as "look-behind" parsing context.
OBJstream os(runTime.globalPath()/outputName)
virtual void clearVariables()
Clear temporary variables, reset from expression strings.
List< expressions::exprString > variableStrings_
Variable definitions, as read from a dictionary.
const word & getResultType() const noexcept
The result type as word - same as result().valueType()
Type getFunctionValue(const word &name, const scalar x) const
regIOobject is an abstract class derived from IOobject to handle automatic object registration with t...
Search registry before disk.
void resetDb(const objectRegistry *obrPtr=nullptr)
Reset the objectRegistry (for functions)
HashTable< refPtr< Function1< scalar > > > scalarFuncs_
const regIOobject * cfindContextIOobject(const word &name) const
Find named context field, if it exists.
const dictionary & dict() const noexcept
The dictionary with all input data/specification.
bool searchRegistry() const noexcept
A traits class, which is primarily used for primitives.
tmp< Field< Type > > evaluate(const expressions::exprString &expr, bool wantPointData=false)
Evaluate the expression and return the field.
const objectRegistry * obrPtr_
Pointer to an object registry (for functions etc).
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...
fileName search(const word &file, const fileName &directory)
Recursively search the given directory for the file.
void addContextObject(const word &name, const regIOobject *)
Add the object to the context.
static Istream & input(Istream &is, IntRange< T > &range)
word name(const expressions::valueTypeCode typeCode)
A word representation of a valueTypeCode. Empty for INVALID.
bool searchFiles() const noexcept
virtual void evaluateVariableRemote(string remote, const word &varName, const expressions::exprString &expr)
void clearResult()
Clear the result.
virtual label size() const
The natural field size for the expression.
An Ostream is an abstract base class for all output systems (streams, files, token lists,...
void removeContextObject(const word &name)
Remove the object from the context.
bool isFunction(const word &name) const
Named mapping with given type exists.
static Type weightedSum(const scalarField &weights, const Field< Type > &fld)
The (global) weighted sum (integral) of a field.
bool cacheReadFields() const noexcept
virtual bool update()
Update things.
bool debugScanner() const noexcept
Read access to scanner debug.
exprResult result_
The result.
const TimeState * timeStatePtr_
Reference to the time-state.
A class for managing references or pointers (no reference counting)
A class representing the concept of 0 (zero) that can be used to avoid manipulating objects known to ...
exprResult & result() noexcept
Non-const access to expression result.
dimensionedScalar pos(const dimensionedScalar &ds)
bool hasContextObjects() const
True if any context fields are defined.