A polymorphic field/result from evaluating an expression. More...
#include <exprResult.H>


Public Member Functions | |
| TypeName ("exprResult") | |
| Runtime type information. | |
| declareRunTimeSelectionTable (autoPtr, exprResult, dictionary,(const dictionary &dict),(dict)) | |
| declareRunTimeSelectionTable (autoPtr, exprResult, empty,(),()) | |
| exprResult () | |
| Default construct. | |
| exprResult (const exprResult &expr) | |
| Copy construct. | |
| exprResult (exprResult &&expr) | |
| Move construct. | |
| exprResult (const dictionary &dict, const bool singleValueOnly=false, const bool valueReqd=false) | |
| Construct from a dictionary. | |
| exprResult (Istream &is) | |
| Construct from Istream as dictionary content. | |
| template<class Type> | |
| exprResult (const Field< Type > &fld) | |
| Construct by copying a field. | |
| template<class Type> | |
| exprResult (Field< Type > &&fld) | |
| Construct by moving a field. | |
| template<class Type> | |
| exprResult (autoPtr< Type > &&obj) | |
| Construct for an IOobject. | |
| template<class Type> | |
| exprResult (const dimensioned< Type > &dt) | |
| Construct from a dimensioned value. | |
| exprResult (const bool &val) | |
| Construct from single value of bool. | |
| exprResult (const scalar &val) | |
| Construct from single value of scalar. | |
| exprResult (const vector &val) | |
| Construct from single value of vector. | |
| exprResult (const tensor &val) | |
| Construct from single value of tensor. | |
| exprResult (const symmTensor &val) | |
| Construct from single value of symmTensor. | |
| exprResult (const sphericalTensor &val) | |
| Construct from single value of sphericalTensor. | |
| virtual autoPtr< exprResult > | clone () const |
| Clone. | |
| virtual | ~exprResult () |
| Destructor. | |
| bool | hasValue () const |
| Has a value? | |
| const word & | valueType () const noexcept |
| Basic type for the field or single value. | |
| bool | isPointData (const bool wantPointData=true) const |
| True if representing point data, or test for same value as wantPointData argument. | |
| bool | isUniform () const |
| True if single, uniform value. | |
| template<class Type> | |
| bool | isType () const |
| True if valueType corresponds to the given Type. | |
| template<class Type> | |
| Type | getValue () const |
| 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. | |
| template<class Type> | |
| const Field< Type > * | getField () const |
| Return a read pointer to the field data if the type matches, nullptr otherwise. Can generally be considered as failsafe. | |
| bool | is_bool () const |
| True if valueType is a bool. | |
| label | size () const |
| The field or object size. | |
| const void * | dataAddress () const |
| The address of the field data content. | |
| void | clear () |
| Clear (zero) the result. | |
| void | noReset () noexcept |
| Change reset behaviour. | |
| void | allowReset () noexcept |
| Change reset behaviour. | |
| void | testIfSingleValue (const bool parRun=UPstream::parRun()) |
| Test if field corresponds to a single-value and thus uniform. | |
| template<class Type> | |
| void | setResult (Field< Type > *, bool wantPointData=false) |
| Set result field, taking ownership of the pointer. | |
| template<class Type> | |
| void | setResult (const Field< Type > &, bool wantPointData=false) |
| Set result field, taking copy of the field contents. | |
| template<class Type> | |
| void | setResult (Field< Type > &&, bool wantPointData=false) |
| Set result field, moving field contents. | |
| template<class Type> | |
| void | setResult (const Type &val, const label size) |
| Set uniform result field of given size. | |
| template<class Type> | |
| void | setSingleValue (const Type &val) |
| Set single-value uniform result. | |
| template<class Type> | |
| const Field< Type > & | cref () const |
| Return const reference to the field. | |
| template<class Type> | |
| Field< Type > & | ref () |
| Return non-const reference to the field. | |
| template<class Type> | |
| Field< Type > & | constCast () const |
| Return non-const reference to the field, casting away constness. | |
| template<class Type> | |
| tmp< Field< Type > > | getResult (bool cacheCopy=false) |
| Return tmp field of the contents, optionally keeping a copy in cache. | |
| exprResult | getUniform (const label size, const bool noWarn, const bool parRun=UPstream::parRun()) const |
| Construct a uniform field from the current results. | |
| template<template< class > class BinaryOp, class Type> | |
| Type | getReduced (const BinaryOp< Type > &bop, const Type &initial=pTraits< Type >::zero) |
| Get a reduced result. | |
| void | writeEntry (const word &keyword, Ostream &os) const |
| Forwarding to Field::writeEntry. | |
| void | writeDict (Ostream &os, const bool subDict=true) const |
| Write entry as dictionary contents. | |
| void | writeField (Ostream &os, const word &keyword="") const |
| Write the field, optionally as an entry. | |
| void | writeValue (Ostream &os) const |
| Write the single value, or the first value from field. | |
| virtual void | operator= (const exprResult &rhs) |
| Copy assignment. | |
| virtual void | operator= (exprResult &&rhs) |
| Move assignment. | |
| exprResult & | operator*= (const scalar &b) |
| Scalar multiplication. | |
| exprResult & | operator+= (const exprResult &b) |
| Addition of results. | |
| template<class Type> | |
| const Foam::Field< Type > * | getField () const |
| 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 |
Static Public Member Functions | |
| static autoPtr< exprResult > | New (const dictionary &dict) |
| Return a reference to the selected value driver. | |
| static autoPtr< exprResult > | New (Istream &is) |
| Construct from Istream as dictionary content. | |
Static Public Attributes | |
| static const exprResult | null |
| An empty result. | |
Protected Member Functions | |
| virtual expressions::exprResult & | target () |
| Simulate virtual templated methods. | |
| virtual void | resetImpl () |
| Reset at new timestep according to the derived class type. | |
| bool | reset (bool force=false) |
| Reset at new timestep according to type. | |
| void | needsReset (bool val) |
| Adjusts the internal needsReset value. | |
Friends | |
| class | exprResultGlobals |
| Friendship with globals. | |
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 121 of file exprResult.H.
| exprResult | ( | ) |
Default construct.
Definition at line 173 of file exprResult.C.
Referenced by declareRunTimeSelectionTable(), declareRunTimeSelectionTable(), exprResult(), exprResult(), exprResult(), exprResult(), exprResult(), exprResult(), exprResultDelayed::exprResultDelayed(), exprResultDelayed::exprResultDelayed(), exprResultDelayed::exprResultDelayed(), exprResultStack::exprResultStack(), exprResultStack::exprResultStack(), exprResultStack::exprResultStack(), exprResultStored::exprResultStored(), exprResultStored::exprResultStored(), exprResultStored::exprResultStored(), getResult(), getUniform(), operator+=(), operator=(), operator=(), exprResultDelayed::operator=(), exprResultDelayed::operator=(), exprResultStack::operator=(), exprResultStack::operator=(), exprResultStored::operator=(), exprResultStack::pop(), exprResultStack::push(), exprResultDelayed::setReadValue(), exprResultDelayed::updateReadValue(), and exprResultStack::~exprResultStack().

| exprResult | ( | const exprResult & | expr | ) |
Copy construct.
Definition at line 185 of file exprResult.C.
References exprResult(), operator=(), and Foam::rhs().

| exprResult | ( | exprResult && | expr | ) |
Move construct.
Definition at line 193 of file exprResult.C.
References exprResult(), operator=(), and Foam::rhs().

|
explicit |
Construct from a dictionary.
| singleValueOnly | Read a single entry, not a field |
| valueReqd | The "value" entry required or optional |
Definition at line 201 of file exprResult.C.
References DebugInFunction, dict, Foam::exit(), exprResult(), Foam::FatalIOError, FatalIOErrorInFunction, hasValue(), keyType::LITERAL, Foam::nl, and valueType().

|
explicit |
|
explicit |
Construct by copying a field.
Definition at line 152 of file exprResultI.H.
References DebugInFunction, exprResult(), fld(), Foam::nl, and setResult().

|
explicit |
Construct by moving a field.
Definition at line 163 of file exprResultI.H.
References DebugInFunction, exprResult(), fld(), Foam::nl, and setResult().

|
explicit |
Construct from a dimensioned value.
Definition at line 174 of file exprResultI.H.
References DebugInFunction, exprResult(), Foam::nl, setSingleValue(), and dimensioned< Type >::value().

|
inlineexplicit |
Construct from single value of bool.
Definition at line 431 of file exprResult.H.
|
inlineexplicit |
Construct from single value of scalar.
Definition at line 432 of file exprResult.H.
|
inlineexplicit |
Construct from single value of vector.
Definition at line 433 of file exprResult.H.
|
inlineexplicit |
Construct from single value of tensor.
Definition at line 434 of file exprResult.H.
|
inlineexplicit |
Construct from single value of symmTensor.
Definition at line 435 of file exprResult.H.
|
inlineexplicit |
Construct from single value of sphericalTensor.
Definition at line 436 of file exprResult.H.
References dict.
|
virtual |
|
inlineprotectedvirtual |
Simulate virtual templated methods.
Reimplemented in exprResultDelayed.
Definition at line 307 of file exprResult.H.
Referenced by setResult(), setResult(), setResult(), setResult(), and setSingleValue().

|
protectedvirtual |
Reset at new timestep according to the derived class type.
Reimplemented in exprResultStored, and exprResultStoredStack.
Definition at line 346 of file exprResult.C.
References clear().
Referenced by reset().


|
protected |
Reset at new timestep according to type.
Definition at line 352 of file exprResult.C.
References resetImpl().

|
inlineprotected |
Adjusts the internal needsReset value.
Definition at line 324 of file exprResult.H.
Referenced by exprResultStack::exprResultStack(), exprResultStack::exprResultStack(), exprResultStack::exprResultStack(), exprResultStoredStack::exprResultStoredStack(), exprResultStoredStack::exprResultStoredStack(), 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 271 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 324 of file exprResult.C.
References dict, and Foam::New().

|
inlinevirtual |
Clone.
Reimplemented in exprResultDelayed, exprResultStack, exprResultStored, and exprResultStoredStack.
Definition at line 456 of file exprResult.H.
References autoPtr< T >::New().

|
inline |
Has a value?
Definition at line 185 of file exprResultI.H.
Referenced by exprResult(), exprResultStack::push(), and Function1Expression< Type >::value().

|
inlinenoexcept |
Basic type for the field or single value.
Definition at line 192 of file exprResultI.H.
References Foam::noexcept.
Referenced by cref(), dataAddress(), exprResult(), getReduced(), getResult(), getUniform(), exprDriver::isLocalVariable(), operator*=(), operator+=(), operator=(), exprResultStack::pop(), exprResultStack::push(), testIfSingleValue(), Function1Expression< Type >::value(), writeDict(), writeEntry(), writeField(), and writeValue().

|
inline |
True if representing point data, or test for same value as wantPointData argument.
Definition at line 198 of file exprResultI.H.
Referenced by exprDriver::isLocalVariable().

|
inline |
True if single, uniform value.
Definition at line 207 of file exprResultI.H.
Referenced by fvExprDriver::evaluateVariableRemote().

|
inline |
True if valueType corresponds to the given Type.
Definition at line 214 of file exprResultI.H.
Referenced by cref(), getField(), getReduced(), getResult(), getValue(), exprDriver::isLocalVariable(), and Function1Expression< Type >::value().

|
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 221 of file exprResultI.H.
References isType(), and Foam::Zero.

|
inline |
Return a read pointer to the field data if the type matches, nullptr otherwise. Can generally be considered as failsafe.
References clear(), dataAddress(), getField(), is_bool(), and size().
Referenced by getField().


|
inline |
True if valueType is a bool.
Definition at line 246 of file exprResultI.H.
Referenced by getField().

|
inline |
The field or object size.
Definition at line 252 of file exprResultI.H.
Referenced by getField(), getResult(), getUniform(), exprDriver::isLocalVariable(), exprResultStack::pop(), setResult(), and Function1Expression< Type >::value().

| const void * dataAddress | ( | ) | const |
The address of the field data content.
Fatal for unknown types. Used, for example, for python integration
Definition at line 810 of file exprResult.C.
References defineExpressionMethod, Foam::exit(), Foam::FatalError, FatalErrorInFunction, Foam::nl, and valueType().
Referenced by getField().


| void clear | ( | ) |
Clear (zero) the result.
Definition at line 364 of file exprResult.C.
Referenced by getField().

|
inlinenoexcept |
Change reset behaviour.
Definition at line 543 of file exprResult.H.
References Foam::noexcept, and noReset().
Referenced by noReset().


|
inlinenoexcept |
| void testIfSingleValue | ( | const bool | parRun = UPstream::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 440 of file exprResult.C.
References Foam::endl(), Foam::nl, valueType(), and WarningInFunction.
Referenced by fvExprDriver::evaluateVariableRemote().


|
inline |
Set result field, taking ownership of the pointer.
Definition at line 329 of file exprResultI.H.
References target().
Referenced by exprResult(), exprResult(), parseDriver::setInternalFieldResult(), and parseDriver::setResult().


|
inline |
Set result field, taking copy of the field contents.
Definition at line 259 of file exprResultI.H.
References DebugInFunction, Foam::nl, and target().

|
inline |
Set result field, moving field contents.
Definition at line 272 of file exprResultI.H.
References DebugInFunction, Foam::nl, and target().

|
inline |
Set uniform result field of given size.
Definition at line 361 of file exprResultI.H.
References size(), and target().

|
inline |
Set single-value uniform result.
Definition at line 392 of file exprResultI.H.
References target().
Referenced by exprResult().


|
inline |
Return const reference to the field.
Referenced by constCast(), ref(), and Function1Expression< Type >::value().

|
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.
References b, exprResult(), os(), UPstream::parRun(), Foam::rhs(), and size().

| Foam::expressions::exprResult getUniform | ( | const label | size, |
| const bool | noWarn, | ||
| const bool | parRun = UPstream::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 403 of file exprResult.C.
References Foam::exit(), exprResult(), Foam::FatalError, FatalErrorInFunction, Foam::nl, size(), and valueType().
Referenced by exprDriver::getRemoteResult().


|
inline |
Get a reduced result.
Definition at line 698 of file exprResultI.H.
References Foam::exit(), Foam::FatalError, FatalErrorInFunction, fld(), isType(), Foam::nl, Foam::returnReduce(), and valueType().

Forwarding to Field::writeEntry.
Definition at line 527 of file exprResult.C.
References Foam::endl(), os(), valueType(), and WarningInFunction.

| void writeDict | ( | Ostream & | os, |
| const bool | subDict = true ) const |
Write entry as dictionary contents.
Definition at line 551 of file exprResult.C.
References DebugInFunction, IOstreamOption::formatNames, Foam::name(), Foam::nl, os(), valueType(), and writeField().

Write the field, optionally as an entry.
Definition at line 595 of file exprResult.C.
References DebugInFunction, Foam::endl(), IOstreamOption::formatNames, Foam::name(), Foam::nl, os(), valueType(), and WarningInFunction.
Referenced by writeDict().


| void writeValue | ( | Ostream & | os | ) | const |
Write the single value, or the first value from field.
Definition at line 627 of file exprResult.C.
References DebugInFunction, Foam::endl(), IOstreamOption::formatNames, Foam::name(), Foam::nl, os(), valueType(), and WarningInFunction.

|
virtual |
Copy assignment.
Reimplemented in exprResultDelayed, exprResultStack, and exprResultStored.
Definition at line 467 of file exprResult.C.
References clear(), DebugInFunction, Foam::exit(), exprResult(), Foam::FatalError, FatalErrorInFunction, Foam::nl, Foam::rhs(), and valueType().
Referenced by exprResult(), exprResult(), exprResultDelayed::operator=(), exprResultStored::operator=(), exprResultStored::operator=(), exprResultStack::push(), and exprResultDelayed::setReadValue().


|
virtual |
Move assignment.
Reimplemented in exprResultDelayed.
Definition at line 504 of file exprResult.C.
References clear(), exprResult(), and Foam::rhs().

| Foam::expressions::exprResult & operator*= | ( | const scalar & | b | ) |
Scalar multiplication.
Definition at line 661 of file exprResult.C.
References b, Foam::exit(), Foam::FatalError, FatalErrorInFunction, Foam::nl, and valueType().

| Foam::expressions::exprResult & operator+= | ( | const exprResult & | b | ) |
Addition of results.
Definition at line 696 of file exprResult.C.
References b, Foam::exit(), exprResult(), Foam::FatalError, FatalErrorInFunction, Foam::nl, and valueType().

|
inline |
Definition at line 234 of file exprResultI.H.
References isType().

|
inline |
Definition at line 614 of file exprResultI.H.
References clear(), DebugInFunction, Foam::exit(), Foam::FatalError, FatalErrorInFunction, isType(), Foam::New(), Foam::nl, and valueType().

|
inline |
Definition at line 656 of file exprResultI.H.
References DebugInFunction, Foam::exit(), Foam::FatalError, FatalErrorInFunction, isType(), Foam::nl, and valueType().

|
inline |
Definition at line 683 of file exprResultI.H.
References cref().

|
inline |
Definition at line 691 of file exprResultI.H.
References cref().

|
friend |
Friendship with globals.
Definition at line 337 of file exprResult.H.
References exprResultGlobals.
Referenced by exprResultGlobals.
|
static |
An empty result.
Definition at line 332 of file exprResult.H.
Referenced by exprResultGlobals::get().