41 typedef typename VolFieldType::Internal IntVolFieldType;
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
99 result =
gMin(values);
104 result =
gMax(values);
115 if (is_weightedOp() && canWeight(weightField))
117 result =
gSum(weightField*values);
122 result =
gSum(values);
127 case opWeightedAverage:
129 if (is_weightedOp() && canWeight(weightField))
132 gSum(weightField*values)/(
gSum(weightField) + ROOTVSMALL);
138 result =
gSum(values)/(scalar(
n) + ROOTVSMALL);
143 case opWeightedVolAverage:
145 if (is_weightedOp() && canWeight(weightField))
147 result =
gSum(weightField*V*values)
148 /(
gSum(weightField*V) + ROOTVSMALL);
153 result =
gSum(V*values)/(
gSum(V) + ROOTVSMALL);
158 case opWeightedVolIntegrate:
160 if (is_weightedOp() && canWeight(weightField))
162 result =
gSum(weightField*V*values);
167 result =
gSum(V*values);
173 const scalar sumV =
gSum(V);
175 Type meanValue =
gSum(V*values)/sumV;
177 for (
direction d=0; d < pTraits<Type>::nComponents; ++d)
180 const scalar mean =
component(meanValue, d);
183 res =
sqrt(
gSum(V*
sqr(vals - mean))/sumV)/(mean + ROOTVSMALL);
199 const word& fieldName,
204 const bool ok = validField<Type>(fieldName);
208 Field<Type> values(getFieldValues<Type>(fieldName));
212 word outName = fieldName +
'_' + regionTypeNames_[regionType_];
223 obr_.time().timeName(),
229 ? scaleFactor_*values
230 : scaleFactor_*weightField*values
234 if (operation_ != opNone)
237 values *= scaleFactor_;
239 Type result = processValues(values, V, weightField);
241 switch (postOperation_)
246 for (
direction d=0; d < pTraits<Type>::nComponents; ++d)
262 if (postOperation_ != postOpNone)
265 prefix += postOperationTypeNames_[postOperation_];
270 prefix += operationTypeNames_[operation_];
281 word resultName = prefix + regionPrefix + fieldName + suffix;
284 <<
" of " << fieldName <<
" = ";
291 bool alwaysScalar(operation_ & typeScalar);
297 if (postOperation_ == postOpMag)
299 sresult =
mag(sresult);
302 else if (postOperation_ == postOpMag)
304 sresult =
mag(result);
311 file()<<
tab << sresult;
315 this->setResult(resultName, sresult);
319 file()<<
tab << result;
323 this->setResult(resultName, result);
Generic templated field type.
Generic GeometricField class.
A primitive field of type <T> with automated input and output.
Defines the attributes of an object for which implicit objectRegistry management is supported,...
bool empty() const noexcept
True if the UList is empty (ie, size() is zero)
Watches for presence of the named trigger file in the case directory and signals a simulation stop (o...
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.
Type processValues(const Field< Type > &values, const scalarField &V, const scalarField &weightField) const
Apply the 'operation' to the values.
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.
Computes the magnitude of an input field.
const objectRegistry & obr_
Reference to the region objectRegistry.
bool useAllCells() const noexcept
Use all cells, not the cellIDs.
wordRe regionName_
Region name (cellSet, cellZone, ...)
bool foundObject(const word &name, const bool recursive=false) const
Is the named Type found?
static word defaultRegion
Return the default region name.
virtual bool write(const bool valid=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.
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)
Ostream & endl(Ostream &os)
Add newline and flush stream.
dimensionedScalar sqrt(const dimensionedScalar &ds)
static constexpr const zero Zero
Global zero (0)
tmp< DimensionedField< TypeR, GeoMesh > > New(const tmp< DimensionedField< TypeR, GeoMesh > > &tdf1, const word &name, const dimensionSet &dimensions)
Global function forwards to reuseTmpDimensionedField::New.
Type gMin(const FieldField< Field, Type > &f)
void cmptMag(FieldField< Field, Type > &cf, const FieldField< Field, Type > &f)
T returnReduce(const T &value, const BinaryOp &bop, const int tag=UPstream::msgType(), const label comm=UPstream::worldComm)
Reduce (copy) and return value.
Type gMax(const FieldField< Field, Type > &f)
constexpr char nl
The newline '\n' character (0x0a)
constexpr char tab
The tab '\t' character(0x09)