46 regionType_ != regionTypes::sampledSurface
47 && obr_.foundObject<sf>(fieldName)
52 else if (obr_.foundObject<vf>(fieldName))
65 const word& fieldName,
67 const bool applyOrientation
75 regionType_ != regionTypes::sampledSurface
76 && obr_.foundObject<sf>(fieldName)
79 return filterField(obr_.lookupObject<sf>(fieldName), applyOrientation);
81 else if (obr_.foundObject<vf>(fieldName))
83 const vf&
fld = obr_.lookupObject<vf>(fieldName);
85 if (surfacePtr_.valid())
87 if (surfacePtr_().interpolate())
94 const faceList& faces = surfacePtr_().faces();
103 const face&
f = faces[facei];
106 avg[facei] += intFld[f[fp]];
108 avg[facei] /= f.
size();
115 return surfacePtr_().sample(fld);
120 return filterField(fld, applyOrientation);
127 <<
"Field " << fieldName <<
" not found in database" 149 result =
sum(values);
152 case operationType::weightedSum:
154 if (weightField.
size())
156 result =
sum(weightField*values);
160 result =
sum(values);
169 case operationType::sumDirection:
172 <<
"Operation " << operationTypeNames_[operation_]
173 <<
" not available for values of type " 180 case operationType::sumDirectionBalance:
183 <<
"Operation " << operationTypeNames_[operation_]
184 <<
" not available for values of type " 193 result =
sum(values)/values.
size();
196 case operationType::weightedAverage:
198 if (weightField.
size())
200 result =
sum(weightField*values)/
sum(weightField);
204 result =
sum(values)/values.
size();
208 case operationType::areaAverage:
212 result =
sum(magSf*values)/
sum(magSf);
215 case operationType::weightedAreaAverage:
219 if (weightField.
size())
221 result =
sum(weightField*magSf*values)/
sum(magSf*weightField);
225 result =
sum(magSf*values)/
sum(magSf);
229 case operationType::areaIntegrate:
233 result =
sum(magSf*values);
236 case operationType::weightedAreaIntegrate:
240 if (weightField.
size())
242 result =
sum(weightField*magSf*values);
246 result =
sum(magSf*values);
252 result =
min(values);
257 result =
max(values);
260 case operationType::CoV:
264 Type meanValue =
sum(values*magSf)/
sum(magSf);
279 case operationType::areaNormalAverage:
281 case operationType::areaNormalIntegrate:
283 case operationType::none:
299 return processSameTypeValues(values, Sf, weightField);
309 const word& fieldName,
314 const bool ok = validField<Type>(fieldName);
318 Field<Type> values(getFieldValues<Type>(fieldName,
true, orient));
321 if (surfacePtr_.valid())
324 Sf = surfacePtr_().Sf();
329 Sf = filterField(mesh_.Sf(),
true);
333 combineFields(values);
337 if (surfaceWriterPtr_.valid())
342 if (surfacePtr_.valid())
344 combineSurfaceGeometry(faces, points);
348 combineMeshGeometry(faces, points);
351 if (Pstream::master())
353 surfaceWriterPtr_->write
356 regionTypeNames_[regionType_] + (
"_" + regionName_),
366 if (operation_ != operationType::none)
369 values *= scaleFactor_;
371 if (Pstream::master())
373 Type result = processValues(values, Sf, weightField);
376 resultDict_.add(fieldName, result,
true);
380 Log <<
" " << operationTypeNames_[operation_]
381 <<
"(" << regionName_ <<
") of " << fieldName
382 <<
" = " << result <<
endl;
396 const bool applyOrientation
404 label facei = faceId_[i];
414 << regionTypeNames_[regionType_] <<
"(" << regionName_ <<
"):" 416 <<
" Unable to process internal faces for volume field " 421 if (applyOrientation)
425 values[i] *= faceSign_[i];
438 const bool applyOrientation
446 label facei = faceId_[i];
454 values[i] = field[facei];
458 if (applyOrientation)
462 values[i] *= faceSign_[i];
#define forAll(list, i)
Loop across all elements in list.
intWM_LABEL_SIZE_t label
A label is an int32_t or int64_t as specified by the pre-processor macro WM_LABEL_SIZE.
const word & name() const
Return name.
errorManipArg< error, int > exit(error &err, const int errNo=1)
A face is a list of labels corresponding to mesh vertices.
dimensioned< Type > max(const dimensioned< Type > &, const dimensioned< Type > &)
#define FatalErrorInFunction
Report an error message using Foam::FatalError.
const Boundary & boundaryField() const
Return const-reference to the boundary field.
T & ref() const
Return non-const reference or generate a fatal error.
dimensionedSymmTensor sqr(const dimensionedVector &dv)
void size(const label)
Override size to be inconsistent with allocated storage.
dimensionedScalar sqrt(const dimensionedScalar &ds)
Ostream & endl(Ostream &os)
Add newline and flush stream.
Traits class for primitives.
Generic GeometricField class.
dimensioned< Type > sum(const DimensionedField< Type, GeoMesh > &df)
gmvFile<< "tracers "<< particles.size()<< nl;forAllConstIter(Cloud< passiveParticle >, particles, iter){ gmvFile<< iter().position().x()<< ' ';}gmvFile<< nl;forAllConstIter(Cloud< passiveParticle >, particles, iter){ gmvFile<< iter().position().y()<< ' ';}gmvFile<< nl;forAllConstIter(Cloud< passiveParticle >, particles, iter){ gmvFile<< iter().position().z()<< ' ';}gmvFile<< nl;forAll(lagrangianScalarNames, i){ const word &name=lagrangianScalarNames[i];IOField< scalar > fld(IOobject(name, runTime.timeName(), cloud::prefix, mesh, IOobject::MUST_READ, IOobject::NO_WRITE))
Pre-declare SubField and related Field type.
A class for handling words, derived from string.
bool validField(const word &fieldName) const
Return true if the field name is valid.
Type processValues(const Field< Type > &values, const vectorField &Sf, const scalarField &weightField) const
Apply the 'operation' to the values. Wrapper around.
tmp< Field< Type > > getFieldValues(const word &fieldName, const bool mustGet=false, const bool applyOrientation=false) const
Return field values by looking up field name.
errorManip< error > abort(error &err)
tmp< Field< cmptType > > component(const direction) const
Return a component field of the field.
void cmptMag(FieldField< Field, Type > &cf, const FieldField< Field, Type > &f)
tmp< Field< Type > > filterField(const GeometricField< Type, fvsPatchField, surfaceMesh > &field, const bool applyOrientation) const
Filter a surface field according to faceIds.
Type processSameTypeValues(const Field< Type > &values, const vectorField &Sf, const scalarField &weightField) const
Apply the 'operation' to the values. Operation has to.
dimensioned< Type > min(const dimensioned< Type > &, const dimensioned< Type > &)
volScalarField sf(fieldObject, mesh)
word name(const complex &)
Return a string representation of a complex.
static tmp< GeometricField< Type, fvsPatchField, surfaceMesh > > interpolate(const GeometricField< Type, fvPatchField, volMesh > &tvf, const surfaceScalarField &faceFlux, Istream &schemeData)
Interpolate field onto faces using scheme given by Istream.
Given cell centre values and point (vertex) values decompose into tetrahedra and linear interpolate w...
bool writeValues(const word &fieldName, const scalarField &weightField, const bool orient)
Templated helper function to output field values.
fileType type(const fileName &, const bool checkVariants=true, const bool followLink=true)
Return the file type: directory or file.
#define Log
Report write to Foam::Info if the local log switch is true.
tmp< GeometricField< Type, fvPatchField, volMesh > > average(const GeometricField< Type, fvsPatchField, surfaceMesh > &ssf)
Area-weighted average a surfaceField creating a volField.
dimensioned< scalar > mag(const dimensioned< Type > &)
A class for managing temporary objects.
label & setComponent(label &l, const direction)
void component(FieldField< Field, typename FieldField< Field, Type >::cmptType > &sf, const FieldField< Field, Type > &f, const direction d)
dimensioned< scalar > sumMag(const DimensionedField< Type, GeoMesh > &df)