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 ()
 Default construct - uses size = 1. More...
 
 parseDriver (const label len)
 Construct 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)
 Construct for specified size with copy of driver context. More...
 
virtual ~parseDriver ()=default
 Destructor. More...
 
virtual label size () const
 The underlying field size for the expression. More...
 
virtual label pointSize () const
 The underlying 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 (bool cacheReadFields=false, bool searchInMemory=true, bool searchFiles=false, const dictionary &dict=dictionary::null)
 Null constructor, and null construct with search preferences. More...
 
 exprDriver (const exprDriver &)
 Copy construct. More...
 
 exprDriver (const dictionary &dict)
 Construct from a dictionary. More...
 
virtual ~exprDriver ()=default
 Destructor. More...
 
const dictionarydict () const
 The dictionary with all input data/specification. More...
 
virtual const exprResultresult () const
 Const access to expression result. More...
 
virtual exprResultresult ()
 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...
 
virtual word getResultType () const
 The result type as word - same as result().valueType() More...
 
scalar argValue () const
 Set special-purpose scalar reference argument. More...
 
int stashedTokenId () const
 Get "look-behind" parsing context (internal bookkeeping) More...
 
int resetStashedTokenId (int tokenId=0) const
 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...
 
void setSearchBehaviour (bool cacheReadFields, bool searchInMemory, bool searchFiles)
 Set search behaviour. More...
 
void setSearchBehaviour (const exprDriver &rhs)
 Set search behaviour to be identical to rhs. More...
 
bool debugScanner () const
 Read access to scanner debug. More...
 
bool debugParser () const
 Read access to parser debug. More...
 
bool cacheReadFields () const
 
bool searchInMemory () const
 
bool searchFiles () const
 
bool prevIterIsOldTime () const
 
virtual void clearVariables ()
 Clear temporary variables and resets from expression strings. More...
 
virtual void setArgument (const scalar val)
 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...
 
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...
 
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 >
Foam::tmp< Foam::Field< Type > > newField (const Type &val) const
 
template<class Type >
Foam::tmp< Foam::Field< Type > > newPointField (const Type &val) const
 

Protected Member Functions

 parseDriver (const parseDriver &)=delete
 
void operator= (const parseDriver &)=delete
 
- Protected Member Functions inherited from exprDriver
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...
 
void operator= (const exprDriver &)=delete
 No copy assignment. More...
 

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...
 
scalar arg1Value_
 Special-purpose scalar reference argument. 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...
 
bool cacheReadFields_
 Keep fields read from disc in memory. More...
 
bool searchInMemory_
 Search in registry before looking on disk. More...
 
bool searchFiles_
 Search on disk (eg, for a standalone application) More...
 

Additional Inherited Members

- Public Types inherited from genericRagelLemonDriver
typedef size_t location_type
 Type for linear addressing within parse content. 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...
 
- Static Protected Member Functions inherited from exprDriver
template<typename TableType >
static bool readTable (const word &name, const dictionary &dict, HashTable< TableType > &tbl, bool clear=true)
 Read an interpolation table. More...
 
template<class TableType >
static void writeTable (Ostream &os, const word &name, const HashTable< TableType > &tbl)
 Write an interpolation table. 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...
 

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/5]

parseDriver ( const parseDriver )
protecteddelete

◆ parseDriver() [2/5]

Default construct - uses size = 1.

Definition at line 52 of file fieldExprDriver.C.

◆ parseDriver() [3/5]

parseDriver ( const label  len)
explicit

Construct with specified size.

Definition at line 59 of file fieldExprDriver.C.

◆ parseDriver() [4/5]

parseDriver ( const label  len,
const dictionary dict 
)

Construct for specified size with given dictionary.

Definition at line 70 of file fieldExprDriver.C.

◆ parseDriver() [5/5]

parseDriver ( const label  len,
const parseDriver rhs 
)

Construct for specified size with copy of driver context.

Definition at line 82 of file fieldExprDriver.C.

◆ ~parseDriver()

virtual ~parseDriver ( )
virtualdefault

Destructor.

Member Function Documentation

◆ operator=()

void operator= ( const parseDriver )
protecteddelete

◆ ClassName()

ClassName ( "fieldExpr::driver"  )

◆ size()

virtual label size ( ) const
inlinevirtual

The underlying field size for the expression.

Reimplemented from exprDriver.

Definition at line 130 of file fieldExprDriver.H.

References parseDriver::size_.

◆ pointSize()

virtual label pointSize ( ) const
inlinevirtual

The underlying point field size for the expression.

Reimplemented from exprDriver.

Definition at line 136 of file fieldExprDriver.H.

References parseDriver::size_.

◆ 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 96 of file fieldExprDriver.C.

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

Referenced by Foam::stringOps::evaluate().

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 161 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 34 of file fieldExprDriverFields.C.

References Foam::New().

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: