A polymorphic field/result from evaluating an expression. More...
Public Member Functions | |
TypeName ("exprResult") | |
Runtime type information. More... | |
declareRunTimeSelectionTable (autoPtr, exprResult, dictionary,(const dictionary &dict),(dict)) | |
declareRunTimeSelectionTable (autoPtr, exprResult, empty,(),()) | |
exprResult () | |
Default construct. 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... | |
exprResult (Istream &is) | |
Construct from Istream as dictionary content. More... | |
template<class Type > | |
exprResult (const Field< Type > &fld) | |
Construct by copying a field. More... | |
template<class Type > | |
exprResult (Field< Type > &&fld) | |
Construct by moving a field. More... | |
template<class Type > | |
exprResult (autoPtr< Type > &&obj) | |
Construct for an IOobject. More... | |
template<class Type > | |
exprResult (const dimensioned< Type > &dt) | |
Construct from a dimensioned value. More... | |
exprResult (const bool &val) | |
Construct from single value of bool. More... | |
exprResult (const scalar &val) | |
Construct from single value of scalar. More... | |
exprResult (const vector &val) | |
Construct from single value of vector. More... | |
exprResult (const tensor &val) | |
Construct from single value of tensor. More... | |
exprResult (const symmTensor &val) | |
Construct from single value of symmTensor. More... | |
exprResult (const sphericalTensor &val) | |
Construct from single value of sphericalTensor. More... | |
virtual autoPtr< exprResult > | clone () const |
Clone. More... | |
virtual | ~exprResult () |
Destructor. More... | |
bool | hasValue () const |
Has a value? More... | |
const word & | valueType () const noexcept |
Basic type for the field or single value. More... | |
bool | isPointData (const bool wantPointData=true) const |
bool | isUniform () const |
True if single, uniform value. More... | |
template<class Type > | |
bool | isType () const |
True if valueType corresponds to the given Type. More... | |
template<class Type > | |
Type | getValue () const |
bool | is_bool () const |
True if valueType is a bool. 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 () noexcept |
Change reset behaviour. More... | |
void | allowReset () noexcept |
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 wantPointData=false) |
Set result field, taking ownership of the pointer. More... | |
template<class Type > | |
void | setResult (const Field< Type > &, bool wantPointData=false) |
Set result field, taking copy of the field contents. More... | |
template<class Type > | |
void | setResult (Field< Type > &&, bool wantPointData=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 > | |
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 > & | constCast () const |
Return non-const reference to the field, casting away constness. More... | |
template<class Type > | |
tmp< Field< Type > > | getResult (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 | writeField (Ostream &os, const word &keyword="") const |
Write the field, optionally as an entry. 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... | |
exprResult & | operator*= (const scalar &b) |
Scalar multiplication. More... | |
exprResult & | operator+= (const exprResult &b) |
Addition of results. More... | |
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 > & | constCast () const |
![]() | |
constexpr | refCount () noexcept |
Default construct, 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< exprResult > | New (const dictionary &dict) |
Return a reference to the selected value driver. More... | |
static autoPtr< exprResult > | New (Istream &is) |
Construct from Istream as dictionary content. More... | |
Static Public Attributes | |
static const exprResult | null |
An empty result. More... | |
Protected Member Functions | |
virtual expressions::exprResult & | target () |
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... | |
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 |
Definition at line 124 of file exprResult.H.
exprResult | ( | ) |
Default construct.
Definition at line 206 of file exprResult.C.
References exprResult::clear().
exprResult | ( | const exprResult & | expr | ) |
Copy construct.
Definition at line 222 of file exprResult.C.
References exprResult::operator=().
exprResult | ( | exprResult && | expr | ) |
Move construct.
Definition at line 230 of file exprResult.C.
References exprResult::operator=().
|
explicit |
Construct from a dictionary.
Definition at line 239 of file exprResult.C.
References DebugInFunction, dict, Foam::exit(), Foam::FatalIOError, FatalIOErrorInFunction, and Foam::nl.
|
explicit |
Construct from Istream as dictionary content.
|
explicit |
Construct by copying a field.
Definition at line 195 of file exprResultI.H.
References DebugInFunction, fld, Foam::nl, and exprResult::setResult().
|
explicit |
Construct by moving a field.
Definition at line 206 of file exprResultI.H.
References DebugInFunction, fld, Foam::nl, and exprResult::setResult().
|
explicit |
Construct for an IOobject.
|
explicit |
Construct from a dimensioned value.
Definition at line 217 of file exprResultI.H.
References DebugInFunction, Foam::nl, exprResult::setSingleValue(), and dimensioned< Type >::value().
|
inlineexplicit |
Construct from single value of bool.
Definition at line 393 of file exprResult.H.
|
inlineexplicit |
Construct from single value of scalar.
Definition at line 394 of file exprResult.H.
|
inlineexplicit |
Construct from single value of vector.
Definition at line 395 of file exprResult.H.
|
inlineexplicit |
Construct from single value of tensor.
Definition at line 396 of file exprResult.H.
|
inlineexplicit |
Construct from single value of symmTensor.
Definition at line 397 of file exprResult.H.
|
inlineexplicit |
Construct from single value of sphericalTensor.
Definition at line 398 of file exprResult.H.
|
virtual |
|
inlineprotectedvirtual |
Simulate virtual templated methods.
Reimplemented in exprResultDelayed.
Definition at line 302 of file exprResult.H.
|
protectedvirtual |
Reset at new timestep according to the derived class type.
Reimplemented in exprResultStored, and exprResultStoredStack.
Definition at line 378 of file exprResult.C.
References clear().
Reset at new timestep according to type.
Definition at line 384 of file exprResult.C.
|
inlineprotected |
Adjusts the internal needsReset value.
Definition at line 312 of file exprResult.H.
Referenced by exprResultStack::exprResultStack(), and exprResultStoredStack::exprResultStoredStack().
TypeName | ( | "exprResult" | ) |
Runtime type information.
declareRunTimeSelectionTable | ( | autoPtr | , |
exprResult | , | ||
dictionary | , | ||
(const dictionary &dict) | , | ||
(dict) | |||
) |
declareRunTimeSelectionTable | ( | autoPtr | , |
exprResult | , | ||
empty | , | ||
() | , | ||
() | |||
) |
|
static |
Return a reference to the selected value driver.
Definition at line 304 of file exprResult.C.
References DebugInfo, dict, Foam::exit(), Foam::FatalIOError, FatalIOErrorInLookup, and Foam::nl.
Referenced by exprResultGlobals::addValue().
|
static |
Construct from Istream as dictionary content.
Definition at line 357 of file exprResult.C.
References dict, and Foam::New().
|
inlinevirtual |
Clone.
Reimplemented in exprResultDelayed, exprResultStored, exprResultStack, and exprResultStoredStack.
Definition at line 412 of file exprResult.H.
References autoPtr< T >::New().
|
inline |
Has a value?
Definition at line 228 of file exprResultI.H.
Referenced by Foam::stringOps::evaluate().
|
inlinenoexcept |
Basic type for the field or single value.
Definition at line 235 of file exprResultI.H.
Referenced by exprDriver::getResultType(), exprDriver::isLocalVariable(), and exprResultStack::push().
True if representing point data, or test for same value as wantPointData argument
Definition at line 242 of file exprResultI.H.
Referenced by exprDriver::getResult(), and exprDriver::isLocalVariable().
|
inline |
True if single, uniform value.
Definition at line 250 of file exprResultI.H.
Referenced by fvExprDriver::evaluateVariableRemote().
|
inline |
True if valueType corresponds to the given Type.
Definition at line 257 of file exprResultI.H.
Referenced by exprDriver::isLocalVariable().
|
inline |
Return a single value when isUniform() is true, or Zero when it is non-uniform or if the type mismatches, which means that it can generally be considered as failsafe.
Definition at line 264 of file exprResultI.H.
References Foam::Zero.
|
inline |
True if valueType is a bool.
Definition at line 275 of file exprResultI.H.
|
inline |
The field or object size.
Definition at line 281 of file exprResultI.H.
Referenced by Foam::stringOps::evaluate(), and exprDriver::isLocalVariable().
const void * dataAddress | ( | ) | const |
The address of the field data content.
Fatal for unknown types. Used, for example, for python integration
Definition at line 833 of file exprResult.C.
References defineExpressionMethod, Foam::exit(), Foam::FatalError, FatalErrorInFunction, and Foam::nl.
void clear | ( | ) |
Clear (zero) the result.
Definition at line 396 of file exprResult.C.
Referenced by exprResult::exprResult().
|
inlinenoexcept |
Change reset behaviour.
Definition at line 467 of file exprResult.H.
|
inlinenoexcept |
Change reset behaviour.
Definition at line 470 of file exprResult.H.
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 471 of file exprResult.C.
References Foam::endl(), Foam::nl, and WarningInFunction.
Referenced by fvExprDriver::evaluateVariableRemote().
Set result field, taking ownership of the pointer.
Definition at line 359 of file exprResultI.H.
Referenced by exprResult::exprResult(), and parseDriver::setResult().
Set result field, taking copy of the field contents.
Definition at line 289 of file exprResultI.H.
References DebugInFunction, and Foam::nl.
Set result field, moving field contents.
Definition at line 302 of file exprResultI.H.
References DebugInFunction, and Foam::nl.
|
inline |
Set uniform result field of given size.
Definition at line 391 of file exprResultI.H.
|
inline |
Set single-value uniform result.
Definition at line 423 of file exprResultI.H.
Referenced by exprDriver::addUniformVariable(), and exprResult::exprResult().
|
inline |
Return const reference to the field.
|
inline |
Return non-const reference to the field.
|
inline |
Return non-const reference to the field, casting away constness.
Return tmp field of the contents, optionally keeping a copy in cache
Referenced by exprDriver::getResult().
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 436 of file exprResult.C.
References Foam::exit(), Foam::FatalError, FatalErrorInFunction, and Foam::nl.
Referenced by exprDriver::getRemoteResult(), and exprResultStack::operator=().
Get a reduced result.
Definition at line 728 of file exprResultI.H.
References Foam::exit(), Foam::FatalError, FatalErrorInFunction, fld, Foam::nl, and Foam::returnReduce().
Forwarding to Field::writeEntry.
Definition at line 561 of file exprResult.C.
References Foam::endl(), os(), and WarningInFunction.
Write entry as dictionary contents.
Definition at line 585 of file exprResult.C.
References DebugInFunction, IOstreamOption::formatNames, Foam::name(), Foam::nl, os(), and Foam::ensightOutput::writeField().
Write the field, optionally as an entry.
Definition at line 629 of file exprResult.C.
References DebugInFunction, Foam::endl(), IOstreamOption::formatNames, Foam::name(), Foam::nl, os(), and WarningInFunction.
Referenced by Foam::stringOps::evaluate().
void writeValue | ( | Ostream & | os | ) | const |
Write the single value, or the first value from field.
Definition at line 661 of file exprResult.C.
References DebugInFunction, Foam::endl(), IOstreamOption::formatNames, Foam::name(), Foam::nl, os(), and WarningInFunction.
Referenced by Foam::stringOps::evaluate().
|
virtual |
Copy assignment.
Reimplemented in exprResultDelayed, exprResultStored, and exprResultStack.
Definition at line 498 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().
|
virtual |
Move assignment.
Reimplemented in exprResultDelayed.
Definition at line 536 of file exprResult.C.
References clear().
Foam::expressions::exprResult & operator*= | ( | const scalar & | b | ) |
Scalar multiplication.
Definition at line 695 of file exprResult.C.
References Foam::constant::physicoChemical::b, Foam::exit(), Foam::FatalError, FatalErrorInFunction, and Foam::nl.
Foam::expressions::exprResult & operator+= | ( | const exprResult & | b | ) |
Addition of results.
Definition at line 729 of file exprResult.C.
References Foam::constant::physicoChemical::b, Foam::exit(), Foam::FatalError, FatalErrorInFunction, and Foam::nl.
|
inline |
Definition at line 643 of file exprResultI.H.
References clear(), DebugInFunction, Foam::exit(), Foam::FatalError, FatalErrorInFunction, Foam::New(), and Foam::nl.
|
inline |
Definition at line 685 of file exprResultI.H.
References DebugInFunction, Foam::exit(), Foam::FatalError, FatalErrorInFunction, and Foam::nl.
|
inline |
Definition at line 712 of file exprResultI.H.
|
inline |
Definition at line 720 of file exprResultI.H.
|
friend |
Friendship with globals.
Definition at line 321 of file exprResult.H.
|
static |
An empty result.
Definition at line 318 of file exprResult.H.
Referenced by exprResultGlobals::get().