parseDriver Class Reference

Driver for generic primitive field expressions. More...

Inheritance diagram for parseDriver:
[legend]
Collaboration diagram for parseDriver:
[legend]

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< scalarFieldfield_rand (label seed=0, bool gaussian=false) const
 A uniform random field. More...
 
tmp< scalarFieldfield_randGaussian (label seed=0) const
 A Gaussian random field. More...
 
- Public Member Functions inherited from genericRagelLemonDriver
 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...
 
OstreamprintBuffer (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...
 
- Public Member Functions inherited from exprDriver
 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...
 
virtual label size () const
 The natural field size for the expression. More...
 
virtual label pointSize () const
 The point field size for the expression. More...
 
const TimeStatetimeState () 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 dictionarydict () const noexcept
 The dictionary with all input data/specification. More...
 
const exprResultresult () const noexcept
 Const access to expression result. More...
 
exprResultresult () 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 wordgetResultType () 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 exprResultvariable (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 regIOobjectcfindContextIOobject (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 contextObjectTableTypecontextObjects () const noexcept
 Read access to the object context. More...
 
contextObjectTableTypecontextObjects () 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...
 
virtual unsigned parse (const std::string &expr, size_t pos=0, size_t len=std::string::npos)=0
 Execute the parser. 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...
 
OstreamwriteVariableStrings (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...
 
- Protected Attributes inherited from genericRagelLemonDriver
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...
 
- Protected Attributes inherited from exprDriver
const dictionarydict_
 The dictionary with all input data/specification. More...
 
exprResult result_
 The result. More...
 
List< expressions::exprStringvariableStrings_
 Variable definitions, as read from a dictionary. More...
 
HashTable< exprResultvariables_
 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 TimeStatetimeStatePtr_
 Reference to the time-state. More...
 
const objectRegistryobrPtr_
 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

- Public Types inherited from genericRagelLemonDriver
typedef size_t location_type
 Type for linear addressing within parse content. More...
 
- Public Types inherited from exprDriver
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 Public Member Functions inherited from exprDriver
static expressions::exprString readExpression (const word &name, const dictionary &dict)
 Read an expression string and do substitutions. More...
 
static List< expressions::exprStringreadVariableStrings (const dictionary &dict, const word &name="variables", bool mandatory=false)
 Read the list of variable strings. More...
 
- Protected Member Functions inherited from exprDriver
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 exprResultvariable (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...
 
- Static Protected Member Functions inherited from exprDriver
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...
 

Detailed Description

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
Note
Use namespace debug switch fieldExpr for scanner (2), parser (4)
Source files

Definition at line 82 of file fieldExprDriver.H.

Constructor & Destructor Documentation

◆ parseDriver() [1/4]

parseDriver ( const parseDriver )
delete

◆ parseDriver() [2/4]

parseDriver ( const label  len = 1)
explicit

Default construct (size=1), or with specified size.

Definition at line 52 of file fieldExprDriver.C.

◆ parseDriver() [3/4]

parseDriver ( const label  len,
const dictionary dict 
)

Construct for specified size with given dictionary.

Definition at line 63 of file fieldExprDriver.C.

◆ parseDriver() [4/4]

parseDriver ( const label  len,
const parseDriver rhs,
const dictionary dict 
)

Construct for specified size, copy of driver context.

Definition at line 75 of file fieldExprDriver.C.

◆ ~parseDriver()

virtual ~parseDriver ( )
virtualdefault

Destructor.

Member Function Documentation

◆ ClassName()

ClassName ( "fieldExpr::driver"  )

◆ operator=()

void operator= ( const parseDriver )
delete

◆ size()

virtual label size ( ) const
inlinevirtual

The natural field size for the expression.

Reimplemented from exprDriver.

Definition at line 131 of file fieldExprDriver.H.

References parseDriver::size_.

Referenced by parseDriver::field_rand(), and parseDriver::getField().

Here is the caller graph for this function:

◆ pointSize()

virtual label pointSize ( ) const
inlinevirtual

The point field size for the expression.

Reimplemented from exprDriver.

Definition at line 137 of file fieldExprDriver.H.

References parseDriver::size_.

Referenced by parseDriver::getField().

Here is the caller graph for this function:

◆ parse()

unsigned parse ( const std::string &  expr,
size_t  pos = 0,
size_t  len = std::string::npos 
)
virtual

Execute the parser.

The return value currently has no meaning.

Implements exprDriver.

Definition at line 90 of file fieldExprDriver.C.

References parseDriver::parse(), Foam::pos(), and scanner::process().

Referenced by Foam::stringOps::evaluate(), and parseDriver::parse().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ setResult()

void setResult ( Field< Type > *  ptr,
bool  pointVal = false 
)
inline

Set result.

Definition at line 162 of file fieldExprDriver.H.

References exprDriver::result(), and exprResult::setResult().

Here is the call graph for this function:

◆ getField()

tmp< Field< Type > > getField ( const word fieldName) const

Return named field (variable) if available.

◆ field_rand()

Foam::tmp< Foam::scalarField > field_rand ( label  seed = 0,
bool  gaussian = false 
) const

A uniform random field.

Definition at line 33 of file fieldExprDriverFields.C.

References exprDriver::fill_random(), Time::New(), and parseDriver::size().

Referenced by parseDriver::field_randGaussian().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ field_randGaussian()

tmp< scalarField > field_randGaussian ( label  seed = 0) const
inline

A Gaussian random field.

Definition at line 181 of file fieldExprDriver.H.

References parseDriver::field_rand().

Here is the call graph for this function:

Member Data Documentation

◆ size_

label size_
protected

The field size.

Definition at line 92 of file fieldExprDriver.H.

Referenced by parseDriver::pointSize(), and parseDriver::size().


The documentation for this class was generated from the following files: