41 typedef typename VolFieldType::Internal IntVolFieldType;
45 obr_.foundObject<VolFieldType>(fieldName)
46 ||
obr_.foundObject<IntVolFieldType>(fieldName)
55 const word& fieldName,
60 typedef typename VolFieldType::Internal IntVolFieldType;
62 if (obr_.foundObject<VolFieldType>(fieldName))
64 return filterField(obr_.lookupObject<VolFieldType>(fieldName));
66 else if (obr_.foundObject<IntVolFieldType>(fieldName))
68 return filterField(obr_.lookupObject<IntVolFieldType>(fieldName));
74 <<
"Field " << fieldName <<
" not found in database" <<
nl
102 result =
gMin(values);
107 result =
gMax(values);
118 if (is_weightedOp() && canWeight(weightField))
120 result =
gSum(weightField*values);
125 result =
gSum(values);
130 case opWeightedAverage:
132 if (is_weightedOp() && canWeight(weightField))
135 gSum(weightField*values)/(
gSum(weightField) + ROOTVSMALL);
141 result =
gSum(values)/(scalar(
n) + ROOTVSMALL);
146 case opWeightedVolAverage:
148 if (is_weightedOp() && canWeight(weightField))
150 result =
gSum(weightField*V*values)
151 /(
gSum(weightField*V) + ROOTVSMALL);
156 result =
gSum(V*values)/(
gSum(V) + ROOTVSMALL);
161 case opWeightedVolIntegrate:
163 if (is_weightedOp() && canWeight(weightField))
165 result =
gSum(weightField*V*values);
170 result =
gSum(V*values);
176 const scalar sumV =
gSum(V);
178 Type meanValue =
gSum(V*values)/sumV;
180 for (
direction d=0; d < pTraits<Type>::nComponents; ++d)
182 tmp<scalarField> vals(
values.component(d));
183 const scalar mean =
component(meanValue, d);
186 res =
sqrt(
gSum(V*
sqr(vals - mean))/sumV)/(mean + ROOTVSMALL);
202 const word& fieldName,
207 const bool ok = validField<Type>(fieldName);
211 Field<Type> values(getFieldValues<Type>(fieldName));
215 word outName = fieldName +
'_' + regionTypeNames_[regionType_];
226 obr_.time().timeName(),
232 ? scaleFactor_*values
233 : scaleFactor_*weightField*values
237 if (operation_ != opNone)
240 values *= scaleFactor_;
242 Type result = processValues(values, V, weightField);
244 switch (postOperation_)
249 for (
direction d=0; d < pTraits<Type>::nComponents; ++d)
265 if (postOperation_ != postOpNone)
268 prefix += postOperationTypeNames_[postOperation_];
273 prefix += operationTypeNames_[operation_];
284 word resultName = prefix + regionPrefix + fieldName + suffix;
287 <<
" of " << fieldName <<
" = ";
294 bool alwaysScalar(operation_ & typeScalar);
300 if (postOperation_ == postOpMag)
302 sresult =
mag(sresult);
305 else if (postOperation_ == postOpMag)
307 sresult =
mag(result);
314 file()<<
tab << sresult;
318 this->setResult(resultName, sresult);
322 file()<<
tab << result;
326 this->setResult(resultName, result);
Generic templated field type that is much like a Foam::List except that it is expected to hold numeri...
Generic GeometricField class.
A primitive field of type <T> with automated input and output.
@ NO_READ
Nothing to be read.
@ NO_WRITE
Ignore writing from objectRegistry::writeObject().
Defines the attributes of an object for which implicit objectRegistry management is supported,...
bool empty() const noexcept
True if List is empty (ie, size() is zero).
scalar scaleFactor_
Scaling factor.
bool writeFields_
Flag to output field values.
bool writeValues(const word &fieldName, const scalarField &V, const scalarField &weightField)
Templated helper function to output field values.
tmp< Field< Type > > getFieldValues(const word &fieldName, const bool mandatory=false) const
Insert field values into values list.
postOperationType postOperation_
Optional post-evaluation operation.
Type processValues(const Field< Type > &values, const scalarField &V, const scalarField &weightField) const
Apply the 'operation' to the values.
bool canWeight(const scalarField &fld) const
True if field is non-empty on any processor.
@ postOpNone
No additional operation after calculation.
@ postOpSqrt
Component-wise sqrt after normal operation.
@ postOpMag
Component-wise mag after normal operation.
operationType operation_
Operation to apply to values.
static const Enum< operationType > operationTypeNames_
Operation type names.
bool validField(const word &fieldName) const
Return true if the field name is valid.
tmp< Field< Type > > filterField(const Field< Type > &field) const
Filter a field according to cellIds.
bool is_weightedOp() const noexcept
True if the operation variant uses a weight-field.
static const Enum< postOperationType > postOperationTypeNames_
Operation type names.
@ opWeightedSum
Weighted sum.
@ opWeightedAverage
Weighted average.
@ opVolIntegrate
Volume integral.
@ opAverage
Ensemble average.
@ opCoV
Coefficient of variation.
@ opWeightedVolIntegrate
Weighted volume integral.
@ opVolAverage
Volume average.
@ opSumMag
Sum of component magnitudes.
@ opWeightedVolAverage
Weighted volume average.
const objectRegistry & obr_
Reference to the region objectRegistry.
void setResult(const word &entryName, const Type &value)
Add result.
bool useAllCells() const noexcept
Use all cells, not the cellIDs.
scalar V() const
Return total volume of the selected region.
wordRe regionName_
Region name (cellSet, cellZone, ...).
static const Enum< regionTypes > regionTypeNames_
Region type names.
regionTypes regionType_
Region type.
const labelList & cellIDs() const
Return the local list of cell IDs.
virtual OFstream & file()
Return access to the file (if only 1).
static word defaultRegion
Return the default region name.
virtual bool write(const bool writeOnProc=true) const
Write using setting from DB.
A class for managing temporary objects.
A class for handling words, derived from Foam::string.
#define FatalErrorInFunction
Report an error message using Foam::FatalError.
List< T > values(const HashTable< T, Key, Hash > &tbl, const bool doSort=false)
List of values from HashTable, optionally sorted.
tmp< DimensionedField< TypeR, GeoMesh > > New(const tmp< DimensionedField< TypeR, GeoMesh > > &tf1, const word &name, const dimensionSet &dimensions, const bool initCopy=false)
Global function forwards to reuseTmpDimensionedField::New.
Type gSum(const FieldField< Field, Type > &f)
dimensionedSymmTensor sqr(const dimensionedVector &dv)
void component(FieldField< Field, typename FieldField< Field, Type >::cmptType > &sf, const FieldField< Field, Type > &f, const direction d)
label & setComponent(label &val, const direction) noexcept
Non-const access to integer-type (has no components).
Field< scalar > scalarField
Specialisation of Field<T> for scalar.
T returnReduce(const T &value, BinaryOp bop, const int tag=UPstream::msgType(), const int communicator=UPstream::worldComm)
Perform reduction on a copy, using specified binary operation.
Ostream & endl(Ostream &os)
Add newline and flush stream.
dimensionedScalar sqrt(const dimensionedScalar &ds)
dimensioned< typename typeOfMag< Type >::type > mag(const dimensioned< Type > &dt)
errorManip< error > abort(error &err)
static constexpr const zero Zero
Global zero (0).
error FatalError
Error stream (stdout output on all processes), with additional 'FOAM FATAL ERROR' header text and sta...
Type gMin(const FieldField< Field, Type > &f)
void cmptMag(FieldField< Field, Type > &cf, const FieldField< Field, Type > &f)
Type gMax(const FieldField< Field, Type > &f)
constexpr char nl
The newline '\n' character (0x0a).
constexpr char tab
The tab '\t' character(0x09).