exprDriver Class Referenceabstract

Base driver for parsing (field) values. More...

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

Public Types

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...
 

Public Member Functions

 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
 

Static Public Member Functions

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

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

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...
 

Protected Attributes

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...
 

Detailed Description

Base driver for parsing (field) values.

Largely based on code and ideas from swak4foam

Properties

Property Description Required Default
variables List of variables for expressions no ()
functions<scalar> Dictionary of scalar Function1 no {}
functions<vector> Dictionary of vector Function1 no {}
allowShadowing Allow variables to shadow field names no false

Debug Properties

Property Description Required Default
debug.driver Debug level (int) for base driver no
debug.scanner Add debug for scanner no false
debug.parser Add debug for parser no false

The functions<scalar> and functions<vector> entries are dictionaries of Foam::Function1 definitions that can either be used to establish a time-varying quantity, to remap a field of scalar values, or both.

Source files

Definition at line 140 of file exprDriver.H.

Member Typedef Documentation

◆ contextObjectTableType

Externally defined context fields.

Definition at line 158 of file exprDriver.H.

Member Enumeration Documentation

◆ searchControls

Search/caching controls.

Enumerator
NO_SEARCH 
SEARCH_REGISTRY 

Search registry before disk.

SEARCH_FILES 

Search disk (eg, standalone app)

CACHE_READ_FIELDS 

Cache fields read from disk.

DEFAULT_SEARCH 

Definition at line 147 of file exprDriver.H.

Constructor & Destructor Documentation

◆ exprDriver() [1/4]

exprDriver ( const exprDriver )
delete

No copy construct.

◆ exprDriver() [2/4]

exprDriver ( enum searchControls  search = searchControls::DEFAULT_SEARCH,
const dictionary dict = dictionary::null 
)
explicit

Default construct, and default construct with search preferences.

Definition at line 173 of file exprDriver.C.

◆ exprDriver() [3/4]

exprDriver ( const exprDriver rhs,
const dictionary dict 
)

Copy construct with new dictionary reference.

Definition at line 200 of file exprDriver.C.

References exprDriver::dict_, exprDriver::scalarFuncs_, Foam::shallowCloneFunctions(), and exprDriver::vectorFuncs_.

Here is the call graph for this function:

◆ exprDriver() [4/4]

exprDriver ( const dictionary dict)
explicit

Construct from a dictionary.

Definition at line 237 of file exprDriver.C.

References exprDriver::dict(), and exprDriver::readDict().

Here is the call graph for this function:

◆ ~exprDriver()

virtual ~exprDriver ( )
virtualdefault

Destructor.

Member Function Documentation

◆ searchRegistry()

bool searchRegistry ( ) const
inlineprotectednoexcept

Definition at line 144 of file exprDriverI.H.

◆ searchFiles()

bool searchFiles ( ) const
inlineprotectednoexcept

Definition at line 150 of file exprDriverI.H.

◆ cacheReadFields()

bool cacheReadFields ( ) const
inlineprotectednoexcept

Definition at line 156 of file exprDriverI.H.

◆ resetTimeReference() [1/2]

void resetTimeReference ( const TimeState ts)
protected

Reset the time-state reference.

Definition at line 130 of file exprDriver.C.

Referenced by parseDriver::parseDriver().

Here is the caller graph for this function:

◆ resetTimeReference() [2/2]

void resetTimeReference ( const TimeState ts)
protected

Reset the time-state reference.

Definition at line 136 of file exprDriver.C.

◆ writeFunctions()

void writeFunctions ( Ostream os) const
protected

Write scalar/vector Function1 entries in dictionary format.

Definition at line 221 of file exprDriverFunctions.C.

References os().

Here is the call graph for this function:

◆ variable() [1/2]

Foam::expressions::exprResult & variable ( const word name)
inlineprotectedvirtual

Non-const access to the named variable (sub-classes only)

Reimplemented in fvExprDriver.

Definition at line 63 of file exprDriverI.H.

References Foam::name().

Referenced by parseDriver::getField().

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

◆ fill_random()

void fill_random ( scalarField field,
label  seed = 0,
const bool  gaussian = false 
) const
protected

Fill a random field.

Parameters
fieldthe field to populate
seedthe seed value. If zero or negative, use as an offset to the current timeIndex (if a time-state is available)
gaussiangenerate a Gaussian distribution

Definition at line 35 of file exprDriverFields.C.

References Foam::FieldOps::assign(), field(), TimeState::timeIndex(), and exprDriver::timeStatePtr_.

Referenced by parseDriver::field_rand().

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

◆ weightedAverage()

Type weightedAverage ( const scalarField weights,
const Field< Type > &  fld 
)
staticprotected

The (global) weighted average of a field, with stabilisation.

Definition at line 34 of file exprDriverTemplates.C.

References fld(), Foam::gSum(), Foam::isNull(), Foam::mag(), n, Foam::returnReduce(), s(), and Foam::Zero.

Referenced by parseDriver::areaAverage(), and parseDriver::volAverage().

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

◆ weightedSum()

Type weightedSum ( const scalarField weights,
const Field< Type > &  fld 
)
staticprotected

The (global) weighted sum (integral) of a field.

Definition at line 70 of file exprDriverTemplates.C.

References fld(), Foam::gSum(), and Foam::isNull().

Referenced by parseDriver::areaSum(), and parseDriver::volSum().

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

◆ getPositionOfMinimum()

Foam::point getPositionOfMinimum ( const scalarField vals,
const pointField locs 
)
staticprotected

Return the location of the min value.

Definition at line 67 of file exprDriverFields.C.

References Foam::FieldOps::findMinData().

Here is the call graph for this function:

◆ getPositionOfMaximum()

Foam::point getPositionOfMaximum ( const scalarField vals,
const pointField locs 
)
staticprotected

Return the location of the max value.

Definition at line 77 of file exprDriverFields.C.

References Foam::FieldOps::findMaxData().

Here is the call graph for this function:

◆ update()

bool update ( )
protectedvirtual

Update things.

Definition at line 321 of file exprDriver.C.

Referenced by fvExprDriver::prepareData().

Here is the caller graph for this function:

◆ updateSpecialVariables()

void updateSpecialVariables ( bool  force = false)
protectedvirtual

Examine current variable values and update stored variables.

Reimplemented in fvExprDriver.

Definition at line 327 of file exprDriver.C.

◆ getRemoteResult()

Foam::expressions::exprResult getRemoteResult ( const exprDriver other) const
protectedvirtual

Get the result from another driver.

Override to allow mapping

Definition at line 368 of file exprDriver.C.

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

Here is the call graph for this function:

◆ TypeName()

TypeName ( "exprDriver"  )

Runtime type information.

◆ operator=()

void operator= ( const exprDriver )
delete

No copy assignment.

◆ size()

virtual label size ( ) const
inlinevirtual

The natural field size for the expression.

Reimplemented in parseDriver, parseDriver, parseDriver, and fvExprDriver.

Definition at line 363 of file exprDriver.H.

◆ pointSize()

virtual label pointSize ( ) const
inlinevirtual

The point field size for the expression.

Reimplemented in parseDriver, parseDriver, parseDriver, and fvExprDriver.

Definition at line 369 of file exprDriver.H.

◆ timeState()

const Foam::TimeState * timeState ( ) const
noexcept

Reference to the current time-state (can be nullptr)

Definition at line 254 of file exprDriver.C.

◆ timeValue()

Foam::scalar timeValue ( ) const
virtual

The current time value.

Definition at line 268 of file exprDriver.C.

◆ deltaT()

Foam::scalar deltaT ( ) const
virtual

The current deltaT value.

Definition at line 282 of file exprDriver.C.

◆ dict()

const dictionary & dict ( ) const
inlinenoexcept

The dictionary with all input data/specification.

Definition at line 385 of file exprDriver.H.

References exprDriver::dict_.

Referenced by exprDriver::exprDriver(), fvExprDriver::fvExprDriver(), fvExprDriver::New(), and exprDriver::readExpression().

Here is the caller graph for this function:

◆ result() [1/2]

const exprResult & result ( ) const
inlinenoexcept

Const access to expression result.

Definition at line 391 of file exprDriver.H.

References exprDriver::result_.

Referenced by Foam::stringOps::evaluate(), exprDriver::getRemoteResult(), fvExprDriver::isGlobalVariable(), parseDriver::setInternalFieldResult(), and parseDriver::setResult().

Here is the caller graph for this function:

◆ result() [2/2]

exprResult & result ( )
inlinenoexcept

Non-const access to expression result.

Definition at line 397 of file exprDriver.H.

References exprDriver::result_.

◆ clearResult()

void clearResult ( )

Clear the result.

Definition at line 315 of file exprDriver.C.

◆ getResult() [1/2]

tmp< Field< Type > > getResult ( bool  wantPointData = false)

Return the expression result as a tmp field.

This also clears the result and associated memory.

◆ getResultType()

const word & getResultType ( ) const
inlinenoexcept

The result type as word - same as result().valueType()

Definition at line 411 of file exprDriver.H.

References exprDriver::result_, and exprResult::valueType().

Here is the call graph for this function:

◆ resetDb() [1/2]

void resetDb ( const objectRegistry obrPtr = nullptr)

Reset the objectRegistry (for functions)

Definition at line 142 of file exprDriver.C.

References forAllIters.

Referenced by parseDriver::parseDriver().

Here is the caller graph for this function:

◆ resetDb() [2/2]

void resetDb ( const objectRegistry db)

Reset the objectRegistry (for functions)

Definition at line 165 of file exprDriver.C.

◆ argValue()

Foam::scalar argValue ( ) const
inlinenoexcept

Get special-purpose scalar reference argument.

Typically available as arg() in an expression and may correspond to table index, time value etc.

Definition at line 37 of file exprDriverI.H.

References exprDriver::arg1Value_.

◆ stashedTokenId()

int stashedTokenId ( ) const
inlinenoexcept

Get "look-behind" parsing context (internal bookkeeping)

Definition at line 115 of file exprDriverI.H.

◆ resetStashedTokenId()

int resetStashedTokenId ( int  tokenId = 0) const
inlinenoexcept

Reset "look-behind" parsing context (mutable operation)

Returns
the previous value

Definition at line 121 of file exprDriverI.H.

◆ setDebugging() [1/2]

void setDebugging ( bool  scannerDebug,
bool  parserDebug 
)

Set the scanner/parser debug.

Definition at line 492 of file exprDriver.C.

◆ setDebugging() [2/2]

void setDebugging ( const exprDriver rhs)

Set the scanner/parser debug to match the input.

Definition at line 503 of file exprDriver.C.

References exprDriver::debugParser_, and exprDriver::debugScanner_.

◆ setCaching()

bool setCaching ( bool  on)
noexcept

Toggle CACHE_READ_FIELDS control.

Definition at line 513 of file exprDriver.C.

◆ setSearchBehaviour() [1/2]

void setSearchBehaviour ( enum searchControls  search,
const bool  caching = false 
)

Set search behaviour, with additional CACHE_READ_FIELDS toggle on

Definition at line 541 of file exprDriver.C.

References Foam::Info, Foam::nl, and Foam::search().

Here is the call graph for this function:

◆ setSearchBehaviour() [2/2]

void setSearchBehaviour ( const exprDriver rhs)

Set search behaviour to be identical to rhs.

Definition at line 569 of file exprDriver.C.

References exprDriver::searchCtrl_.

◆ debugScanner()

bool debugScanner ( ) const
inlinenoexcept

Read access to scanner debug.

Definition at line 132 of file exprDriverI.H.

◆ debugParser()

bool debugParser ( ) const
inlinenoexcept

Read access to parser debug.

Definition at line 138 of file exprDriverI.H.

◆ prevIterIsOldTime()

bool prevIterIsOldTime ( ) const
inline

Definition at line 470 of file exprDriver.H.

References exprDriver::prevIterIsOldTime_.

◆ clearVariables()

void clearVariables ( )
virtual

Clear temporary variables, reset from expression strings.

Reimplemented in fvExprDriver.

Definition at line 331 of file exprDriver.C.

◆ setArgument()

void setArgument ( const scalar  val)
inlinenoexcept

Set special-purpose scalar reference argument.

Typically available as arg() in an expression and may corrspond to table index, time value etc.

Definition at line 31 of file exprDriverI.H.

◆ hasVariable()

bool hasVariable ( const word name) const
inlinevirtual

True if named variable exists.

Reimplemented in fvExprDriver.

Definition at line 43 of file exprDriverI.H.

References Foam::name().

Referenced by parseDriver::getField().

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

◆ variable() [2/2]

const Foam::expressions::exprResult & variable ( const word name) const
inlinevirtual

Return const-access to the named variable.

Reimplemented in fvExprDriver.

Definition at line 53 of file exprDriverI.H.

References Foam::name().

Here is the call graph for this function:

◆ addVariables() [1/2]

void addVariables ( const expressions::exprString expr,
bool  clear = true 
)

Add/set string expressions for variables.

Can include multiple definitions inline

Parameters
clearRemove previously defined variables

Definition at line 378 of file exprDriver.C.

References clear(), Foam::exit(), Foam::FatalError, FatalErrorInFunction, Foam::FatalIOError, FatalIOErrorInFunction, Foam::stringOps::inplaceTrim(), Foam::nl, Foam::stringOps::trim(), and kkLOmega::validate().

Here is the call graph for this function:

◆ addVariables() [2/2]

void addVariables ( const UList< expressions::exprString > &  list,
bool  clear = true 
)

Add/set string expressions for variables.

Can include multiple definitions inline

Parameters
clearRemove previously defined variables

Definition at line 474 of file exprDriver.C.

References clear().

Here is the call graph for this function:

◆ addUniformVariable() [1/2]

void addUniformVariable ( const word name,
const T val 
)
inline

Add a uniform variable from an outside caller.

◆ hasContextObjects()

bool hasContextObjects ( ) const
inline

True if any context fields are defined.

Definition at line 30 of file exprDriverContextI.H.

References exprDriver::contextObjects_, and HashTable< T, Key, Hash >::empty().

Here is the call graph for this function:

◆ cfindContextIOobject()

const Foam::regIOobject * cfindContextIOobject ( const word name) const
inline

Find named context field, if it exists.

Definition at line 37 of file exprDriverContextI.H.

References Foam::name().

Referenced by fvExprDriver::foundField(), parseDriver::getField(), parseDriver::patchInternalField(), parseDriver::patchNeighbourField(), and parseDriver::patchNormalField().

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

◆ cfindContextObject()

const ObjType * cfindContextObject ( const word name) const

Find context field object of specified type.

Returns
nullptr if not found

Definition at line 113 of file exprDriverContextI.H.

References Foam::name().

Here is the call graph for this function:

◆ addContextObject() [1/2]

void addContextObject ( const word name,
const regIOobject objptr 
)
inline

Add the object to the context.

Definition at line 47 of file exprDriverContextI.H.

References Foam::name().

Here is the call graph for this function:

◆ addContextObject() [2/2]

void addContextObject ( const regIOobject objptr)
inline

Add the object to the context.

Definition at line 64 of file exprDriverContextI.H.

References IOobject::name().

Here is the call graph for this function:

◆ removeContextObject() [1/2]

void removeContextObject ( const word name)
inline

Remove the object from the context.

Definition at line 76 of file exprDriverContextI.H.

References Foam::name().

Here is the call graph for this function:

◆ removeContextObject() [2/2]

void removeContextObject ( const regIOobject objptr)
inline

Remove the object from the context.

Definition at line 85 of file exprDriverContextI.H.

References IOobject::name().

Here is the call graph for this function:

◆ contextObjects() [1/2]

const Foam::HashTable< const Foam::regIOobject * > & contextObjects ( ) const
inlinenoexcept

Read access to the object context.

Definition at line 98 of file exprDriverContextI.H.

◆ contextObjects() [2/2]

Foam::HashTable< const Foam::regIOobject * > & contextObjects ( )
inlinenoexcept

Write access to the object context.

Definition at line 105 of file exprDriverContextI.H.

◆ isFunction()

bool isFunction ( const word name) const

Named mapping with given type exists.

Definition at line 135 of file exprDriverTemplates.C.

References doLocalCode.

◆ getFunctionValue()

Type getFunctionValue ( const word name,
const scalar  x 
) const

Evaluate named mapping for the given time/value. Zero for undefined/unknown

Definition at line 160 of file exprDriverTemplates.C.

References doLocalCode, UList< T >::empty(), Foam::exit(), Foam::FatalError, FatalErrorInFunction, Foam::flatOutput(), Foam::func(), Foam::name(), Foam::nl, and x.

Here is the call graph for this function:

◆ fillFunctionValues()

void fillFunctionValues ( Field< Type > &  result,
const word name,
const scalarField input 
) const

Fill result with values remapped according to the named Function1.

Definition at line 213 of file exprDriverTemplates.C.

References doLocalCode, UList< T >::empty(), Foam::exit(), Foam::FatalError, FatalErrorInFunction, Foam::flatOutput(), Foam::func(), Foam::input(), Foam::min(), Foam::name(), Foam::nl, UList< T >::size(), and Foam::Zero.

Here is the call graph for this function:

◆ isLocalVariable()

bool isLocalVariable ( const word name,
bool  wantPointData = false,
label  expectedSize = -1 
) const

Test existence of a local variable.

Definition at line 284 of file exprDriverTemplates.C.

References DebugInfo, Foam::endl(), Foam::Info, exprResult::isPointData(), exprResult::isType(), Foam::name(), Foam::reduce(), exprResult::size(), and exprResult::valueType().

Here is the call graph for this function:

◆ getLocalVariable()

tmp< Field< Type > > getLocalVariable ( const word name,
label  expectSize,
const bool  mandatory = true 
) const

Retrieve local/global variable as a tmp field.

Parameters
nameThe name of the local/global field
expectSizeThe size check on the variable, -1 to ignore
mandatoryA missing variable is Fatal, or return an invalid tmp

◆ parse()

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

Execute the parser.

The return value currently has no meaning.

Implemented in parseDriver, parseDriver, and parseDriver.

◆ evaluate() [1/2]

tmp< Field< Type > > evaluate ( const expressions::exprString expr,
bool  wantPointData = false 
)
inline

Evaluate the expression and return the field.

This also clears the result and associated memory.

◆ evaluateUniform()

Type evaluateUniform ( const expressions::exprString expr,
bool  wantPointData = false 
)
inline

Evaluate the expression and return a single value.

Does not clear the result.

Definition at line 100 of file exprDriverI.H.

◆ evaluateVariable()

void evaluateVariable ( const word varName,
const expressions::exprString expr 
)

Evaluate the expression and save as the specified named variable

Definition at line 338 of file exprDriver.C.

References DebugInfo, and Foam::endl().

Here is the call graph for this function:

◆ evaluateVariableRemote()

void evaluateVariableRemote ( string  remote,
const word varName,
const expressions::exprString expr 
)
virtual

Evaluate an expression on a remote and save as the specified named variable

Reimplemented in fvExprDriver.

Definition at line 356 of file exprDriver.C.

References NotImplemented.

◆ newField() [1/2]

tmp< Field< Type > > newField ( const Type &  val = pTraits< Type >::zero) const

Return a new field with the size()

◆ newPointField() [1/2]

tmp< Field< Type > > newPointField ( const Type &  val = pTraits< Type >::zero) const

Return a new field with the pointSize()

◆ readExpression() [1/2]

Foam::expressions::exprString readExpression ( const word name,
const dictionary dict 
)
static

Read an expression string and do substitutions.

Definition at line 74 of file exprDriverIO.C.

References exprDriver::dict(), dictionary::get(), and Foam::name().

Here is the call graph for this function:

◆ readVariableStrings()

Foam::List< Foam::expressions::exprString > readVariableStrings ( const dictionary dict,
const word name = "variables",
bool  mandatory = false 
)
static

Read the list of variable strings.

(or initialize with a single string)

Definition at line 95 of file exprDriverIO.C.

References dict, and Foam::exprTools::getList().

Here is the call graph for this function:

◆ readExpression() [2/2]

Foam::expressions::exprString readExpression ( const word name)

Read an expression string (with the current dictionary) and do substitutions

Definition at line 85 of file exprDriverIO.C.

References dict, and Foam::name().

Here is the call graph for this function:

◆ readDict()

bool readDict ( const dictionary dict)
virtual

Read variables, tables etc.

Also usable for objects not constructed from a dictionary.

Reimplemented in fvExprDriver, and parseDriver.

Definition at line 296 of file exprDriver.C.

References dict, and exprDriver::readDict().

Referenced by exprDriver::exprDriver(), Function1Expression< Type >::Function1Expression(), and exprDriver::readDict().

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

◆ setVariableStrings()

Foam::label setVariableStrings ( const dictionary dict,
bool  mandatory = false 
)

Read "variables" and assigns to the list of expression strings.

Returns
the number variable strings read.

Definition at line 106 of file exprDriverIO.C.

References dict.

◆ writeVariableStrings()

Foam::Ostream & writeVariableStrings ( Ostream os,
const word keyword = "" 
) const

Write "variables".

Definition at line 118 of file exprDriverIO.C.

References os().

Here is the call graph for this function:

◆ addUniformVariable() [2/2]

void addUniformVariable ( const word name,
const Type &  val 
)
inline

Definition at line 73 of file exprDriverI.H.

References Foam::name(), and exprResult::setSingleValue().

Here is the call graph for this function:

◆ evaluate() [2/2]

Foam::tmp< Foam::Field< Type > > evaluate ( const expressions::exprString expr,
bool  wantPointData 
)

Definition at line 86 of file exprDriverI.H.

◆ getResult() [2/2]

Foam::tmp< Foam::Field< Type > > getResult ( bool  wantPointData)

Definition at line 91 of file exprDriverTemplates.C.

References Foam::exit(), Foam::FatalError, FatalErrorInFunction, and Foam::nl.

Here is the call graph for this function:

◆ getFunction1Ptr()

const Foam::Function1< Type > * getFunction1Ptr ( const word name,
const HashTable< refPtr< Function1< Type > > > &  tbl,
wordList listFailure 
)

Definition at line 109 of file exprDriverTemplates.C.

References Foam::func(), and Foam::name().

Here is the call graph for this function:

◆ newField() [2/2]

Foam::tmp< Foam::Field< Type > > newField ( const Type &  val) const

Definition at line 330 of file exprDriverTemplates.C.

References Foam::New().

Here is the call graph for this function:

◆ newPointField() [2/2]

Foam::tmp< Foam::Field< Type > > newPointField ( const Type &  val) const

Definition at line 341 of file exprDriverTemplates.C.

References Foam::New().

Here is the call graph for this function:

Member Data Documentation

◆ dict_

const dictionary& dict_
protected

The dictionary with all input data/specification.

Definition at line 188 of file exprDriver.H.

Referenced by exprDriver::dict(), and exprDriver::exprDriver().

◆ result_

exprResult result_
protected

The result.

Definition at line 191 of file exprDriver.H.

Referenced by exprDriver::getResultType(), and exprDriver::result().

◆ variableStrings_

List<expressions::exprString> variableStrings_
protected

Variable definitions, as read from a dictionary.

Definition at line 194 of file exprDriver.H.

◆ variables_

HashTable<exprResult> variables_
protected

The variables table.

Definition at line 197 of file exprDriver.H.

Referenced by fvExprDriver::hasVariable().

◆ scalarFuncs_

HashTable<refPtr<Function1<scalar> > > scalarFuncs_
protected

Function1 mappings/timelines (scalar), evaluated at the simulation time or with arbitrary scalars

Definition at line 201 of file exprDriver.H.

Referenced by exprDriver::exprDriver().

◆ vectorFuncs_

HashTable<refPtr<Function1<vector> > > vectorFuncs_
protected

Function1 mappings/timelines (vector), evaluated at the simulation time or with arbitrary scalars

Definition at line 205 of file exprDriver.H.

Referenced by exprDriver::exprDriver().

◆ contextObjects_

contextObjectTableType contextObjects_
protected

Externally defined context fields.

Definition at line 208 of file exprDriver.H.

Referenced by exprDriver::hasContextObjects().

◆ arg1Value_

scalar arg1Value_
protected

Special-purpose scalar reference argument.

Definition at line 211 of file exprDriver.H.

Referenced by exprDriver::argValue().

◆ timeStatePtr_

const TimeState* timeStatePtr_
mutableprotected

Reference to the time-state.

Definition at line 214 of file exprDriver.H.

Referenced by exprDriver::fill_random().

◆ obrPtr_

const objectRegistry* obrPtr_
protected

Pointer to an object registry (for functions etc).

Definition at line 217 of file exprDriver.H.

◆ stashedTokenId_

int stashedTokenId_
mutableprotected

Internal bookkeeping as "look-behind" parsing context.

Definition at line 223 of file exprDriver.H.

◆ debugScanner_

bool debugScanner_
protected

Request debugging for scanner.

Definition at line 226 of file exprDriver.H.

Referenced by exprDriver::setDebugging().

◆ debugParser_

bool debugParser_
protected

Request debugging for parser.

Definition at line 229 of file exprDriver.H.

Referenced by exprDriver::setDebugging().

◆ allowShadowing_

bool allowShadowing_
protected

Allow variable names to mask field names.

Definition at line 232 of file exprDriver.H.

◆ prevIterIsOldTime_

bool prevIterIsOldTime_
protected

Use value of previous iteration when oldTime is requested.

Definition at line 235 of file exprDriver.H.

Referenced by exprDriver::prevIterIsOldTime().

◆ searchCtrl_

searchControls searchCtrl_
protected

Registry/disk/caching control.

Definition at line 238 of file exprDriver.H.

Referenced by exprDriver::setSearchBehaviour().


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