Driver for generic primitive field expressions. More...
Public Member Functions | |
ClassName ("fieldExpr::driver") | |
parseDriver (const parseDriver &)=delete | |
void | operator= (const parseDriver &)=delete |
parseDriver (const label len=1) | |
Default construct (size=1), or with specified size. More... | |
parseDriver (const label len, const dictionary &dict) | |
Construct for specified size with given dictionary. More... | |
parseDriver (const label len, const parseDriver &rhs, const dictionary &dict) | |
Construct for specified size, copy of driver context. More... | |
virtual | ~parseDriver ()=default |
Destructor. More... | |
virtual label | size () const |
The natural field size for the expression. More... | |
virtual label | pointSize () const |
The point field size for the expression. More... | |
virtual unsigned | parse (const std::string &expr, size_t pos=0, size_t len=std::string::npos) |
Execute the parser. More... | |
template<class Type > | |
void | setResult (Field< Type > *ptr, bool pointVal=false) |
Set result. More... | |
template<class Type > | |
tmp< Field< Type > > | getField (const word &fieldName) const |
Return named field (variable) if available. More... | |
tmp< scalarField > | field_rand (label seed=0, bool gaussian=false) const |
A uniform random field. More... | |
tmp< scalarField > | field_randGaussian (label seed=0) const |
A Gaussian random field. More... | |
![]() | |
genericRagelLemonDriver () | |
Construct null. More... | |
genericRagelLemonDriver (const genericRagelLemonDriver &rhs)=default | |
Copy construct. More... | |
genericRagelLemonDriver (genericRagelLemonDriver &&rhs)=default | |
Move construct. More... | |
virtual | ~genericRagelLemonDriver ()=default |
Destructor. More... | |
void | clear () |
Reset references. More... | |
const std::string & | content () const |
Get reference to the input buffer content. More... | |
void | content (const std::string &s, size_t pos=0, size_t len=std::string::npos) |
std::string::const_iterator | cbegin () const |
Iterator to begin of content (sub)string. More... | |
std::string::const_iterator | cend () const |
Iterator to end of content (sub)string. More... | |
size_t | parsePosition () const |
The relative parse position with the content (sub)string. More... | |
size_t & | parsePosition () |
The relative parse position with the content (sub)string. More... | |
Ostream & | printBuffer (Ostream &os) const |
Output the input buffer string content. More... | |
void | reportFatal (const std::string &msg) const |
Report FatalError. More... | |
void | reportFatal (const std::string &msg, size_t pos) const |
Report FatalError at parser position. More... | |
![]() | |
TypeName ("exprDriver") | |
Runtime type information. More... | |
exprDriver (const exprDriver &)=delete | |
No copy construct. More... | |
void | operator= (const exprDriver &)=delete |
No copy assignment. More... | |
exprDriver (enum searchControls search=searchControls::DEFAULT_SEARCH, const dictionary &dict=dictionary::null) | |
Default construct, and default construct with search preferences. More... | |
exprDriver (const exprDriver &rhs, const dictionary &dict) | |
Copy construct with new dictionary reference. More... | |
exprDriver (const dictionary &dict) | |
Construct from a dictionary. More... | |
virtual | ~exprDriver ()=default |
Destructor. More... | |
const TimeState * | timeState () const noexcept |
Reference to the current time-state (can be nullptr) More... | |
virtual scalar | timeValue () const |
The current time value. More... | |
virtual scalar | deltaT () const |
The current deltaT value. More... | |
const dictionary & | dict () const noexcept |
The dictionary with all input data/specification. More... | |
const exprResult & | result () const noexcept |
Const access to expression result. More... | |
exprResult & | result () noexcept |
Non-const access to expression result. More... | |
void | clearResult () |
Clear the result. More... | |
template<class Type > | |
tmp< Field< Type > > | getResult (bool wantPointData=false) |
Return the expression result as a tmp field. More... | |
const word & | getResultType () const noexcept |
The result type as word - same as result().valueType() More... | |
void | resetDb (const objectRegistry *obrPtr=nullptr) |
Reset the objectRegistry (for functions) More... | |
void | resetDb (const objectRegistry &db) |
Reset the objectRegistry (for functions) More... | |
scalar | argValue () const noexcept |
Get special-purpose scalar reference argument. More... | |
int | stashedTokenId () const noexcept |
Get "look-behind" parsing context (internal bookkeeping) More... | |
int | resetStashedTokenId (int tokenId=0) const noexcept |
Reset "look-behind" parsing context (mutable operation) More... | |
void | setDebugging (bool scannerDebug, bool parserDebug) |
Set the scanner/parser debug. More... | |
void | setDebugging (const exprDriver &rhs) |
Set the scanner/parser debug to match the input. More... | |
bool | setCaching (bool on) noexcept |
Toggle CACHE_READ_FIELDS control. More... | |
void | setSearchBehaviour (enum searchControls search, const bool caching=false) |
void | setSearchBehaviour (const exprDriver &rhs) |
Set search behaviour to be identical to rhs. More... | |
bool | debugScanner () const noexcept |
Read access to scanner debug. More... | |
bool | debugParser () const noexcept |
Read access to parser debug. More... | |
bool | prevIterIsOldTime () const |
virtual void | clearVariables () |
Clear temporary variables, reset from expression strings. More... | |
void | setArgument (const scalar val) noexcept |
Set special-purpose scalar reference argument. More... | |
virtual bool | hasVariable (const word &name) const |
True if named variable exists. More... | |
virtual const exprResult & | variable (const word &name) const |
Return const-access to the named variable. More... | |
void | addVariables (const expressions::exprString &expr, bool clear=true) |
Add/set string expressions for variables. More... | |
void | addVariables (const UList< expressions::exprString > &list, bool clear=true) |
Add/set string expressions for variables. More... | |
template<class T > | |
void | addUniformVariable (const word &name, const T &val) |
Add a uniform variable from an outside caller. More... | |
bool | hasContextObjects () const |
True if any context fields are defined. More... | |
const regIOobject * | cfindContextIOobject (const word &name) const |
Find named context field, if it exists. More... | |
template<class ObjType > | |
const ObjType * | cfindContextObject (const word &name) const |
Find context field object of specified type. More... | |
void | addContextObject (const word &name, const regIOobject *) |
Add the object to the context. More... | |
void | addContextObject (const regIOobject *) |
Add the object to the context. More... | |
void | removeContextObject (const word &name) |
Remove the object from the context. More... | |
void | removeContextObject (const regIOobject *) |
Remove the object from the context. More... | |
const contextObjectTableType & | contextObjects () const noexcept |
Read access to the object context. More... | |
contextObjectTableType & | contextObjects () noexcept |
Write access to the object context. More... | |
template<class Type > | |
bool | isFunction (const word &name) const |
Named mapping with given type exists. More... | |
template<class Type > | |
Type | getFunctionValue (const word &name, const scalar x) const |
template<class Type > | |
void | fillFunctionValues (Field< Type > &result, const word &name, const scalarField &input) const |
Fill result with values remapped according to the named Function1. More... | |
template<class T > | |
bool | isLocalVariable (const word &name, bool wantPointData=false, label expectedSize=-1) const |
Test existence of a local variable. More... | |
template<class Type > | |
tmp< Field< Type > > | getLocalVariable (const word &name, label expectSize, const bool mandatory=true) const |
Retrieve local/global variable as a tmp field. More... | |
template<class Type > | |
tmp< Field< Type > > | evaluate (const expressions::exprString &expr, bool wantPointData=false) |
Evaluate the expression and return the field. More... | |
template<class Type > | |
Type | evaluateUniform (const expressions::exprString &expr, bool wantPointData=false) |
Evaluate the expression and return a single value. More... | |
void | evaluateVariable (const word &varName, const expressions::exprString &expr) |
virtual void | evaluateVariableRemote (string remote, const word &varName, const expressions::exprString &expr) |
template<class Type > | |
tmp< Field< Type > > | newField (const Type &val=pTraits< Type >::zero) const |
Return a new field with the size() More... | |
template<class Type > | |
tmp< Field< Type > > | newPointField (const Type &val=pTraits< Type >::zero) const |
Return a new field with the pointSize() More... | |
expressions::exprString | readExpression (const word &name) |
virtual bool | readDict (const dictionary &dict) |
Read variables, tables etc. More... | |
label | setVariableStrings (const dictionary &dict, bool mandatory=false) |
Read "variables" and assigns to the list of expression strings. More... | |
Ostream & | writeVariableStrings (Ostream &os, const word &keyword="") const |
Write "variables". More... | |
template<class Type > | |
void | addUniformVariable (const word &name, const Type &val) |
template<class Type > | |
Foam::tmp< Foam::Field< Type > > | evaluate (const expressions::exprString &expr, bool wantPointData) |
template<class Type > | |
Foam::tmp< Foam::Field< Type > > | getResult (bool wantPointData) |
template<class Type > | |
const Foam::Function1< Type > * | getFunction1Ptr (const word &name, const HashTable< refPtr< Function1< Type >>> &tbl, wordList *listFailure) |
template<class Type > | |
Foam::tmp< Foam::Field< Type > > | newField (const Type &val) const |
template<class Type > | |
Foam::tmp< Foam::Field< Type > > | newPointField (const Type &val) const |
Protected Attributes | |
label | size_ |
The field size. More... | |
![]() | |
std::reference_wrapper< const std::string > | content_ |
Reference to the input string. More... | |
size_t | start_ |
Start position within input string. More... | |
size_t | length_ |
Length of input (sub)string. More... | |
size_t | position_ |
The last known parser position. More... | |
![]() | |
const dictionary & | dict_ |
The dictionary with all input data/specification. More... | |
exprResult | result_ |
The result. More... | |
List< expressions::exprString > | variableStrings_ |
Variable definitions, as read from a dictionary. More... | |
HashTable< exprResult > | variables_ |
The variables table. More... | |
HashTable< refPtr< Function1< scalar > > > | scalarFuncs_ |
HashTable< refPtr< Function1< vector > > > | vectorFuncs_ |
contextObjectTableType | contextObjects_ |
Externally defined context fields. More... | |
scalar | arg1Value_ |
Special-purpose scalar reference argument. More... | |
const TimeState * | timeStatePtr_ |
Reference to the time-state. More... | |
const objectRegistry * | obrPtr_ |
Pointer to an object registry (for functions etc). More... | |
int | stashedTokenId_ |
Internal bookkeeping as "look-behind" parsing context. More... | |
bool | debugScanner_ |
Request debugging for scanner. More... | |
bool | debugParser_ |
Request debugging for parser. More... | |
bool | allowShadowing_ |
Allow variable names to mask field names. More... | |
bool | prevIterIsOldTime_ |
Use value of previous iteration when oldTime is requested. More... | |
searchControls | searchCtrl_ |
Registry/disk/caching control. More... | |
Additional Inherited Members | |
![]() | |
typedef size_t | location_type |
Type for linear addressing within parse content. More... | |
![]() | |
enum | searchControls { NO_SEARCH = 0, SEARCH_REGISTRY = 1, SEARCH_FILES = 2, CACHE_READ_FIELDS = 4, DEFAULT_SEARCH = (SEARCH_REGISTRY) } |
Search/caching controls. More... | |
typedef HashTable< const regIOobject * > | contextObjectTableType |
Externally defined context fields. More... | |
![]() | |
static expressions::exprString | readExpression (const word &name, const dictionary &dict) |
Read an expression string and do substitutions. More... | |
static List< expressions::exprString > | readVariableStrings (const dictionary &dict, const word &name="variables", bool mandatory=false) |
Read the list of variable strings. More... | |
![]() | |
bool | searchRegistry () const noexcept |
bool | searchFiles () const noexcept |
bool | cacheReadFields () const noexcept |
void | resetTimeReference (const TimeState *ts) |
Reset the time-state reference. More... | |
void | resetTimeReference (const TimeState &ts) |
Reset the time-state reference. More... | |
void | writeFunctions (Ostream &os) const |
Write scalar/vector Function1 entries in dictionary format. More... | |
virtual exprResult & | variable (const word &name) |
Non-const access to the named variable (sub-classes only) More... | |
void | fill_random (scalarField &field, label seed=0, const bool gaussian=false) const |
Fill a random field. More... | |
virtual bool | update () |
Update things. More... | |
virtual void | updateSpecialVariables (bool force=false) |
Examine current variable values and update stored variables. More... | |
virtual exprResult | getRemoteResult (const exprDriver &other) const |
Get the result from another driver. More... | |
![]() | |
template<class Type > | |
static Type | weightedAverage (const scalarField &weights, const Field< Type > &fld) |
The (global) weighted average of a field, with stabilisation. More... | |
template<class Type > | |
static Type | weightedSum (const scalarField &weights, const Field< Type > &fld) |
The (global) weighted sum (integral) of a field. More... | |
static point | getPositionOfMinimum (const scalarField &vals, const pointField &locs) |
Return the location of the min value. More... | |
static point | getPositionOfMaximum (const scalarField &vals, const pointField &locs) |
Return the location of the max value. More... | |
Driver for generic primitive field expressions.
In addition to the standard mathematical functions, operations and logical and relational operations, the volume expression support the following driver-specific functions:
Functions
Function | Description | Number of arguments | |
---|---|---|---|
rand | Random field | 0/1 |
fieldExpr
for scanner (2), parser (4)Definition at line 82 of file fieldExprDriver.H.
|
delete |
|
explicit |
Default construct (size=1), or with specified size.
Definition at line 53 of file fieldExprDriver.C.
parseDriver | ( | const label | len, |
const dictionary & | dict | ||
) |
Construct for specified size with given dictionary.
Definition at line 64 of file fieldExprDriver.C.
parseDriver | ( | const label | len, |
const parseDriver & | rhs, | ||
const dictionary & | dict | ||
) |
Construct for specified size, copy of driver context.
Definition at line 76 of file fieldExprDriver.C.
|
virtualdefault |
Destructor.
ClassName | ( | "fieldExpr::driver" | ) |
|
delete |
|
inlinevirtual |
The natural field size for the expression.
Reimplemented from exprDriver.
Definition at line 131 of file fieldExprDriver.H.
References parseDriver::size_.
|
inlinevirtual |
The point field size for the expression.
Reimplemented from exprDriver.
Definition at line 137 of file fieldExprDriver.H.
References parseDriver::size_.
|
virtual |
Execute the parser.
The return value currently has no meaning.
Implements exprDriver.
Definition at line 91 of file fieldExprDriver.C.
References Foam::pos(), and scanner::process().
Referenced by Foam::stringOps::evaluate().
Set result.
Definition at line 162 of file fieldExprDriver.H.
References exprDriver::result(), and exprResult::setResult().
Return named field (variable) if available.
Foam::tmp< Foam::scalarField > field_rand | ( | label | seed = 0 , |
bool | gaussian = false |
||
) | const |
A uniform random field.
Definition at line 34 of file fieldExprDriverFields.C.
References Foam::New().
Referenced by parseDriver::field_randGaussian().
|
inline |
A Gaussian random field.
Definition at line 181 of file fieldExprDriver.H.
References parseDriver::field_rand().
|
protected |
The field size.
Definition at line 92 of file fieldExprDriver.H.
Referenced by parseDriver::pointSize(), and parseDriver::size().