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))
174 tmp<scalarField> weight
176 weightingFactor(weightField, Sf, is_magOp())
189 case opSumDirectionBalance:
192 <<
"Operation " << operationTypeNames_[operation_]
193 <<
" not available for values of type " 194 << pTraits<Type>::typeName
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))
249 tmp<scalarField> factor
251 areaWeightingFactor(weightField, Sf, is_magOp())
259 tmp<scalarField> factor(
mag(Sf));
268 const scalar gSumMagSf =
gSum(magSf);
270 Type meanValue =
gSum(
values*magSf)/gSumMagSf;
272 for (
direction d=0; d < pTraits<Type>::nComponents; ++d)
274 tmp<scalarField> vals(
values.component(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);
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.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.
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)