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
414 const
bool caching = false
437 inline void setArgument(
const scalar val)
noexcept;
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"
Info<< nl<< "Wrote faMesh in vtk format: "<< writer.output().name()<< nl;}{ vtk::lineWriter writer(aMesh.points(), aMesh.edges(), fileName(aMesh.mesh().time().globalPath()/"finiteArea-edges"));writer.writeGeometry();writer.beginCellData(4);writer.writeProcIDs();{ Field< scalar > fld(faMeshTools::flattenEdgeField(aMesh.magLe(), true))
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.
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
HashTable< refPtr< Function1< scalar > > > scalarFuncs_
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_
Type getFunctionValue(const word &name, const scalar x) const
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)
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.
static Type weightedAverage(const scalarField &weights, const Field< Type > &fld)
The (global) weighted average of a field, with stabilisation.
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)
static Type weightedSum(const scalarField &weights, const Field< Type > &fld)
The (global) weighted sum (integral) of a field.
void setSearchBehaviour(enum searchControls search, const bool caching=false)
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)
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.
A polymorphic field/result from evaluating an expression.
const word & valueType() const noexcept
Basic type for the field or single value.
Registry of regIOobjects.
A traits class, which is primarily used for primitives.
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)
dimensionedScalar pos(const dimensionedScalar &ds)
List< word > wordList
A List of words.
static Istream & input(Istream &is, IntRange< T > &range)
word name(const expressions::valueTypeCode typeCode)
A word representation of a valueTypeCode. Empty for INVALID.
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.
#define TypeName(TypeNameString)
Declare a ClassName() with extra virtual type info.