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 Type meanValue =
gSum(values*magSf)/
gSum(magSf);
270 case operationType::none:
287 const word& fieldName,
293 const bool ok = validField<Type>(fieldName);
298 Field<Type> values(getFieldValues<Type>(fieldName));
306 if (selectionType_ == selectionTypes::sampledSurface)
308 combineSurfaceGeometry(faces,
points);
312 combineMeshGeometry(faces,
points);
316 combineFields(writeValues);
320 surfaceWriterPtr_->write
324 +
'_' + selectionTypeNames[selectionType_]
325 +
'_' + selectionName_,
336 if (operation_ != operationType::none)
339 values *= scaleFactor_;
343 #define writeValuesFieldType(fieldType, none) \
346 || writeValues<Type, fieldType> \
355 #undef writeValuesFieldType
360 <<
"Operation " << operationTypeNames_[operation_]
361 <<
" not available for values of type "
372 template<
class Type,
class ResultType>
375 const word& fieldName,
384 if (processValues(values, signs, weights, Sf, result))
387 resultDict_.add(fieldName, result,
true);
393 Log <<
" " << operationTypeNames_[operation_]
394 <<
"(" << selectionName_ <<
") of " << fieldName
395 <<
" = " << result <<
endl;
417 const label facei = faceId_[i];
428 << selectionTypeNames[selectionType_]
429 <<
"(" << selectionName_ <<
"):"
431 <<
" Unable to process internal faces for volume field "
452 const label facei = faceId_[i];
461 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.
static bool master(const label communicator=0)
Am I the master process.
A face is a list of labels corresponding to mesh vertices.
tmp< Field< Type > > getFieldValues(const word &fieldName) const
Return field values by looking up field name.
bool writeValues(const word &fieldName, const scalarField &signs, const scalarField &weights, const vectorField &Sf)
Templated helper function to output field values.
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 region 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(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(), cloud::prefix, mesh, IOobject::MUST_READ, IOobject::NO_WRITE))
#define Log
Report write to Foam::Info if the local log switch is true.
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.
errorManipArg< error, int > exit(error &err, const int errNo=1)
Type gSum(const FieldField< Field, Type > &f)
tmp< DimensionedField< scalar, GeoMesh > > stabilise(const DimensionedField< scalar, GeoMesh > &dsf, const dimensioned< scalar > &ds)
intWM_LABEL_SIZE_t label
A label is an int32_t or int64_t as specified by the pre-processor macro WM_LABEL_SIZE.
dimensionedSymmTensor sqr(const dimensionedVector &dv)
Ostream & endl(Ostream &os)
Add newline and flush stream.
word name(const bool)
Return a word representation of a bool.
void component(FieldField< Field, typename FieldField< Field, Type >::cmptType > &sf, const FieldField< Field, Type > &f, const direction d)
label & setComponent(label &l, const direction)
dimensioned< Type > sum(const DimensionedField< Type, GeoMesh > &df)
errorManip< error > abort(error &err)
layerAndWeight min(const layerAndWeight &a, const layerAndWeight &b)
dimensionedScalar sqrt(const dimensionedScalar &ds)
dimensioned< scalar > mag(const dimensioned< Type > &)
layerAndWeight max(const layerAndWeight &a, const layerAndWeight &b)
dimensionSet cmptMag(const dimensionSet &)
FOR_ALL_FIELD_TYPES(makeFieldSourceTypedef)
Type gMin(const FieldField< Field, Type > &f)
Type gMax(const FieldField< Field, Type > &f)
fileType type(const fileName &, const bool checkVariants=true, const bool followLink=true)
Return the file type: directory or file.
dimensioned< scalar > sumMag(const DimensionedField< Type, GeoMesh > &df)
#define writeValuesFieldType(fieldType, none)