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>
173 case opAbsWeightedSum:
175 if (is_weightedOp() && canWeight(weightField))
177 tmp<scalarField> weight
179 weightingFactor(weightField, Sf, is_magOp())
192 case opSumDirectionBalance:
195 <<
"Operation " << operationTypeNames_[operation_]
196 <<
" not available for values of type " 197 << pTraits<Type>::typeName
203 case opWeightedAverage:
204 case opAbsWeightedAverage:
206 if (is_weightedOp() && canWeight(weightField))
210 weightingFactor(weightField, Sf, is_magOp())
225 case opWeightedAreaAverage:
226 case opAbsWeightedAreaAverage:
228 if (is_weightedOp() && canWeight(weightField))
232 areaWeightingFactor(weightField, Sf, is_magOp())
246 case opAreaIntegrate:
247 case opWeightedAreaIntegrate:
248 case opAbsWeightedAreaIntegrate:
250 if (is_weightedOp() && canWeight(weightField))
252 tmp<scalarField> factor
254 areaWeightingFactor(weightField, Sf, is_magOp())
262 tmp<scalarField> factor(
mag(Sf));
271 const scalar gSumMagSf =
gSum(magSf);
273 Type meanValue =
gSum(
values*magSf)/gSumMagSf;
277 tmp<scalarField> vals(
values.component(d));
278 const scalar mean =
component(meanValue, d);
283 /(mean + ROOTVSMALL);
289 case opAreaNormalAverage:
290 case opAreaNormalIntegrate:
297 case opWeightedUniformity:
298 case opAbsWeightedUniformity:
300 if (is_weightedOp() && canWeight(weightField))
303 return processValues<Type, scalar>
307 weightingFactor(weightField, is_magOp())
319 template<
class Type,
class WeightType>
327 return processSameTypeValues(
values, Sf, weightField);
331 template<
class WeightType>
340 label nProcessed = 0;
348 if (
Pstream::master() && surfaceWriterPtr_ && surfaceWriterPtr_->enabled())
350 auto&
writer = *surfaceWriterPtr_;
358 / regionTypeNames_[regionType_] + (
"_" + regionName_)
366 for (
const word& fieldName : fields_)
370 writeValues<scalar>(fieldName, Sf, weightField,
points, faces)
371 || writeValues<vector>(fieldName, Sf, weightField,
points, faces)
372 || writeValues<sphericalTensor>
374 fieldName, Sf, weightField,
points, faces
376 || writeValues<symmTensor>(fieldName, Sf, weightField,
points, faces)
377 || writeValues<tensor>(fieldName, Sf, weightField,
points, faces)
385 <<
"Requested field " << fieldName
386 <<
" not found in database and not processed" 392 if (
Pstream::master() && surfaceWriterPtr_ && surfaceWriterPtr_->enabled())
394 auto&
writer = *surfaceWriterPtr_;
412 template<
class Type,
class WeightType>
415 const word& fieldName,
422 const bool ok = validField<Type>(fieldName);
429 if (surfaceWriterPtr_ && surfaceWriterPtr_->enabled())
432 combineFields(allValues);
437 surfaceWriterPtr_->write(fieldName, allValues);
446 if (operation_ != opNone)
451 Type result = processValues(
values, Sf, weightField);
453 switch (postOperation_)
474 if (postOperation_ != postOpNone)
477 prefix += postOperationTypeNames_[postOperation_];
482 prefix += operationTypeNames_[operation_];
487 word resultName = prefix + regionName_ +
',' + fieldName + suffix;
491 Log <<
" " << prefix << regionName_ << suffix
492 <<
" of " << fieldName <<
" = ";
499 bool alwaysScalar(operation_ & typeScalar);
505 if (postOperation_ == postOpMag)
507 sresult =
mag(sresult);
510 else if (postOperation_ == postOpMag)
512 sresult =
mag(result);
519 file()<<
tab << sresult;
523 this->setResult(resultName, sresult);
527 file()<<
tab << result;
531 this->setResult(resultName, result);
551 auto&
values = tvalues.ref();
555 const label facei = faceId_[i];
556 const label patchi = facePatchId_[i];
584 auto&
values = tvalues.ref();
588 const label facei = faceId_[i];
589 const label patchi = facePatchId_[i];
603 Pout<<
"field " <<
field.name() <<
" oriented: " 607 if (
field.is_oriented())
A class for handling file names.
errorManipArg< error, int > exit(error &err, const int errNo=1)
dimensioned< typename typeOfMag< Type >::type > mag(const dimensioned< Type > &dt)
vtk::lineWriter writer(edgeCentres, edgeList::null(), fileName(aMesh.time().globalPath()/"finiteArea-edgesCentres"))
error FatalError
Error stream (stdout output on all processes), with additional 'FOAM FATAL ERROR' header text and sta...
A list of keyword definitions, which are a keyword followed by a number of values (eg...
#define FatalErrorInFunction
Report an error message using Foam::FatalError.
Type gMin(const FieldField< Field, Type > &f)
dimensionedSymmTensor sqr(const dimensionedVector &dv)
constexpr char nl
The newline '\n' character (0x0a)
Fields (face and point) for polySurface.
dimensionedScalar sqrt(const dimensionedScalar &ds)
Ostream & endl(Ostream &os)
Add newline and flush stream.
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.
constexpr char tab
The tab '\t' character(0x09)
Generic GeometricField class.
::Foam::direction nComponents(const expressions::valueTypeCode) noexcept
The number of components associated with given valueTypeCode.
T returnReduce(const T &value, const BinaryOp &bop, const int tag=UPstream::msgType(), const label comm=UPstream::worldComm)
Perform reduction on a copy, using specified binary operation.
tmp< Field< Type > > getFieldValues(const word &fieldName, const bool mandatory=false) const
Return field values by looking up field name.
IOdictionary propsDict(dictIO)
#define forAll(list, i)
Loop across all elements in list.
List< T > values(const HashTable< T, Key, Hash > &tbl, const bool doSort=false)
List of values from HashTable, optionally sorted.
word outputName("finiteArea-edges.obj")
Type gSum(const FieldField< Field, Type > &f)
Type processSameTypeValues(const Field< Type > &values, const vectorField &Sf, const Field< WeightType > &weightField) const
Apply the 'operation' to the values. Operation must preserve Type.
label writeAll(const vectorField &Sf, const Field< WeightType > &weightField, const pointField &points, const faceList &faces)
Templated helper function to output field values.
Generic templated field type.
A class for handling words, derived from Foam::string.
Field< scalar > scalarField
Specialisation of Field<T> for scalar.
bool validField(const word &fieldName) const
Return true if the field name is known and a valid type.
tmp< Field< Type > > filterField(const GeometricField< Type, fvsPatchField, surfaceMesh > &field) const
Filter a surface field according to faceIds.
errorManip< error > abort(error &err)
void cmptMag(FieldField< Field, Type > &cf, const FieldField< Field, Type > &f)
int debug
Static debugging option.
Type gMax(const FieldField< Field, Type > &f)
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))
#define WarningInFunction
Report a warning using Foam::Warning.
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.
static bool master(const label communicator=worldComm)
True if process corresponds to the master rank in the communicator.
Field with dimensions and associated with geometry type GeoMesh which is used to size the field and a...
static tmp< scalarField > weightingFactor(const Field< WeightType > &weightField, const bool useMag)
Weighting factor.
bool canWeight(const Field< WeightType > &fld) const
True if field is non-empty on any processor.
A class for managing temporary objects.
bool returnReduceOr(const bool value, const label comm=UPstream::worldComm)
Perform logical (or) MPI Allreduce on a copy. Uses UPstream::reduceOr.
label & setComponent(label &val, const direction) noexcept
Non-const access to integer-type (has no components)
void component(FieldField< Field, typename FieldField< Field, Type >::cmptType > &sf, const FieldField< Field, Type > &f, const direction d)
prefixOSstream Pout
OSstream wrapped stdout (std::cout) with parallel prefix.
Uses the cell value for any location within the cell.
static constexpr const zero Zero
Global zero (0)