57#ifndef Foam_expressions_exprResult_H
58#define Foam_expressions_exprResult_H
97 expressions::exprValue value_;
108 inline bool deleteChecked();
116 inline bool readChecked
122 const bool singleValueOnly
128 bool getUniformChecked
138 bool getUniformCheckedBool
158 bool duplicateFieldChecked(
const void* ptr);
163 bool writeSingleValueChecked(
Ostream&
os)
const;
169 bool writeFieldChecked(
const word& keyword,
Ostream&
os)
const;
174 bool writeEntryChecked(
const word& keyword,
Ostream&
os)
const;
184 bool multiplyEqChecked(
const scalar&
b);
188 inline void setResultImpl(
Field<Type>*,
bool wantPointData=
false);
191 inline void setResultImpl(
const Field<Type>&,
bool wantPointData=
false);
194 inline void setResultImpl(
Field<Type>&&,
bool wantPointData=
false);
197 inline void setResultImpl(
const Type& val,
const label len);
200 inline void setSingleValueImpl(
const Type& val);
215 bool reset(
bool force=
false);
218 void needsReset(
bool val) { needsReset_ = val; }
269 const bool singleValueOnly =
false,
271 const bool valueReqd =
false
293 #undef exprResult_Construct
294 #define exprResult_Construct(Type) \
296 explicit exprResult(const Type& val) : exprResult() \
298 setSingleValue(val); \
308 #undef exprResult_Construct
342 inline
bool isPointData(const
bool wantPointData=true) const;
349 inline
bool isType() const;
366 inline label
size() const;
444 template<
template<
class>
class BinaryOp,
class Type>
447 const BinaryOp<Type>& bop,
Info<< nl;Info<< "Write faMesh in vtk format:"<< nl;{ vtk::uindirectPatchWriter writer(aMesh.patch(), fileName(aMesh.time().globalPath()/vtkBaseFileName));writer.writeGeometry();globalIndex procAddr(aMesh.nFaces());labelList cellIDs;if(UPstream::master()) { cellIDs.resize(procAddr.totalSize());for(const labelRange &range :procAddr.ranges()) { auto slice=cellIDs.slice(range);slice=identity(range);} } writer.beginCellData(4);writer.writeProcIDs();writer.write("cellID", cellIDs);writer.write("area", aMesh.S().field());writer.write("normal", aMesh.faceAreaNormals());writer.beginPointData(1);writer.write("normal", aMesh.pointAreaNormals());Info<< " "<< writer.output().name()<< nl;}{ vtk::lineWriter writer(aMesh.points(), aMesh.edges(), fileName(aMesh.time().globalPath()/(vtkBaseFileName+"-edges")));writer.writeGeometry();writer.beginCellData(4);writer.writeProcIDs();{ Field< scalar > fld(faMeshTools::flattenEdgeField(aMesh.magLe(), true))
Generic templated field type that is much like a Foam::List except that it is expected to hold numeri...
An Istream is an abstract base class for all input systems (streams, files, token lists etc)....
An Ostream is an abstract base class for all output systems (streams, files, token lists,...
static bool parRun(const bool on) noexcept
Set as parallel run on/off.
Pointer management similar to std::unique_ptr, with some additional methods and type checking.
static autoPtr< T > New(Args &&... args)
Construct autoPtr with forwarding arguments.
A list of keyword definitions, which are a keyword followed by a number of values (eg,...
Generic dimensioned Type class.
A keyword and a list of tokens is an 'entry'.
A polymorphic field/result from evaluating an expression.
Field< Type > & constCast() const
Return non-const reference to the field, casting away constness.
const word & valueType() const noexcept
Basic type for the field or single value.
void testIfSingleValue(const bool parRun=UPstream::parRun())
Test if field corresponds to a single-value and thus uniform.
exprResult(Istream &is)
Construct from Istream as dictionary content.
Type getReduced(const BinaryOp< Type > &bop, const Type &initial=pTraits< Type >::zero)
Get a reduced result.
Type getValue() const
Return a single value when isUniform() is true, or Zero when it is non-uniform or if the type mismatc...
void writeDict(Ostream &os, const bool subDict=true) const
Write entry as dictionary contents.
exprResult & operator+=(const exprResult &b)
Addition of results.
tmp< Field< Type > > getResult(bool cacheCopy=false)
Return tmp field of the contents, optionally keeping a copy in cache.
static const exprResult null
An empty result.
virtual void resetImpl()
Reset at new timestep according to the derived class type.
virtual expressions::exprResult & target()
Simulate virtual templated methods.
label size() const
The field or object size.
bool isType() const
True if valueType corresponds to the given Type.
Field< Type > & ref()
Return non-const reference to the field.
declareRunTimeSelectionTable(autoPtr, exprResult, empty,(),())
void allowReset() noexcept
Change reset behaviour.
exprResult getUniform(const label size, const bool noWarn, const bool parRun=UPstream::parRun()) const
Construct a uniform field from the current results.
void writeValue(Ostream &os) const
Write the single value, or the first value from field.
void noReset() noexcept
Change reset behaviour.
bool is_bool() const
True if valueType is a bool.
void writeEntry(const word &keyword, Ostream &os) const
Forwarding to Field::writeEntry.
virtual autoPtr< exprResult > clone() const
Clone.
exprResult(autoPtr< Type > &&obj)
Construct for an IOobject.
const Field< Type > & cref() const
Return const reference to the field.
void setSingleValue(const Type &val)
Set single-value uniform result.
const Field< Type > * getField() const
Return a read pointer to the field data if the type matches, nullptr otherwise. Can generally be cons...
TypeName("exprResult")
Runtime type information.
declareRunTimeSelectionTable(autoPtr, exprResult, dictionary,(const dictionary &dict),(dict))
virtual void operator=(const exprResult &rhs)
Copy assignment.
void needsReset(bool val)
Adjusts the internal needsReset value.
void setResult(Field< Type > *, bool wantPointData=false)
Set result field, taking ownership of the pointer.
exprResult()
Default construct.
static autoPtr< exprResult > New(const dictionary &dict)
Return a reference to the selected value driver.
void clear()
Clear (zero) the result.
friend class exprResultGlobals
Friendship with globals.
virtual ~exprResult()
Destructor.
bool isUniform() const
True if single, uniform value.
bool isPointData(const bool wantPointData=true) const
True if representing point data, or test for same value as wantPointData argument.
const void * dataAddress() const
The address of the field data content.
exprResult & operator*=(const scalar &b)
Scalar multiplication.
bool reset(bool force=false)
Reset at new timestep according to type.
bool hasValue() const
Has a value?
void writeField(Ostream &os, const word &keyword="") const
Write the field, optionally as an entry.
A polymorphic typed union of simple primitive and VectorSpace types. It uses a 'fatter' representatio...
A traits class, which is primarily used for primitives and vector-space.
A class for managing temporary objects.
A class for handling words, derived from Foam::string.
#define exprResult_Construct(Type)
OBJstream os(runTime.globalPath()/outputName)
A namespace for expression-related classes/traits etc.
Ostream & operator<<(Ostream &, const boundaryPatch &p)
Write boundaryPatch as dictionary entries (without surrounding braces).
Istream & operator>>(Istream &, directionInfo &)
void rhs(fvMatrix< typename Expr::value_type > &m, const Expr &expression)
bool isType(const U &obj)
Check if typeid of the object and Type are identical.
SphericalTensor< scalar > sphericalTensor
SphericalTensor of scalars, i.e. SphericalTensor<scalar>.
SymmTensor< scalar > symmTensor
SymmTensor of scalars, i.e. SymmTensor<scalar>.
Macros to ease declaration of run-time selection tables.
#define declareRunTimeSelectionTable(ptrWrapper, baseType, argNames, argList, parList)
Declare a run-time selection (variables and adder classes).
#define TypeName(TypeNameString)
Declare a ClassName() with extra virtual type info.