Go to the documentation of this file.
40 template<
class WeightType>
50 return mag(weightField);
56 template<
class WeightType>
79 foundObject<smt>(fieldName)
80 || foundObject<vf>(fieldName)
81 || (withSurfaceFields() && foundObject<sf>(fieldName))
90 const word& fieldName,
98 if (foundObject<smt>(fieldName))
100 return lookupObject<smt>(fieldName);
102 else if (withSurfaceFields() && foundObject<sf>(fieldName))
104 return filterField(lookupObject<sf>(fieldName));
106 else if (foundObject<vf>(fieldName))
108 const vf&
fld = lookupObject<vf>(fieldName);
118 return sampledPtr_->sample(interp);
122 return filterField(
fld);
129 <<
"Field " << fieldName <<
" not found in database" <<
nl
137 template<
class Type,
class WeightType>
170 case opAbsWeightedSum:
172 if (is_weightedOp() && canWeight(weightField))
176 weightingFactor(weightField, Sf, is_magOp())
189 case opSumDirectionBalance:
192 <<
"Operation " << operationTypeNames_[operation_]
193 <<
" not available for values of type "
200 case opWeightedAverage:
201 case opAbsWeightedAverage:
203 if (is_weightedOp() && canWeight(weightField))
207 weightingFactor(weightField, Sf, is_magOp())
222 case opWeightedAreaAverage:
223 case opAbsWeightedAreaAverage:
225 if (is_weightedOp() && canWeight(weightField))
229 areaWeightingFactor(weightField, Sf, is_magOp())
243 case opAreaIntegrate:
244 case opWeightedAreaIntegrate:
245 case opAbsWeightedAreaIntegrate:
247 if (is_weightedOp() && canWeight(weightField))
251 areaWeightingFactor(weightField, Sf, is_magOp())
268 const scalar gSumMagSf =
gSum(magSf);
270 Type meanValue =
gSum(
values*magSf)/gSumMagSf;
272 for (
direction d=0; d < pTraits<Type>::nComponents; ++d)
275 const scalar mean =
component(meanValue, d);
280 /(mean + ROOTVSMALL);
286 case opAreaNormalAverage:
287 case opAreaNormalIntegrate:
294 case opWeightedUniformity:
295 case opAbsWeightedUniformity:
297 if (is_weightedOp() && canWeight(weightField))
300 return processValues<Type, scalar>
304 weightingFactor(weightField, is_magOp())
316 template<
class Type,
class WeightType>
324 return processSameTypeValues(
values, Sf, weightField);
328 template<
class WeightType>
337 label nProcessed = 0;
345 if (Pstream::master() && surfaceWriterPtr_ && surfaceWriterPtr_->enabled())
347 auto&
writer = *surfaceWriterPtr_;
355 / regionTypeNames_[regionType_] + (
"_" + regionName_)
363 for (
const word& fieldName : fields_)
367 writeValues<scalar>(fieldName, Sf, weightField,
points, faces)
368 || writeValues<vector>(fieldName, Sf, weightField,
points, faces)
369 || writeValues<sphericalTensor>
371 fieldName, Sf, weightField,
points, faces
373 || writeValues<symmTensor>(fieldName, Sf, weightField,
points, faces)
374 || writeValues<tensor>(fieldName, Sf, weightField,
points, faces)
382 <<
"Requested field " << fieldName
383 <<
" not found in database and not processed"
389 if (Pstream::master() && surfaceWriterPtr_ && surfaceWriterPtr_->enabled())
391 auto&
writer = *surfaceWriterPtr_;
409 template<
class Type,
class WeightType>
412 const word& fieldName,
419 const bool ok = validField<Type>(fieldName);
426 if (surfaceWriterPtr_ && surfaceWriterPtr_->enabled())
429 combineFields(allValues);
431 if (Pstream::master())
434 surfaceWriterPtr_->write(fieldName, allValues);
443 if (operation_ != opNone)
448 Type result = processValues(
values, Sf, weightField);
450 switch (postOperation_)
455 for (
direction d=0; d < pTraits<Type>::nComponents; ++d)
471 if (postOperation_ != postOpNone)
474 prefix += postOperationTypeNames_[postOperation_];
479 prefix += operationTypeNames_[operation_];
484 word resultName = prefix + regionName_ +
',' + fieldName + suffix;
488 Log <<
" " << prefix << regionName_ << suffix
489 <<
" of " << fieldName <<
" = ";
496 bool alwaysScalar(operation_ & typeScalar);
502 if (postOperation_ == postOpMag)
504 sresult =
mag(sresult);
507 else if (postOperation_ == postOpMag)
509 sresult =
mag(result);
516 file()<<
tab << sresult;
520 this->setResult(resultName, sresult);
524 file()<<
tab << result;
528 this->setResult(resultName, result);
548 auto&
values = tvalues.ref();
552 const label facei = faceId_[i];
553 const label patchi = facePatchId_[i];
581 auto&
values = tvalues.ref();
585 const label facei = faceId_[i];
586 const label patchi = facePatchId_[i];
600 Pout<<
"field " <<
field.name() <<
" oriented: "
604 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.
A class for handling file names.
T returnReduce(const T &Value, const BinaryOp &bop, const int tag=Pstream::msgType(), const label comm=UPstream::worldComm)
bool canWeight(const Field< WeightType > &fld) const
True if field is non-empty on any processor.
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.
virtual void write(const coordSet &, const wordList &, const List< const Field< Type > * > &, Ostream &) const =0
General entry point for writing.
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.
void cmptMag(FieldField< Field, Type > &cf, const FieldField< Field, Type > &f)
word outputName("finiteArea-edges.obj")
Generic templated field type.
tmp< Field< Type > > getFieldValues(const word &fieldName, const bool mandatory=false) const
Return field values by looking up field name.
IOdictionary propsDict(IOobject("particleTrackProperties", runTime.constant(), mesh, IOobject::MUST_READ_IF_MODIFIED))
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))
A list of keyword definitions, which are a keyword followed by a number of values (eg,...
Base class for graphics format writing. Entry points are.
errorManip< error > abort(error &err)
static tmp< scalarField > weightingFactor(const Field< WeightType > &weightField, const bool useMag)
Weighting factor.
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)
A traits class, which is primarily used 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...