exprResult Class Reference

A polymorphic field/result from evaluating an expression. More...

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

Public Member Functions

 TypeName ("exprResult")
 Runtime type information. More...
 
 declareRunTimeSelectionTable (autoPtr, exprResult, dictionary,(const dictionary &dict),(dict))
 
 declareRunTimeSelectionTable (autoPtr, exprResult, empty,(),())
 
 exprResult ()
 Construct null. More...
 
 exprResult (const exprResult &expr)
 Copy construct. More...
 
 exprResult (exprResult &&expr)
 Move construct. More...
 
 exprResult (const dictionary &dict, const bool uniform=false, const bool needsValue=false)
 Construct from a dictionary. More...
 
template<class Type >
 exprResult (const Field< Type > &f)
 Construct by copying a field. More...
 
template<class Type >
 exprResult (Field< Type > &&f)
 Construct by moving a field. More...
 
template<class Type >
 exprResult (autoPtr< Type > &ap)
 Construct for an IOobject. More...
 
template<class Type >
 exprResult (autoPtr< Type > &&ap)
 Construct for an IOobject. More...
 
template<class Type >
 exprResult (const dimensioned< Type > &f)
 Construct from a dimensioned value. More...
 
 exprResult (const bool &val)
 
 exprResult (const scalar &val)
 
 exprResult (const vector &val)
 
 exprResult (const tensor &val)
 
 exprResult (const symmTensor &val)
 
 exprResult (const sphericalTensor &val)
 
virtual autoPtr< exprResultclone () const
 Clone. More...
 
virtual ~exprResult ()
 Destructor. More...
 
bool hasValue () const
 Has a value? More...
 
const wordvalueType () const
 Basic type for the field or single value. More...
 
bool isPointValue (const bool isPointVal=true) const
 True if representing point values, or test if same as isPointVal. More...
 
bool isUniform () const
 True if single, uniform value. More...
 
template<class Type >
bool isType () const
 True if valueType corresponds to the given Type. More...
 
bool isBool () const
 True if valueType is a bool. More...
 
bool isObject () const
 True if the object pointer is being used. More...
 
label size () const
 The field or object size. More...
 
const void * dataAddress () const
 The address of the field data content. More...
 
void clear ()
 Clear (zero) the result. More...
 
void noReset ()
 Change reset behaviour. More...
 
void allowReset ()
 Change reset behaviour. More...
 
void testIfSingleValue (const bool parRun=Pstream::parRun())
 Test if field corresponds to a single-value and thus uniform. More...
 
template<class Type >
void setResult (Field< Type > *, bool isPointVal=false)
 Set result field, taking ownership of the pointer. More...
 
template<class Type >
void setResult (const Field< Type > &fld, bool isPointVal=false)
 Set result field, taking copy of the field contents. More...
 
template<class Type >
void setResult (Field< Type > &&, bool isPointVal=false)
 Set result field, moving field contents. More...
 
template<class Type >
void setResult (const Type &val, const label size)
 Set uniform result field of given size. More...
 
template<class Type >
void setSingleValue (const Type &val)
 Set single-value uniform result. More...
 
template<class Type >
void setObjectResult (autoPtr< Type > &o)
 
template<class Type >
void setObjectResult (autoPtr< Type > &&o)
 
template<class Type >
const Field< Type > & cref () const
 Return const reference to the field. More...
 
template<class Type >
Field< Type > & ref ()
 Return non-const reference to the field. More...
 
template<class Type >
Field< Type > & getRef () const
 Return non-const reference to the field, casting away constness. More...
 
template<class Type >
tmp< Field< Type > > getResult (bool cacheCopy=false)
 
template<class Type >
tmp< Type > getObjectResult (bool cacheCopy=false)
 
exprResult getUniform (const label size, const bool noWarn, const bool parRun=Pstream::parRun()) const
 Construct a uniform field from the current results. More...
 
template<template< class > class BinaryOp, class Type >
Type getReduced (const BinaryOp< Type > &bop, const Type &initial=pTraits< Type >::zero)
 Get a reduced result. More...
 
void writeEntry (const word &keyword, Ostream &os) const
 Forwarding to Field::writeEntry. More...
 
void writeDict (Ostream &os, const bool subDict=true) const
 Write entry as dictionary contents. More...
 
void writeValue (Ostream &os) const
 Write the single value, or the first value from field. More...
 
virtual void operator= (const exprResult &rhs)
 Copy assignment. More...
 
virtual void operator= (exprResult &&rhs)
 Move assignment. More...
 
exprResultoperator*= (const scalar &b)
 Scalar multiplication. More...
 
exprResultoperator+= (const exprResult &b)
 Addition of results. More...
 
template<class T >
void setObjectResultImpl (T *ptr)
 
template<class T >
void setObjectResultImpl (autoPtr< T > &o)
 
template<class T >
void setObjectResultImpl (autoPtr< T > &&o)
 
template<class Type >
Foam::tmp< Foam::Field< Type > > getResult (bool cacheCopy)
 
template<class Type >
const Foam::Field< Type > & cref () const
 
template<class Type >
Foam::Field< Type > & ref ()
 
template<class Type >
Foam::Field< Type > & getRef () const
 
template<class Type >
Foam::tmp< Type > getObjectResult (bool cacheCopy)
 
- Public Member Functions inherited from refCount
constexpr refCount () noexcept
 Construct null initializing count to 0. More...
 
int count () const noexcept
 Return the current reference count. More...
 
bool unique () const noexcept
 Return true if the reference count is zero. More...
 
void operator++ () noexcept
 Increment the reference count. More...
 
void operator++ (int) noexcept
 Increment the reference count. More...
 
void operator-- () noexcept
 Decrement the reference count. More...
 
void operator-- (int) noexcept
 Decrement the reference count. More...
 

Static Public Member Functions

static autoPtr< exprResultNew (const dictionary &dict)
 Return a reference to the selected value driver. More...
 

Static Public Attributes

static const exprResult null
 An empty result. More...
 

Protected Member Functions

virtual exprResulttarget ()
 Simulate virtual templated methods. More...
 
virtual void resetImpl ()
 Reset at new timestep according to the derived class type. More...
 
bool reset (bool force=false)
 Reset at new timestep according to type. More...
 
void needsReset (bool val)
 Adjusts the internal needsReset value. More...
 

Friends

class exprResultGlobals
 Friendship with globals. More...
 

Detailed Description

A polymorphic field/result from evaluating an expression.


Dictionary parameters

Property Description Required Default
resultType The type of result no exprResult
unsetValue Create without reading the dictionary no false
noReset Suppress reset on time no false

When creating with values

Property Description Required Default
valueType Result value type (scalar, vector,..) yes
isSingleValue A single field value no false
isPointValue Interpret values as point values no false
value The field values yes
fieldSize The size of the field (when not single-value) no
Source files

Definition at line 128 of file exprResult.H.

Constructor & Destructor Documentation

◆ exprResult() [1/15]

Construct null.

Definition at line 205 of file exprResult.C.

References exprResult::clear().

Here is the call graph for this function:

◆ exprResult() [2/15]

exprResult ( const exprResult expr)

Copy construct.

Definition at line 222 of file exprResult.C.

References exprResult::operator=().

Here is the call graph for this function:

◆ exprResult() [3/15]

exprResult ( exprResult &&  expr)

Move construct.

Definition at line 230 of file exprResult.C.

References exprResult::operator=().

Here is the call graph for this function:

◆ exprResult() [4/15]

exprResult ( const dictionary dict,
const bool  uniform = false,
const bool  needsValue = false 
)
explicit

Construct from a dictionary.

Definition at line 239 of file exprResult.C.

References DebugInFunction, dict, Foam::exit(), Foam::FatalError, FatalErrorInFunction, Foam::FatalIOError, FatalIOErrorInFunction, and Foam::nl.

Here is the call graph for this function:

◆ exprResult() [5/15]

exprResult ( const Field< Type > &  f)

Construct by copying a field.

Definition at line 193 of file exprResultI.H.

References DebugInFunction, f(), Foam::nl, and exprResult::setResult().

Here is the call graph for this function:

◆ exprResult() [6/15]

exprResult ( Field< Type > &&  f)

Construct by moving a field.

Definition at line 204 of file exprResultI.H.

References DebugInFunction, f(), Foam::nl, and exprResult::setResult().

Here is the call graph for this function:

◆ exprResult() [7/15]

exprResult ( autoPtr< Type > &  ap)

Construct for an IOobject.

Definition at line 215 of file exprResultI.H.

References exprResult::setObjectResult().

Here is the call graph for this function:

◆ exprResult() [8/15]

exprResult ( autoPtr< Type > &&  ap)

Construct for an IOobject.

Definition at line 224 of file exprResultI.H.

References exprResult::setObjectResult().

Here is the call graph for this function:

◆ exprResult() [9/15]

exprResult ( const dimensioned< Type > &  f)

Construct from a dimensioned value.

Definition at line 233 of file exprResultI.H.

References DebugInFunction, f(), Foam::nl, and exprResult::setSingleValue().

Here is the call graph for this function:

◆ exprResult() [10/15]

exprResult ( const bool val)
inlineexplicit

Construct from single value of bool

Definition at line 406 of file exprResult.H.

◆ exprResult() [11/15]

exprResult ( const scalar &  val)
inlineexplicit

Construct from single value of scalar

Definition at line 407 of file exprResult.H.

◆ exprResult() [12/15]

exprResult ( const vector val)
inlineexplicit

Construct from single value of vector

Definition at line 408 of file exprResult.H.

◆ exprResult() [13/15]

exprResult ( const tensor val)
inlineexplicit

Construct from single value of tensor

Definition at line 409 of file exprResult.H.

◆ exprResult() [14/15]

exprResult ( const symmTensor val)
inlineexplicit

Construct from single value of symmTensor

Definition at line 410 of file exprResult.H.

◆ exprResult() [15/15]

exprResult ( const sphericalTensor val)
inlineexplicit

Construct from single value of sphericalTensor

Definition at line 411 of file exprResult.H.

◆ ~exprResult()

~exprResult ( )
virtual

Destructor.

Definition at line 355 of file exprResult.C.

References DebugInFunction, and Foam::nl.

Member Function Documentation

◆ target()

virtual exprResult& target ( )
inlineprotectedvirtual

Simulate virtual templated methods.

Reimplemented in exprResultDelayed.

Definition at line 314 of file exprResult.H.

◆ resetImpl()

void resetImpl ( )
protectedvirtual

Reset at new timestep according to the derived class type.

Reimplemented in exprResultStored, and exprResultStoredStack.

Definition at line 365 of file exprResult.C.

References clear().

Here is the call graph for this function:

◆ reset()

bool reset ( bool  force = false)
protected

Reset at new timestep according to type.

Returns
true if it was actually reset

Definition at line 371 of file exprResult.C.

◆ needsReset()

void needsReset ( bool  val)
inlineprotected

Adjusts the internal needsReset value.

Definition at line 324 of file exprResult.H.

References Foam::val.

Referenced by exprResultStack::exprResultStack(), and exprResultStoredStack::exprResultStoredStack().

Here is the caller graph for this function:

◆ TypeName()

TypeName ( "exprResult"  )

Runtime type information.

◆ declareRunTimeSelectionTable() [1/2]

declareRunTimeSelectionTable ( autoPtr  ,
exprResult  ,
dictionary  ,
(const dictionary &dict ,
(dict  
)

◆ declareRunTimeSelectionTable() [2/2]

declareRunTimeSelectionTable ( autoPtr  ,
exprResult  ,
empty  ,
()  ,
()   
)

◆ New()

Foam::autoPtr< Foam::expressions::exprResult > New ( const dictionary dict)
static

Return a reference to the selected value driver.

Definition at line 304 of file exprResult.C.

References DebugInfo, dict, Foam::exit(), Foam::FatalError, FatalErrorInLookup, and Foam::nl.

Referenced by exprResultGlobals::addValue().

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

◆ clone()

virtual autoPtr<exprResult> clone ( ) const
inlinevirtual

Clone.

Reimplemented in exprResultDelayed, exprResultStored, exprResultStack, and exprResultStoredStack.

Definition at line 422 of file exprResult.H.

References autoPtr< T >::New().

Here is the call graph for this function:

◆ hasValue()

bool hasValue ( ) const
inline

Has a value?

Definition at line 244 of file exprResultI.H.

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

Here is the caller graph for this function:

◆ valueType()

const Foam::word & valueType ( ) const
inline

Basic type for the field or single value.

Definition at line 250 of file exprResultI.H.

Referenced by exprDriver::getResultType(), exprDriver::isLocalVariable(), and exprResultStack::push().

Here is the caller graph for this function:

◆ isPointValue()

bool isPointValue ( const bool  isPointVal = true) const
inline

True if representing point values, or test if same as isPointVal.

Definition at line 257 of file exprResultI.H.

Referenced by parseDriver::getField(), exprDriver::getResult(), parseDriver::getVariableIfAvailable(), and exprDriver::isLocalVariable().

Here is the caller graph for this function:

◆ isUniform()

bool isUniform ( ) const
inline

True if single, uniform value.

Definition at line 265 of file exprResultI.H.

Referenced by fvExprDriver::evaluateVariableRemote(), parseDriver::getField(), fvExprDriver::getVariable(), and parseDriver::getVariableIfAvailable().

Here is the caller graph for this function:

◆ isType()

bool isType ( ) const
inline

True if valueType corresponds to the given Type.

Definition at line 272 of file exprResultI.H.

Referenced by exprDriver::isLocalVariable().

Here is the caller graph for this function:

◆ isBool()

bool isBool ( ) const
inline

True if valueType is a bool.

Definition at line 278 of file exprResultI.H.

◆ isObject()

bool isObject ( ) const
inline

True if the object pointer is being used.

Definition at line 284 of file exprResultI.H.

◆ size()

Foam::label size ( ) const
inline

The field or object size.

Definition at line 290 of file exprResultI.H.

Referenced by Foam::stringOps::evaluate(), and exprDriver::isLocalVariable().

Here is the caller graph for this function:

◆ dataAddress()

const void * dataAddress ( ) const

The address of the field data content.

Fatal for unknown types. Used, for example, for python integration

Definition at line 825 of file exprResult.C.

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

Here is the call graph for this function:

◆ clear()

void clear ( )

Clear (zero) the result.

Definition at line 383 of file exprResult.C.

Referenced by exprDriver::clearResult(), and exprResult::exprResult().

Here is the caller graph for this function:

◆ noReset()

void noReset ( )
inline

Change reset behaviour.

Definition at line 473 of file exprResult.H.

◆ allowReset()

void allowReset ( )
inline

Change reset behaviour.

Definition at line 476 of file exprResult.H.

◆ testIfSingleValue()

void testIfSingleValue ( const bool  parRun = Pstream::parRun())

Test if field corresponds to a single-value and thus uniform.

Uses field min/max to establish uniformity. Test afterwards with isUniform()

Definition at line 459 of file exprResult.C.

References Foam::endl(), Foam::nl, and WarningInFunction.

Referenced by fvExprDriver::evaluateVariableRemote().

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

◆ setResult() [1/4]

void setResult ( Field< Type > *  fldPtr,
bool  isPointVal = false 
)
inline

Set result field, taking ownership of the pointer.

Definition at line 410 of file exprResultI.H.

Referenced by exprResult::exprResult(), and parseDriver::setResult().

Here is the caller graph for this function:

◆ setResult() [2/4]

void setResult ( const Field< Type > &  fld,
bool  isPointVal = false 
)
inline

Set result field, taking copy of the field contents.

Definition at line 298 of file exprResultI.H.

References DebugInFunction, Foam::nl, and Foam::val.

◆ setResult() [3/4]

void setResult ( Field< Type > &&  val,
bool  isPointVal = false 
)
inline

Set result field, moving field contents.

Definition at line 311 of file exprResultI.H.

References DebugInFunction, Foam::nl, and Foam::val.

◆ setResult() [4/4]

void setResult ( const Type &  val,
const label  size 
)
inline

Set uniform result field of given size.

Definition at line 441 of file exprResultI.H.

References Foam::val.

◆ setSingleValue()

void setSingleValue ( const Type &  val)
inline

Set single-value uniform result.

Definition at line 473 of file exprResultI.H.

References Foam::val.

Referenced by exprDriver::addUniformVariable(), and exprResult::exprResult().

Here is the caller graph for this function:

◆ setObjectResult() [1/2]

void setObjectResult ( autoPtr< Type > &  o)
inline

Definition at line 367 of file exprResultI.H.

References autoPtr< T >::ptr().

Referenced by exprResult::exprResult().

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

◆ setObjectResult() [2/2]

void setObjectResult ( autoPtr< Type > &&  o)
inline

Definition at line 374 of file exprResultI.H.

◆ cref() [1/2]

const Field<Type>& cref ( ) const
inline

Return const reference to the field.

Referenced by parseDriver::getField(), fvExprDriver::getVariable(), and parseDriver::getVariableIfAvailable().

Here is the caller graph for this function:

◆ ref() [1/2]

Field<Type>& ref ( )
inline

Return non-const reference to the field.

◆ getRef() [1/2]

Field<Type>& getRef ( ) const
inline

Return non-const reference to the field, casting away constness.

◆ getResult() [1/2]

tmp<Field<Type> > getResult ( bool  cacheCopy = false)
inline

Return tmp field of the contents, optionally keeping a copy in cache

Referenced by exprDriver::getResult().

Here is the caller graph for this function:

◆ getObjectResult() [1/2]

tmp<Type> getObjectResult ( bool  cacheCopy = false)
inline

Get object result (Caution - potentially fragile) optionally keeping a copy in cache

◆ getUniform()

Foam::expressions::exprResult getUniform ( const label  size,
const bool  noWarn,
const bool  parRun = Pstream::parRun() 
) const

Construct a uniform field from the current results.

Uses the field average. Optionally warning if the min/max deviation is larger than SMALL.

Definition at line 424 of file exprResult.C.

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

Referenced by exprDriver::getRemoteResult(), and exprResultStack::operator=().

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

◆ getReduced()

Type getReduced ( const BinaryOp< Type > &  bop,
const Type &  initial = pTraits<Type>::zero 
)
inline

Get a reduced result.

Definition at line 794 of file exprResultI.H.

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

Here is the call graph for this function:

◆ writeEntry()

void writeEntry ( const word keyword,
Ostream os 
) const

Forwarding to Field::writeEntry.

Definition at line 557 of file exprResult.C.

References Foam::endl(), and WarningInFunction.

Here is the call graph for this function:

◆ writeDict()

void writeDict ( Ostream os,
const bool  subDict = true 
) const

Write entry as dictionary contents.

Definition at line 581 of file exprResult.C.

References Ostream::beginBlock(), DebugInFunction, Ostream::endBlock(), Foam::endl(), IOstreamOption::format(), IOstreamOption::formatNames, Foam::name(), Foam::nl, WarningInFunction, Ostream::writeEntry(), and Ostream::writeEntryIfDifferent().

Here is the call graph for this function:

◆ writeValue()

void writeValue ( Ostream os) const

Write the single value, or the first value from field.

Definition at line 639 of file exprResult.C.

References DebugInFunction, Foam::endl(), IOstreamOption::format(), IOstreamOption::formatNames, Foam::name(), Foam::nl, and WarningInFunction.

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

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

◆ operator=() [1/2]

void operator= ( const exprResult rhs)
virtual

Copy assignment.

Reimplemented in exprResultDelayed, exprResultStored, and exprResultStack.

Definition at line 486 of file exprResult.C.

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

Referenced by exprResult::exprResult(), exprResultStored::operator=(), exprResultDelayed::operator=(), exprResultStack::push(), and exprResultDelayed::setReadValue().

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

◆ operator=() [2/2]

void operator= ( exprResult &&  rhs)
virtual

Move assignment.

Reimplemented in exprResultDelayed.

Definition at line 530 of file exprResult.C.

References clear().

Here is the call graph for this function:

◆ operator*=()

Foam::expressions::exprResult & operator*= ( const scalar &  b)

Scalar multiplication.

Definition at line 673 of file exprResult.C.

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

Here is the call graph for this function:

◆ operator+=()

Foam::expressions::exprResult & operator+= ( const exprResult b)

Addition of results.

Definition at line 714 of file exprResult.C.

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

Here is the call graph for this function:

◆ setObjectResultImpl() [1/3]

void setObjectResultImpl ( T ptr)

Definition at line 381 of file exprResultI.H.

References DebugInFunction, and Foam::nl.

◆ setObjectResultImpl() [2/3]

void setObjectResultImpl ( autoPtr< T > &  o)

Definition at line 395 of file exprResultI.H.

References autoPtr< T >::ptr().

Here is the call graph for this function:

◆ setObjectResultImpl() [3/3]

void setObjectResultImpl ( autoPtr< T > &&  o)

Definition at line 402 of file exprResultI.H.

◆ getResult() [2/2]

Foam::tmp<Foam::Field<Type> > getResult ( bool  cacheCopy)
inline

Definition at line 669 of file exprResultI.H.

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

Here is the call graph for this function:

◆ cref() [2/2]

const Foam::Field<Type>& cref ( ) const
inline

Definition at line 711 of file exprResultI.H.

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

Here is the call graph for this function:

◆ ref() [2/2]

Foam::Field<Type>& ref ( )
inline

Definition at line 738 of file exprResultI.H.

◆ getRef() [2/2]

Foam::Field<Type>& getRef ( ) const
inline

Definition at line 746 of file exprResultI.H.

◆ getObjectResult() [2/2]

Foam::tmp<Type> getObjectResult ( bool  cacheCopy)
inline

Definition at line 754 of file exprResultI.H.

References clear(), DebugInFunction, Foam::exit(), Foam::FatalError, FatalErrorInFunction, tmp< T >::New(), Foam::nl, and WarningInFunction.

Here is the call graph for this function:

Friends And Related Function Documentation

◆ exprResultGlobals

friend class exprResultGlobals
friend

Friendship with globals.

Definition at line 333 of file exprResult.H.

Member Data Documentation

◆ null

const Foam::expressions::exprResult null
static

An empty result.

Definition at line 330 of file exprResult.H.

Referenced by exprResultGlobals::get().


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