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())
201 sum(weightField*values)
206 result =
sum(values)/values.
size();
210 case operationType::areaAverage:
214 result =
sum(magSf*values)/
sum(magSf);
217 case operationType::weightedAreaAverage:
221 if (weightField.
size())
224 sum(weightField*magSf*values)
229 result =
sum(magSf*values)/
sum(magSf);
233 case operationType::areaIntegrate:
237 result =
sum(magSf*values);
240 case operationType::weightedAreaIntegrate:
244 if (weightField.
size())
246 result =
sum(weightField*magSf*values);
250 result =
sum(magSf*values);
256 result =
min(values);
261 result =
max(values);
264 case operationType::CoV:
268 Type meanValue =
sum(values*magSf)/
sum(magSf);
283 case operationType::areaNormalAverage:
285 case operationType::areaNormalIntegrate:
287 case operationType::none:
303 return processSameTypeValues(values, Sf, weightField);
313 const word& fieldName,
318 const bool ok = validField<Type>(fieldName);
322 Field<Type> values(getFieldValues<Type>(fieldName,
true, orient));
325 if (surfacePtr_.valid())
328 Sf = surfacePtr_().Sf();
333 Sf = filterField(mesh_.Sf(),
true);
337 combineFields(values);
341 if (surfaceWriterPtr_.valid())
346 if (surfacePtr_.valid())
348 combineSurfaceGeometry(faces, points);
352 combineMeshGeometry(faces, points);
355 if (Pstream::master())
357 surfaceWriterPtr_->write
360 regionTypeNames_[regionType_] + (
"_" + regionName_),
370 if (operation_ != operationType::none)
373 values *= scaleFactor_;
375 if (Pstream::master())
377 Type result = processValues(values, Sf, weightField);
380 resultDict_.add(fieldName, result,
true);
384 Log <<
" " << operationTypeNames_[operation_]
385 <<
"(" << regionName_ <<
") of " << fieldName
386 <<
" = " << result <<
endl;
400 const bool applyOrientation
408 label facei = faceId_[i];
418 << regionTypeNames_[regionType_] <<
"(" << regionName_ <<
"):" 420 <<
" Unable to process internal faces for volume field " 425 if (applyOrientation)
429 values[i] *= faceSign_[i];
442 const bool applyOrientation
450 label facei = faceId_[i];
458 values[i] = field[facei];
462 if (applyOrientation)
466 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.
tmp< DimensionedField< scalar, GeoMesh > > stabilise(const DimensionedField< scalar, GeoMesh > &dsf, const dimensioned< scalar > &ds)
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)