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