65 if (selectionType_ == selectionTypes::sampledSurface)
72 if (surfacePtr_().interpolate())
80 const faceList& faces = surfacePtr_().faces();
85 const face&
f = faces[facei];
88 avg[facei] += intFld[
f[fp]];
90 avg[facei] /=
f.size();
97 return surfacePtr_().sample(
fld);
103 <<
"Surface field " << fieldName
104 <<
" cannot be sampled onto surface " << surfacePtr_().name()
105 <<
". Only vol fields can be sampled onto surfaces."
115 return filterField(
fld);
121 return filterField(
fld);
126 <<
"Field " << fieldName <<
" not found in database"
133 template<
class Type,
class ResultType>
157 return processValuesTypeType(values, signs, weights, Sf, result);
173 case operationType::minMag:
178 case operationType::maxMag:
207 result =
gSum(weights*values);
215 case operationType::orientedSum:
217 result =
gSum(signs*weights*values);
227 case operationType::areaAverage:
231 gSum(weights*magSf*values)
235 case operationType::areaIntegrate:
238 result =
gSum(weights*magSf*values);
243 result =
gMin(values);
248 result =
gMax(values);
251 case operationType::CoV:
255 const Type meanValue =
gSum(values*magSf)/
gSum(magSf);
262 const scalar mean =
component(meanValue, d);
274 case operationType::UI:
278 const Type meanValue =
gSum(values*magSf)/
gSum(magSf);
285 const scalar mean =
component(meanValue, d);
297 case operationType::none:
314 const word& fieldName,
322 if (operation_ != operationType::none)
326 #define writeValuesFieldType(fieldType, none) \
330 const bool typeOk = \
331 processValues(values, signs, weights, Sf, result); \
336 resultDict_.add(fieldName, result, true); \
339 if (Pstream::master()) \
341 file() << tab << result; \
343 Log << " " << operationTypeNames_[operation_] \
344 << "(" << selectionName_.c_str() << ") of " \
345 << fieldName << " = " << result << endl; \
352 #undef writeValuesFieldType
357 <<
"Operation " << operationTypeNames_[operation_]
358 <<
" not available for values of type "
378 const label facei = faceId_[i];
389 << selectionTypeNames[selectionType_]
390 <<
"(" << selectionName_.c_str() <<
"):"
392 <<
" Unable to process internal faces for volume field "
413 const label facei = faceId_[i];
422 values[i] = field[facei];
#define forAll(list, i)
Loop across all elements in list.
Pre-declare SubField and related Field type.
tmp< Field< cmptType > > component(const direction) const
Return a component field of the field.
Generic GeometricField class.
const Boundary & boundaryField() const
Return const-reference to the boundary field.
const word & name() const
Return name.
void size(const label)
Override size to be inconsistent with allocated storage.
A face is a list of labels corresponding to mesh vertices.
void writeValues(const word &fieldName, const Field< Type > &values, const scalarField &signs, const scalarField &weights, const vectorField &Sf)
Templated helper function to output field values.
tmp< Field< Type > > getFieldValues(const word &fieldName) const
Return field values by looking up field name.
bool processValuesTypeType(const Field< Type > &values, const scalarField &signs, const scalarField &weights, const vectorField &Sf, Type &result) const
Apply a Type -> Type operation to the values.
selectionTypes selectionType_
Selection type.
bool validField(const word &fieldName) const
Return true if the field name is valid.
bool processValues(const Field< Type > &values, const scalarField &signs, const scalarField &weights, const vectorField &Sf, ResultType &result) const
Apply the operation to the values, and return true if successful.
tmp< Field< Type > > filterField(const SurfaceField< Type > &field) const
Filter a surface field according to faceIds.
const objectRegistry & obr_
Reference to the objectRegistry.
Given cell centre values and point (vertex) values decompose into tetrahedra and linear interpolate w...
bool foundObject(const word &name) const
Is the named Type in registry.
Traits class for primitives.
A class for managing temporary objects.
T & ref() const
Return non-const reference or generate a fatal error.
A class for handling words, derived from string.
#define FatalErrorInFunction
Report an error message using Foam::FatalError.
gmvFile<< "tracers "<< particles.size()<< nl;{ pointField positions(particles.size());label particlei=0;forAllConstIter(lagrangian::Cloud< passiveParticle >, particles, iter) { positions[particlei++]=iter().position(mesh);} for(i=0;i< pTraits< point >::nComponents;i++) { forAll(positions, particlei) { gmvFile<< component(positions[particlei], i)<< ' ';} gmvFile<< nl;}}forAll(lagrangianScalarNames, i){ const word &name=lagrangianScalarNames[i];IOField< scalar > fld(IOobject(name, runTime.name(), lagrangian::cloud::prefix, mesh, IOobject::MUST_READ, IOobject::NO_WRITE))
static tmp< SurfaceField< Type > > interpolate(const VolField< Type > &tvf, const surfaceScalarField &faceFlux, Istream &schemeData)
Interpolate field onto faces using scheme given by Istream.
tmp< VolField< Type > > average(const SurfaceField< Type > &ssf)
Area-weighted average a surfaceField creating a volField.
Scalar protectedDivide(const Scalar a, const Scalar b)
Divide two numbers and protect the result from overflowing.
errorManipArg< error, int > exit(error &err, const int errNo=1)
Type gSum(const FieldField< Field, Type > &f)
intWM_LABEL_SIZE_t label
A label is an int32_t or int64_t as specified by the pre-processor macro WM_LABEL_SIZE.
label & setComponent(label &l, const direction)
errorManip< error > abort(error &err)
dimensioned< scalar > sumMag(const DimensionedField< Type, GeoMesh, PrimitiveField > &df)
tmp< DimensionedField< scalar, GeoMesh, Field > > stabilise(const DimensionedField< scalar, GeoMesh, PrimitiveField > &dsf, const dimensioned< scalar > &ds)
void mag(LagrangianPatchField< scalar > &f, const LagrangianPatchField< Type > &f1)
layerAndWeight min(const layerAndWeight &a, const layerAndWeight &b)
void component(LagrangianPatchField< typename LagrangianPatchField< Type >::cmptType > &sf, const LagrangianPatchField< Type > &f, const direction d)
dimensioned< Type > sum(const DimensionedField< Type, GeoMesh, PrimitiveField > &df)
layerAndWeight max(const layerAndWeight &a, const layerAndWeight &b)
void sqr(LagrangianPatchField< typename outerProduct< Type, Type >::type > &f, const LagrangianPatchField< Type > &f1)
word name(const LagrangianState state)
Return a string representation of a Lagrangian state enumeration.
FOR_ALL_FIELD_TYPES(makeFieldSourceTypedef)
Type gMin(const FieldField< Field, Type > &f)
void sqrt(LagrangianPatchField< scalar > &f, const LagrangianPatchField< scalar > &f1)
Type gMax(const FieldField< Field, Type > &f)
void cmptMag(LagrangianPatchField< Type > &f, const LagrangianPatchField< Type > &f1)
fileType type(const fileName &, const bool checkVariants=true, const bool followLink=true)
Return the file type: directory or file.
#define writeValuesFieldType(fieldType, none)