40template<
class WeightType>
50 return mag(weightField);
56template<
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
137template<
class Type,
class WeightType>
155 result =
gMin(values);
160 result =
gMax(values);
170 case opAbsWeightedSum:
172 if (is_weightedOp() && canWeight(weightField))
176 weightingFactor(weightField, Sf, is_magOp())
179 result =
gSum(weight*values);
184 result =
gSum(values);
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())
210 result =
gSum(factor*values)/(
gSum(factor) + ROOTVSMALL);
217 result =
gSum(values)/(scalar(
n) + ROOTVSMALL);
222 case opWeightedAreaAverage:
223 case opAbsWeightedAreaAverage:
225 if (is_weightedOp() && canWeight(weightField))
229 areaWeightingFactor(weightField, Sf, is_magOp())
232 result =
gSum(factor*values)/
gSum(factor + ROOTVSMALL);
239 result =
gSum(factor*values)/
gSum(factor + ROOTVSMALL);
243 case opAreaIntegrate:
244 case opWeightedAreaIntegrate:
245 case opAbsWeightedAreaIntegrate:
247 if (is_weightedOp() && canWeight(weightField))
251 areaWeightingFactor(weightField, Sf, is_magOp())
254 result =
gSum(factor*values);
261 result =
gSum(factor*values);
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())
316template<
class Type,
class WeightType>
324 return processSameTypeValues(values, Sf, weightField);
328template<
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_;
409template<
class Type,
class WeightType>
412 const word& fieldName,
419 const bool ok = validField<Type>(fieldName);
423 Field<Type> values(getFieldValues<Type>(fieldName,
true));
426 if (surfaceWriterPtr_ && surfaceWriterPtr_->enabled())
429 combineFields(allValues);
434 surfaceWriterPtr_->write(fieldName, allValues);
443 if (operation_ != opNone)
446 values *= scaleFactor_;
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];
558 values[i] =
field.boundaryField()[patchi][facei];
563 values[i] = 0.5*(
field[own[facei]] +
field[nei[facei]]);
581 auto& values = tvalues.ref();
585 const label facei = faceId_[i];
586 const label patchi = facePatchId_[i];
590 values[i] =
field.boundaryField()[patchi][facei];
594 values[i] =
field[facei];
600 Pout<<
"field " <<
field.name() <<
" oriented: "
604 if (
field.oriented()())
vtk::internalMeshWriter writer(topoMesh, topoCells, vtk::formatType::INLINE_ASCII, runTime.path()/"blockTopology")
Info<< nl<< "Wrote faMesh in vtk format: "<< writer.output().name()<< nl;}{ vtk::lineWriter writer(aMesh.points(), aMesh.edges(), fileName(aMesh.mesh().time().globalPath()/"finiteArea-edges"));writer.writeGeometry();writer.beginCellData(4);writer.writeProcIDs();{ Field< scalar > fld(faMeshTools::flattenEdgeField(aMesh.magLe(), true))
Field with dimensions and associated with geometry type GeoMesh which is used to size the field and a...
Generic templated field type.
Generic GeometricField class.
A list of keyword definitions, which are a keyword followed by a number of values (eg,...
A class for handling file names.
Watches for presence of the named trigger file in the case directory and signals a simulation stop (o...
static tmp< scalarField > weightingFactor(const Field< WeightType > &weightField, const bool useMag)
Weighting factor.
tmp< Field< Type > > getFieldValues(const word &fieldName, const bool mandatory=false) const
Return field values by looking up field name.
label writeAll(const vectorField &Sf, const Field< WeightType > &weightField, const pointField &points, const faceList &faces)
Templated helper function to output field values.
bool canWeight(const Field< WeightType > &fld) const
True if field is non-empty on any processor.
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 validField(const word &fieldName) const
Return true if the field name is known and a valid type.
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.
tmp< Field< Type > > filterField(const GeometricField< Type, fvsPatchField, surfaceMesh > &field) const
Filter a surface field according to faceIds.
Type processValues(const Field< Type > &values, const vectorField &Sf, const Field< WeightType > &weightField) const
Apply the 'operation' to the values. Wrapper around.
Computes the magnitude of an input field.
Uses the cell value for any location within the cell.
A traits class, which is primarily used for primitives.
splitCell * master() const
A class for managing temporary objects.
A class for handling words, derived from Foam::string.
#define FatalErrorInFunction
Report an error message using Foam::FatalError.
word outputName("finiteArea-edges.obj")
#define WarningInFunction
Report a warning using Foam::Warning.
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.
prefixOSstream Pout
OSstream wrapped stdout (std::cout) with parallel prefix.
errorManipArg< error, int > exit(error &err, const int errNo=1)
Type gMax(const FieldField< Field, Type > &f)
constexpr char nl
The newline '\n' character (0x0a)
constexpr char tab
The tab '\t' character(0x09)
Fields (face and point) for polySurface.
#define forAll(list, i)
Loop across all elements in list.
IOdictionary propsDict(dictIO)