68#ifndef Foam_expressions_exprDriver_H
69#define Foam_expressions_exprDriver_H
129 static const Function1<Type>* getFunction1Ptr
132 const HashTable<refPtr<Function1<Type>>>& tbl,
231 const
bool gaussian = false
303 virtual label
size()
const
321 virtual scalar
deltaT() const;
348 tmp<Field<Type>>
getResult(
bool wantPointData=
false);
360 void resetDb(
const objectRegistry* obrPtr =
nullptr);
363 void resetDb(
const objectRegistry& db);
398 const
bool caching = false
421 inline void setArgument(
const scalar val)
noexcept;
464 template<
class ObjType>
514 bool wantPointData = false,
515 label expectedSize = -1
529 const
bool mandatory = true
537 virtual
unsigned parse
539 const std::
string& expr,
541 size_t len = std::
string::npos
551 bool wantPointData = false
560 bool wantPointData = false
610 bool mandatory = false
627 bool mandatory = false
637 const
word& keyword =
""
649#include "exprDriverI.H"
Generic templated field type that is much like a Foam::List except that it is expected to hold numeri...
Top level data entry class for use in dictionaries. Provides a mechanism to specify a variable as a c...
A HashTable similar to std::unordered_map.
A 1D array of objects of type <T>, where the size of the vector is known and used for subscript bound...
An Ostream is an abstract base class for all output systems (streams, files, token lists,...
The time value with time-stepping information, user-defined remapping, etc.
A 1D vector of objects of type <T>, where the size of the vector is known and can be used for subscri...
A list of keyword definitions, which are a keyword followed by a number of values (eg,...
Base driver for parsing (field) values.
bool isLocalVariable(const word &name, bool wantPointData=false, label expectedSize=-1) const
Test existence of a local variable.
virtual label size() const
The natural field size for the expression.
bool searchFiles() const noexcept
void fill_random(scalarField &field, label seed=0, const bool gaussian=false) const
Fill a random field.
bool cacheReadFields() const noexcept
bool debugParser() const noexcept
Read access to parser debug.
static point getPositionOfMaximum(const scalarField &vals, const pointField &locs)
Return the location of the max value.
Ostream & writeVariableStrings(Ostream &os, const word &keyword="") const
Write "variables".
exprResult result_
The result.
void removeContextObject(const word &name)
Remove the object from the context.
virtual exprResult & variable(const word &name)
Non-const access to the named variable (sub-classes only).
virtual void updateSpecialVariables(bool force=false)
Examine current variable values and update stored variables.
void clearResult()
Clear the result.
void addVariables(const expressions::exprString &expr, bool clear=true)
Add/set string expressions for variables.
bool hasContextObjects() const
True if any context fields are defined.
static expressions::exprString readExpression(const word &name, const dictionary &dict)
Read an expression string and do substitutions.
void writeFunctions(Ostream &os) const
Write scalar/vector Function1 entries in dictionary format.
exprResult & result() noexcept
Non-const access to expression result.
const TimeState * timeState() const noexcept
Reference to the current time-state (can be nullptr).
void addContextObject(const word &name, const regIOobject *)
Add the object to the context.
virtual label pointSize() const
The point field size for the expression.
void resetDb(const objectRegistry *obrPtr=nullptr)
Reset the objectRegistry (for functions).
tmp< Field< Type > > newField(const Type &val=pTraits< Type >::zero) const
Return a new field with the size().
bool searchRegistry() const noexcept
exprDriver(const exprDriver &)=delete
No copy construct.
HashTable< refPtr< Function1< scalar > > > scalarFuncs_
Function1 mappings/timelines (scalar), evaluated at the simulation time or with arbitrary scalars.
label setVariableStrings(const dictionary &dict, bool mandatory=false)
Read "variables" and assigns to the list of expression strings.
tmp< Field< Type > > getLocalVariable(const word &name, label expectSize, const bool mandatory=true) const
Retrieve local/global variable as a tmp field.
bool debugParser_
Request debugging for parser.
HashTable< refPtr< Function1< vector > > > vectorFuncs_
Function1 mappings/timelines (vector), evaluated at the simulation time or with arbitrary scalars.
Type getFunctionValue(const word &name, const scalar x) const
Evaluate named mapping for the given time/value. Zero for undefined/unknown.
bool allowShadowing_
Allow variable names to mask field names.
searchControls
Search/caching controls.
@ SEARCH_REGISTRY
Search registry before disk.
@ SEARCH_FILES
Search disk (eg, standalone app).
@ CACHE_READ_FIELDS
Cache fields read from disk.
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.
tmp< Field< Type > > evaluate(const expressions::exprString &expr, bool wantPointData=false)
Evaluate the expression and return the field.
bool prevIterIsOldTime_
Use value of previous iteration when oldTime is requested.
bool debugScanner_
Request debugging for scanner.
bool debugScanner() const noexcept
Read access to scanner debug.
const ObjType * cfindContextObject(const word &name) const
Find context field object of specified type.
virtual bool readDict(const dictionary &dict)
Read variables, tables etc.
static point getPositionOfMinimum(const scalarField &vals, const pointField &locs)
Return the location of the min value.
Type evaluateUniform(const expressions::exprString &expr, bool wantPointData=false)
Evaluate the expression and return a single value.
List< expressions::exprString > variableStrings_
Variable definitions, as read from a dictionary.
virtual scalar deltaT() const
The current deltaT value.
const objectRegistry * obrPtr_
Pointer to an object registry (for functions etc).
const TimeState * timeStatePtr_
Reference to the time-state.
const dictionary & dict_
The dictionary with all input data/specification.
HashTable< exprResult > variables_
The variables table.
searchControls searchCtrl_
Registry/disk/caching control.
scalar argValue() const noexcept
Get special-purpose scalar reference argument.
void setDebugging(bool scannerDebug, bool parserDebug)
Set the scanner/parser debug.
int resetStashedTokenId(int tokenId=0) const noexcept
Reset "look-behind" parsing context (mutable operation).
void setSearchBehaviour(enum searchControls search, const bool caching=false)
Set search behaviour, with additional CACHE_READ_FIELDS toggle on.
virtual exprResult getRemoteResult(const exprDriver &other) const
Get the result from another driver.
virtual bool update()
Update things.
void setArgument(const scalar val) noexcept
Set special-purpose scalar reference argument.
const contextObjectTableType & contextObjects() const noexcept
Read access to the object context.
const exprResult & result() const noexcept
Const access to expression result.
int stashedTokenId() const noexcept
Get "look-behind" parsing context (internal bookkeeping).
void evaluateVariable(const word &varName, const expressions::exprString &expr)
Evaluate the expression and save as the specified named variable.
void resetTimeReference(const TimeState *ts)
Reset the time-state reference.
virtual void clearVariables()
Clear temporary variables, reset from expression strings.
contextObjectTableType contextObjects_
Externally defined context fields.
bool isFunction(const word &name) const
Named mapping with given type exists.
const regIOobject * cfindContextIOobject(const word &name) const
Find named context field, if it exists.
virtual bool hasVariable(const word &name) const
True if named variable exists.
virtual unsigned parse(const std::string &expr, size_t pos=0, size_t len=std::string::npos)=0
Execute the parser.
static List< expressions::exprString > readVariableStrings(const dictionary &dict, const word &name="variables", bool mandatory=false)
Read the list of variable strings.
const dictionary & dict() const noexcept
The dictionary with all input data/specification.
void fillFunctionValues(Field< Type > &result, const word &name, const scalarField &input) const
Fill result with values remapped according to the named Function1.
virtual scalar timeValue() const
The current time value.
const word & getResultType() const noexcept
The result type as word - same as result().valueType().
HashTable< const regIOobject * > contextObjectTableType
Externally defined context fields.
bool setCaching(bool on) noexcept
Toggle CACHE_READ_FIELDS control.
tmp< Field< Type > > getResult(bool wantPointData=false)
Return the expression result as a tmp field.
int stashedTokenId_
Internal bookkeeping as "look-behind" parsing context.
void addUniformVariable(const word &name, const T &val)
Add a uniform variable from an outside caller.
tmp< Field< Type > > newPointField(const Type &val=pTraits< Type >::zero) const
Return a new field with the pointSize().
bool prevIterIsOldTime() const
scalar arg1Value_
Special-purpose scalar reference argument.
TypeName("exprDriver")
Runtime type information.
A polymorphic field/result from evaluating an expression.
A variant of Foam::string with expansion of dictionary variables into a comma-separated form.
Registry of regIOobjects.
A traits class, which is primarily used for primitives and vector-space.
A class for managing references or pointers (no reference counting).
regIOobject is an abstract class derived from IOobject to handle automatic object registration with t...
A class for managing temporary objects.
A class for handling words, derived from Foam::string.
A class representing the concept of 0 (zero) that can be used to avoid manipulating objects known to ...
OBJstream os(runTime.globalPath()/outputName)
A namespace for expression-related classes/traits etc.
dimensionedScalar pos(const dimensionedScalar &ds)
List< word > wordList
List of word.
Field< scalar > scalarField
Specialisation of Field<T> for scalar.
vector point
Point is a vector.
void rhs(fvMatrix< typename Expr::value_type > &m, const Expr &expression)
word name(const expressions::valueTypeCode typeCode)
A word representation of a valueTypeCode. Empty for expressions::valueTypeCode::INVALID.
vectorField pointField
pointField is a vectorField.
void T(FieldField< Field, Type > &f1, const FieldField< Field, Type > &f2)
fileName search(const word &file, const fileName &directory)
Recursively search the given directory for the file.
Specialisations of Field<T> for scalar, vector and tensor.