46 regionType_ != regionTypes::sampledSurface
47 && obr_.foundObject<sf>(fieldName)
52 else if (obr_.foundObject<vf>(fieldName))
71 if (regionType_ == regionTypes::sampledSurface)
73 if (obr_.foundObject<vf>(fieldName))
75 const vf&
fld = obr_.lookupObject<vf>(fieldName);
77 if (surfacePtr_().interpolate())
85 const faceList& faces = surfacePtr_().faces();
90 const face&
f = faces[facei];
93 avg[facei] += intFld[f[fp]];
95 avg[facei] /= f.
size();
102 return surfacePtr_().sample(fld);
105 else if (obr_.foundObject<sf>(fieldName))
108 <<
"Surface field " << fieldName
109 <<
" cannot be sampled onto surface " << surfacePtr_().name()
110 <<
". Only vol fields can be sampled onto surfaces." 116 if (obr_.foundObject<vf>(fieldName))
118 const vf&
fld = obr_.lookupObject<vf>(fieldName);
119 return filterField(fld);
121 else if (obr_.foundObject<sf>(fieldName))
123 const sf&
fld = obr_.lookupObject<sf>(fieldName);
124 return filterField(fld);
129 <<
"Field " << fieldName <<
" not found in database" 136 template<
class Type,
class ResultType>
160 return processValuesTypeType(values, signs, weights, Sf, result);
176 case operationType::minMag:
181 case operationType::maxMag:
209 result =
gSum(weights*values);
217 case operationType::orientedSum:
219 result =
gSum(signs*weights*values);
229 case operationType::areaAverage:
233 gSum(weights*magSf*values)
237 case operationType::areaIntegrate:
240 result =
gSum(weights*magSf*values);
245 result =
gMin(values);
250 result =
gMax(values);
253 case operationType::CoV:
257 Type meanValue =
gSum(values*magSf)/
gSum(magSf);
272 case operationType::none:
289 const word& fieldName,
295 const bool ok = validField<Type>(fieldName);
300 Field<Type> values(getFieldValues<Type>(fieldName));
308 if (regionType_ == regionTypes::sampledSurface)
310 combineSurfaceGeometry(faces, points);
314 combineMeshGeometry(faces, points);
318 combineFields(writeValues);
320 if (Pstream::master())
322 surfaceWriterPtr_->write
326 +
'_' + regionTypeNames_[regionType_]
338 if (operation_ != operationType::none)
341 values *= scaleFactor_;
345 #define writeValuesFieldType(fieldType, none) \ 348 || writeValues<Type, fieldType> \ 357 #undef writeValuesFieldType 362 <<
"Operation " << operationTypeNames_[operation_]
363 <<
" not available for values of type " 374 template<
class Type,
class ResultType>
377 const word& fieldName,
386 if (processValues(values, signs, weights, Sf, result))
389 resultDict_.add(fieldName, result,
true);
391 if (Pstream::master())
395 Log <<
" " << operationTypeNames_[operation_]
396 <<
"(" << regionName_ <<
") of " << fieldName
397 <<
" = " << result <<
endl;
419 const label facei = faceId_[i];
430 << regionTypeNames_[regionType_] <<
"(" << regionName_ <<
"):" 432 <<
" Unable to process internal faces for volume field " 453 const label facei = faceId_[i];
462 values[i] = field[facei];
#define forAll(list, i)
Loop across all elements in list.
layerAndWeight max(const layerAndWeight &a, const layerAndWeight &b)
const word & name() const
Return 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.
errorManipArg< error, int > exit(error &err, const int errNo=1)
A face is a list of labels corresponding to mesh vertices.
#define FatalErrorInFunction
Report an error message using Foam::FatalError.
Type gMin(const FieldField< Field, Type > &f)
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.
#define FOR_ALL_FIELD_TYPES(Macro,...)
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))
Type gSum(const FieldField< Field, Type > &f)
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.
dimensionSet cmptMag(const dimensionSet &)
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 GeometricField< Type, fvsPatchField, surfaceMesh > &field) const
Filter a surface field according to faceIds.
layerAndWeight min(const layerAndWeight &a, const layerAndWeight &b)
tmp< Field< Type > > getFieldValues(const word &fieldName) 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.
#define writeValuesFieldType(fieldType, none)
Type gMax(const FieldField< Field, Type > &f)
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...
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 > &)
bool writeValues(const word &fieldName, const scalarField &signs, const scalarField &weights, const vectorField &Sf)
Templated helper function to output field values.
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)