44 if (regionType_ != stSampledSurface && obr_.foundObject<sf>(fieldName))
48 else if (obr_.foundObject<vf>(fieldName))
61 const word& fieldName,
63 const bool applyOrientation
69 if (regionType_ != stSampledSurface && obr_.foundObject<sf>(fieldName))
71 return filterField(obr_.lookupObject<sf>(fieldName), applyOrientation);
73 else if (obr_.foundObject<vf>(fieldName))
75 const vf&
fld = obr_.lookupObject<vf>(fieldName);
77 if (surfacePtr_.valid())
79 if (surfacePtr_().interpolate())
86 const faceList& faces = surfacePtr_().faces();
95 const face&
f = faces[facei];
98 avg[facei] += intFld[f[fp]];
100 avg[facei] /= f.
size();
107 return surfacePtr_().sample(fld);
112 return filterField(fld, applyOrientation);
119 <<
"Field " << fieldName <<
" not found in database" 141 result =
sum(values);
146 if (weightField.
size())
148 result =
sum(weightField*values);
152 result =
sum(values);
164 <<
"Operation " << operationTypeNames_[operation_]
165 <<
" not available for values of type " 172 case opSumDirectionBalance:
175 <<
"Operation " << operationTypeNames_[operation_]
176 <<
" not available for values of type " 185 result =
sum(values)/values.
size();
188 case opWeightedAverage:
190 if (weightField.
size())
192 result =
sum(weightField*values)/
sum(weightField);
196 result =
sum(values)/values.
size();
204 result =
sum(magSf*values)/
sum(magSf);
207 case opWeightedAreaAverage:
211 if (weightField.
size())
213 result =
sum(weightField*magSf*values)/
sum(magSf*weightField);
217 result =
sum(magSf*values)/
sum(magSf);
221 case opAreaIntegrate:
225 result =
sum(magSf*values);
228 case opWeightedAreaIntegrate:
232 if (weightField.
size())
234 result =
sum(weightField*magSf*values);
238 result =
sum(magSf*values);
244 result =
min(values);
249 result =
max(values);
256 Type meanValue =
sum(values*magSf)/
sum(magSf);
271 case opAreaNormalAverage:
273 case opAreaNormalIntegrate:
291 return processSameTypeValues(values, Sf, weightField);
301 const word& fieldName,
306 const bool ok = validField<Type>(fieldName);
310 Field<Type> values(getFieldValues<Type>(fieldName,
true, orient));
313 if (surfacePtr_.valid())
316 Sf = surfacePtr_().Sf();
321 Sf = filterField(mesh_.Sf(),
true);
325 combineFields(values);
329 if (surfaceWriterPtr_.valid())
334 if (surfacePtr_.valid())
336 combineSurfaceGeometry(faces, points);
340 combineMeshGeometry(faces, points);
343 if (Pstream::master())
345 surfaceWriterPtr_->write
348 regionTypeNames_[regionType_] + (
"_" + regionName_),
358 if (operation_ != opNone)
361 values *= scaleFactor_;
363 if (Pstream::master())
365 Type result = processValues(values, Sf, weightField);
368 resultDict_.add(fieldName, result,
true);
370 file() <<
tab << result;
372 Log <<
" " << operationTypeNames_[operation_]
373 <<
"(" << regionName_ <<
") of " << fieldName
374 <<
" = " << result <<
endl;
388 const bool applyOrientation
396 label facei = faceId_[i];
406 << regionTypeNames_[regionType_] <<
"(" << regionName_ <<
"):" 408 <<
" Unable to process internal faces for volume field " 413 if (applyOrientation)
417 values[i] *= faceSign_[i];
430 const bool applyOrientation
438 label facei = faceId_[i];
446 values[i] = field[facei];
450 if (applyOrientation)
454 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.
#define Log
Report write to Foam::Info if the local log switch is true.
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)