Go to the documentation of this file.
40 template<
class WeightType>
66 foundObject<smt>(fieldName)
67 || foundObject<vf>(fieldName)
68 || (withSurfaceFields() && foundObject<sf>(fieldName))
77 const word& fieldName,
85 if (foundObject<smt>(fieldName))
87 return lookupObject<smt>(fieldName);
89 else if (withSurfaceFields() && foundObject<sf>(fieldName))
91 return filterField(lookupObject<sf>(fieldName));
93 else if (foundObject<vf>(fieldName))
95 const vf&
fld = lookupObject<vf>(fieldName);
99 if (sampledPtr_->interpolate())
103 return sampledPtr_->interpolate(interp);
109 return sampledPtr_->sample(interp);
114 return filterField(
fld);
121 <<
"Field " << fieldName <<
" not found in database" <<
nl
129 template<
class Type,
class WeightType>
162 case opAbsWeightedSum:
164 if (canWeight(weightField))
177 case opSumDirectionBalance:
180 <<
"Operation " << operationTypeNames_[operation_]
181 <<
" not available for values of type "
188 case opWeightedAverage:
189 case opAbsWeightedAverage:
191 if (canWeight(weightField))
193 const scalarField factor(weightingFactor(weightField));
206 case opWeightedAreaAverage:
207 case opAbsWeightedAreaAverage:
209 if (canWeight(weightField))
211 const scalarField factor(weightingFactor(weightField, Sf));
223 case opAreaIntegrate:
224 case opWeightedAreaIntegrate:
225 case opAbsWeightedAreaIntegrate:
227 if (canWeight(weightField))
243 const scalar gSumMagSf =
gSum(magSf);
245 Type meanValue =
gSum(
values*magSf)/gSumMagSf;
247 for (
direction d=0; d < pTraits<Type>::nComponents; ++d)
250 const scalar mean =
component(meanValue, d);
255 /(mean + ROOTVSMALL);
261 case opAreaNormalAverage:
262 case opAreaNormalIntegrate:
269 case opWeightedUniformity:
270 case opAbsWeightedUniformity:
272 if (canWeight(weightField))
275 return processValues<Type, scalar>
279 weightingFactor(weightField)
291 template<
class Type,
class WeightType>
299 return processSameTypeValues(
values, Sf, weightField);
303 template<
class WeightType>
312 return mag(weightField);
316 template<
class WeightType>
325 label nProcessed = 0;
327 for (
const word& fieldName : fields_)
331 writeValues<scalar>(fieldName, Sf, weightField,
points, faces)
332 || writeValues<vector>(fieldName, Sf, weightField,
points, faces)
333 || writeValues<sphericalTensor>
335 fieldName, Sf, weightField,
points, faces
337 || writeValues<symmTensor>(fieldName, Sf, weightField,
points, faces)
338 || writeValues<tensor>(fieldName, Sf, weightField,
points, faces)
346 <<
"Requested field " << fieldName
347 <<
" not found in database and not processed"
356 template<
class Type,
class WeightType>
359 const word& fieldName,
366 const bool ok = validField<Type>(fieldName);
373 if (surfaceWriterPtr_ && surfaceWriterPtr_->enabled())
376 combineFields(allValues);
378 if (Pstream::master())
380 surfaceWriterPtr_->open
386 / regionTypeNames_[regionType_] + (
"_" + regionName_)
391 surfaceWriterPtr_->write(fieldName, allValues);
393 surfaceWriterPtr_->clear();
397 if (operation_ != opNone)
402 Type result = processValues(
values, Sf, weightField);
404 switch (postOperation_)
409 for (
direction d=0; d < pTraits<Type>::nComponents; ++d)
425 if (postOperation_ != postOpNone)
428 prefix += postOperationTypeNames_[postOperation_];
433 prefix += operationTypeNames_[operation_];
438 word resultName = prefix + regionName_ +
',' + fieldName + suffix;
442 Log <<
" " << prefix << regionName_ << suffix
443 <<
" of " << fieldName <<
" = ";
450 bool alwaysScalar(operation_ & typeScalar);
456 if (postOperation_ == postOpMag)
458 sresult =
mag(sresult);
461 else if (postOperation_ == postOpMag)
463 sresult =
mag(result);
470 file()<<
tab << sresult;
474 this->setResult(resultName, sresult);
478 file()<<
tab << result;
482 this->setResult(resultName, result);
502 auto&
values = tvalues.ref();
506 const label facei = faceId_[i];
507 const label patchi = facePatchId_[i];
535 auto&
values = tvalues.ref();
539 const label facei = faceId_[i];
540 const label patchi = facePatchId_[i];
554 Pout<<
"field " <<
field.name() <<
" oriented: "
558 if (
field.oriented()())
int debug
Static debugging option.
label & setComponent(label &l, const direction)
void component(FieldField< Field, typename FieldField< Field, Type >::cmptType > &sf, const FieldField< Field, Type > &f, const direction d)
A class for handling words, derived from Foam::string.
T returnReduce(const T &Value, const BinaryOp &bop, const int tag=Pstream::msgType(), const label comm=UPstream::worldComm)
A class for managing temporary objects.
static constexpr const zero Zero
Global zero (0)
List< T > values(const HashTable< T, Key, Hash > &tbl, const bool doSort=false)
List of values from HashTable, optionally sorted.
Type processSameTypeValues(const Field< Type > &values, const vectorField &Sf, const Field< WeightType > &weightField) const
Apply the 'operation' to the values. Operation must preserve Type.
bool canWeight(const Field< WeightType > &weightField) const
True if operation variant uses a weight-field that is available.
Ostream & endl(Ostream &os)
Add newline and flush stream.
Type gSum(const FieldField< Field, Type > &f)
prefixOSstream Pout
OSstream wrapped stdout (std::cout) with parallel prefix.
tmp< Field< Type > > filterField(const GeometricField< Type, fvsPatchField, surfaceMesh > &field) const
Filter a surface field according to faceIds.
label writeAll(const vectorField &Sf, const Field< WeightType > &weightField, const pointField &points, const faceList &faces)
Templated helper function to output field values.
#define forAll(list, i)
Loop across all elements in list.
Uses the cell value for any point in the cell.
tmp< scalarField > weightingFactor(const Field< WeightType > &weightField) const
Weighting factor.
void cmptMag(FieldField< Field, Type > &cf, const FieldField< Field, Type > &f)
Generic templated field type.
Given cell centre values and point (vertex) values decompose into tetrahedra and linear interpolate w...
tmp< Field< Type > > getFieldValues(const word &fieldName, const bool mandatory=false) const
Return field values by looking up field name.
gmvFile<< "tracers "<< particles.size()<< nl;for(const passiveParticle &p :particles){ gmvFile<< p.position().x()<< ' ';}gmvFile<< nl;for(const passiveParticle &p :particles){ gmvFile<< p.position().y()<< ' ';}gmvFile<< nl;for(const passiveParticle &p :particles){ gmvFile<< p.position().z()<< ' ';}gmvFile<< nl;for(const word &name :lagrangianScalarNames){ IOField< scalar > fld(IOobject(name, runTime.timeName(), cloud::prefix, mesh, IOobject::MUST_READ, IOobject::NO_WRITE))
errorManip< error > abort(error &err)
errorManipArg< error, int > exit(error &err, const int errNo=1)
tmp< DimensionedField< TypeR, GeoMesh > > New(const tmp< DimensionedField< TypeR, GeoMesh >> &tdf1, const word &name, const dimensionSet &dimensions)
Global function forwards to reuseTmpDimensionedField::New.
bool validField(const word &fieldName) const
Return true if the field name is known and a valid type.
#define FatalErrorInFunction
Report an error message using Foam::FatalError.
dimensionedSymmTensor sqr(const dimensionedVector &dv)
dimensionedScalar sqrt(const dimensionedScalar &ds)
Traits class for primitives.
dimensioned< typename typeOfMag< Type >::type > mag(const dimensioned< Type > &dt)
Type gMin(const FieldField< Field, Type > &f)
Generic GeometricField class.
bool writeValues(const word &fieldName, const vectorField &Sf, const Field< WeightType > &weightField, const pointField &points, const faceList &faces)
Templated helper function to output field values.
Type processValues(const Field< Type > &values, const vectorField &Sf, const Field< WeightType > &weightField) const
Apply the 'operation' to the values. Wrapper around.
#define WarningInFunction
Report a warning using Foam::Warning.
Type gMax(const FieldField< Field, Type > &f)
Field with dimensions and associated with geometry type GeoMesh which is used to size the field and a...