This function object provides a 'face regionType' variant of the fieldValues function object. Given a list of user-specified fields and a selection of mesh (or general surface) faces, a number of operations can be performed, such as sums, averages and integrations. More...
Public Types | |
enum | regionTypes { stFaceZone, stPatch, stSampledSurface } |
region type enumeration More... | |
enum | operationType { opNone, opSum, opSumMag, opSumDirection, opSumDirectionBalance, opAverage, opWeightedAverage, opAreaAverage, opWeightedAreaAverage, opAreaIntegrate, opMin, opMax, opCoV, opAreaNormalAverage, opAreaNormalIntegrate } |
Operation type enumeration. More... | |
Public Member Functions | |
TypeName ("surfaceRegion") | |
Run-time type information. More... | |
surfaceRegion (const word &name, const Time &runTime, const dictionary &dict) | |
Construct from name, Time and dictionary. More... | |
surfaceRegion (const word &name, const objectRegistry &obr, const dictionary &dict) | |
Construct from name, objectRegistry and dictionary. More... | |
virtual | ~surfaceRegion () |
Destructor. More... | |
const regionTypes & | regionType () const |
Return the region type. More... | |
const labelList & | faceId () const |
Return the local list of face IDs. More... | |
const labelList & | facePatch () const |
Return the local list of patch ID per face. More... | |
const labelList & | faceSign () const |
Return the list of +1/-1 representing face flip map. More... | |
template<class Type > | |
bool | writeValues (const word &fieldName, const scalarField &weightField, const bool orient) |
Templated helper function to output field values. More... | |
template<class Type > | |
tmp< Field< Type > > | filterField (const GeometricField< Type, fvsPatchField, surfaceMesh > &field, const bool applyOrientation) const |
Filter a surface field according to faceIds. More... | |
template<class Type > | |
tmp< Field< Type > > | filterField (const GeometricField< Type, fvPatchField, volMesh > &field, const bool applyOrientation) const |
Filter a volume field according to faceIds. More... | |
virtual bool | read (const dictionary &) |
Read from dictionary. More... | |
virtual bool | write () |
Calculate and write. More... | |
template<> | |
Foam::scalar | processValues (const Field< scalar > &values, const vectorField &Sf, const scalarField &weightField) const |
template<> | |
Foam::vector | processValues (const Field< vector > &values, const vectorField &Sf, const scalarField &weightField) const |
template<> | |
scalar | processValues (const Field< scalar > &values, const vectorField &Sf, const scalarField &weightField) const |
Specialisation for scalar. More... | |
template<> | |
vector | processValues (const Field< vector > &values, const vectorField &Sf, const scalarField &weightField) const |
Specialisation for vector. More... | |
template<class Type > | |
Foam::tmp< Foam::Field< Type > > | getFieldValues (const word &fieldName, const bool mustGet, const bool applyOrientation) const |
template<class Type > | |
Foam::tmp< Foam::Field< Type > > | filterField (const GeometricField< Type, fvPatchField, volMesh > &field, const bool applyOrientation) const |
template<class Type > | |
Foam::tmp< Foam::Field< Type > > | filterField (const GeometricField< Type, fvsPatchField, surfaceMesh > &field, const bool applyOrientation) const |
Public Member Functions inherited from fieldValue | |
TypeName ("fieldValue") | |
Run-time type information. More... | |
declareRunTimeSelectionTable (autoPtr, fieldValue, dictionary,(const word &name, const objectRegistry &obr, const dictionary &dict),(name, obr, dict)) | |
fieldValue (const word &name, const Time &runTime, const dictionary &dict, const word &valueType) | |
Construct from Time and dictionary. More... | |
fieldValue (const word &name, const objectRegistry &obr, const dictionary &dict, const word &valueType) | |
Construct from objectRegistry and dictionary. More... | |
virtual | ~fieldValue () |
Destructor. More... | |
const dictionary & | dict () const |
Return the reference to the construction dictionary. More... | |
const word & | regionName () const |
Return the region name. More... | |
const wordList & | fields () const |
Return the list of field names. More... | |
const Switch & | writeFields () const |
Return the output field values flag. More... | |
const fvMesh & | mesh () const |
Helper function to return the reference to the mesh. More... | |
const dictionary & | resultDict () const |
Return access to the latest set of results. More... | |
virtual bool | execute () |
Execute. More... | |
Public Member Functions inherited from writeFiles | |
writeFiles (const word &name, const Time &time, const dictionary &dict, const word &prefix) | |
Construct from name, Time, dictionary and prefix. More... | |
writeFiles (const word &name, const objectRegistry &obr, const dictionary &dict, const word &prefix) | |
Construct from name, objectRegistry, dictionary and prefix. More... | |
virtual | ~writeFiles () |
Destructor. More... | |
const wordList & | names () const |
Return const access to the names. More... | |
OFstream & | file () |
Return access to the file (if only 1) More... | |
PtrList< OFstream > & | files () |
Return access to the files. More... | |
OFstream & | file (const label i) |
Return file 'i'. More... | |
Public Member Functions inherited from writeFile | |
writeFile (const word &name, const Time &t, const dictionary &dict, const word &prefix) | |
Construct from name, Time, dictionary and prefix. More... | |
writeFile (const word &name, const objectRegistry &obr, const dictionary &dict, const word &prefix) | |
Construct from name, objectRegistry, dictionary and prefix. More... | |
virtual | ~writeFile () |
Destructor. More... | |
void | writeCommented (Ostream &os, const string &str) const |
Write a commented string to stream. More... | |
void | writeTabbed (Ostream &os, const string &str) const |
Write a tabbed string to stream. More... | |
void | writeHeader (Ostream &os, const string &str) const |
Write a commented header to stream. More... | |
void | writeTime (Ostream &os) const |
Write the current time to stream. More... | |
template<class Type > | |
void | writeHeaderValue (Ostream &os, const string &property, const Type &value) const |
Write a (commented) header property and value pair. More... | |
label | charWidth () const |
Return width of character stream output. More... | |
Public Member Functions inherited from regionFunctionObject | |
TypeName ("regionFunctionObject") | |
Runtime type information. More... | |
regionFunctionObject (const word &name, const Time &runTime, const dictionary &dict) | |
Construct from Time and dictionary. More... | |
regionFunctionObject (const word &name, const objectRegistry &obr, const dictionary &dict) | |
Construct from the region objectRegistry and dictionary. More... | |
virtual | ~regionFunctionObject () |
Destructor. More... | |
Public Member Functions inherited from functionObject | |
virtual const word & | type () const =0 |
Runtime type information. More... | |
declareRunTimeSelectionTable (autoPtr, functionObject, dictionary,(const word &name, const Time &runTime, const dictionary &dict),(name, runTime, dict)) | |
functionObject (const word &name) | |
Construct from components. More... | |
autoPtr< functionObject > | clone () const |
Return clone. More... | |
virtual | ~functionObject () |
Destructor. More... | |
const word & | name () const |
Return the name of this functionObject. More... | |
virtual bool | end () |
Called when Time::run() determines that the time-loop exits. More... | |
virtual bool | adjustTimeStep () |
Called at the end of Time::adjustDeltaT() if adjustTime is true. More... | |
virtual void | updateMesh (const mapPolyMesh &mpm) |
Update for changes of mesh. More... | |
virtual void | movePoints (const polyMesh &mesh) |
Update for changes of mesh. More... | |
Static Public Attributes | |
static const NamedEnum< regionTypes, 3 > | regionTypeNames_ |
region type names More... | |
static const NamedEnum< operationType, 15 > | operationTypeNames_ |
Operation type names. More... | |
Static Public Attributes inherited from writeFile | |
static const word | outputPrefix |
Directory prefix. More... | |
static label | addChars = 7 |
Additional characters for writing. More... | |
Static Public Attributes inherited from functionObject | |
static int | debug |
static bool | postProcess |
Global post-processing mode switch. More... | |
Protected Member Functions | |
void | initialise (const dictionary &dict) |
Initialise, e.g. face addressing. More... | |
template<class Type > | |
bool | validField (const word &fieldName) const |
Return true if the field name is valid. More... | |
template<class Type > | |
tmp< Field< Type > > | getFieldValues (const word &fieldName, const bool mustGet=false, const bool applyOrientation=false) const |
Return field values by looking up field name. More... | |
template<class Type > | |
Type | processSameTypeValues (const Field< Type > &values, const vectorField &Sf, const scalarField &weightField) const |
Apply the 'operation' to the values. Operation has to. More... | |
template<class Type > | |
Type | processValues (const Field< Type > &values, const vectorField &Sf, const scalarField &weightField) const |
Apply the 'operation' to the values. Wrapper around. More... | |
virtual void | writeFileHeader (const label i) |
Output file header information. More... | |
Protected Member Functions inherited from fieldValue | |
template<class Type > | |
void | combineFields (Field< Type > &field) |
Combine fields from all processor domains into single field. More... | |
template<class Type > | |
void | combineFields (tmp< Field< Type >> &) |
Combine fields from all processor domains into single field. More... | |
Protected Member Functions inherited from writeFiles | |
virtual void | createFiles () |
Create the output file. More... | |
virtual void | resetNames (const wordList &names) |
Reset the list of names from a wordList. More... | |
virtual void | resetName (const word &name) |
Reset the list of names to a single name entry. More... | |
writeFiles (const writeFiles &) | |
Disallow default bitwise copy construct. More... | |
void | operator= (const writeFiles &) |
Disallow default bitwise assignment. More... | |
Protected Member Functions inherited from writeFile | |
virtual void | initStream (Ostream &os) const |
Initialise the output stream for writing. More... | |
virtual fileName | baseFileDir () const |
Return the base directory for output. More... | |
virtual fileName | baseTimeDir () const |
Return the base directory for the current time value. More... | |
virtual Omanip< int > | valueWidth (const label offset=0) const |
Return the value width when writing to stream with optional offset. More... | |
writeFile (const writeFile &) | |
Disallow default bitwise copy construct. More... | |
void | operator= (const writeFile &) |
Disallow default bitwise assignment. More... | |
Protected Member Functions inherited from regionFunctionObject | |
template<class ObjectType > | |
bool | foundObject (const word &fieldName) const |
Find field in the objectRegistry. More... | |
template<class ObjectType > | |
const ObjectType & | lookupObject (const word &fieldName) const |
Lookup field from the objectRegistry. More... | |
template<class ObjectType > | |
bool | store (word &fieldName, const tmp< ObjectType > &tfield, bool cacheable=false) |
Store the given field in the objectRegistry under the given name. More... | |
bool | writeObject (const word &fieldName) |
Write field if present in objectRegistry. More... | |
bool | clearObject (const word &fieldName) |
Clear field from the objectRegistry if present. More... | |
Protected Attributes | |
autoPtr< surfaceWriter > | surfaceWriterPtr_ |
Surface writer. More... | |
regionTypes | regionType_ |
region type More... | |
operationType | operation_ |
Operation to apply to values. More... | |
word | weightFieldName_ |
Weight field name - optional. More... | |
bool | orientWeightField_ |
Flag to indicate if flipMap should be applied to the weight field. More... | |
label | orientedFieldsStart_ |
Start index of fields that require application of flipMap. More... | |
scalar | scaleFactor_ |
Scale factor - optional. More... | |
scalar | totalArea_ |
Total area of the surfaceRegion. More... | |
bool | writeArea_ |
Optionally write the area of the surfaceRegion. More... | |
label | nFaces_ |
Global number of faces. More... | |
labelList | faceId_ |
Local list of face IDs. More... | |
labelList | facePatchId_ |
Local list of patch ID per face. More... | |
labelList | faceSign_ |
List of +1/-1 representing face flip map. More... | |
autoPtr< sampledSurface > | surfacePtr_ |
Underlying sampledSurface. More... | |
Protected Attributes inherited from fieldValue | |
dictionary | dict_ |
Construction dictionary. More... | |
word | regionName_ |
Name of region (patch, zone, etc.) More... | |
wordList | fields_ |
List of field names to operate on. More... | |
Switch | writeFields_ |
Output field values flag. More... | |
dictionary | resultDict_ |
Results dictionary for external access of results. More... | |
Protected Attributes inherited from writeFile | |
const word | prefix_ |
Prefix. More... | |
Protected Attributes inherited from regionFunctionObject | |
const Time & | time_ |
Reference to the Time. More... | |
const objectRegistry & | obr_ |
Reference to the region objectRegistry. More... | |
Additional Inherited Members | |
Static Public Member Functions inherited from fieldValue | |
static autoPtr< fieldValue > | New (const word &name, const objectRegistry &obr, const dictionary &dict, const bool output=true) |
Return a reference to the selected fieldValue. More... | |
Static Public Member Functions inherited from functionObject | |
static autoPtr< functionObject > | New (const word &name, const Time &, const dictionary &) |
Select from dictionary, based on its "type" entry. More... | |
Public Attributes inherited from functionObject | |
Switch | log |
Switch write log to Info. More... | |
This function object provides a 'face regionType' variant of the fieldValues function object. Given a list of user-specified fields and a selection of mesh (or general surface) faces, a number of operations can be performed, such as sums, averages and integrations.
For example, to calculate the volumetric or mass flux across a patch, apply the 'sum' operator to the flux field (typically phi
)
Example of function object specification:
surfaceRegion1 { type surfaceRegion; libs ("libfieldFunctionObjects.so"); ... log yes; writeFields true; surfaceFormat none; regionType faceZone; name f0; operation sum; weightField alpha1; fields ( p phi U ); }
Property | Description | Required | Default value |
---|---|---|---|
type | type name: surfaceRegion | yes | |
log | write data to standard output | no | no |
writeFields | Write the region field values | yes | |
writeArea | Write the area of the surfaceRegion | no | |
surfaceFormat | output value format | no | |
regionType | face regionType: see below | yes | |
name | name of face regionType if required | no | |
operation | operation to perform | yes | |
weightField | name of field to apply weighting | no | |
orientedWeightField | name of oriented field to apply weighting | no | |
scaleFactor | scale factor | no | 1 |
fields | list of fields to operate on | yes | |
orientedFields | list of oriented fields to operate on | no |
Where regionType
is defined by
faceZone | : | requires a 'name' entry to specify the faceZone |
patch | : | requires a 'name' entry to specify the patch |
sampledSurface | : | requires a 'sampledSurfaceDict' sub-dictionary |
The operation
is one of:
none | : | no operation |
sum | : | sum |
sumMag | : | sum of component magnitudes |
sumDirection | : | sum values which are positive in given direction |
sumDirectionBalance | : | sum of balance of values in given direction |
average | : | ensemble average |
weightedAverage | : | weighted average |
areaAverage | : | area weighted average |
weightedAreaAverage | : | weighted area average |
areaIntegrate | : | area integral |
min | : | minimum |
max | : | maximum |
CoV | : | coefficient of variation: standard deviation/mean |
areaNormalAverage | : | area weighted average in face normal direction |
areaNormalIntegrate | : | area weighted integral in face normal directon |
faceZone
can only consist of boundary facessampledSurfaces:
interpolationCellPoint
otherwise they use cell valuessampledSurface
is logically only in one cell so interpolation will be wrong when triangles are larger than cells. This can only happen for sampling on a triSurfaceMesh
Definition at line 299 of file surfaceRegion.H.
enum regionTypes |
region type enumeration
Enumerator | |
---|---|
stFaceZone | |
stPatch | |
stSampledSurface |
Definition at line 309 of file surfaceRegion.H.
enum operationType |
Operation type enumeration.
Definition at line 321 of file surfaceRegion.H.
surfaceRegion | ( | const word & | name, |
const Time & | runTime, | ||
const dictionary & | dict | ||
) |
Construct from name, Time and dictionary.
Definition at line 644 of file surfaceRegion.C.
References Foam::exit(), Foam::FatalError, FatalErrorInFunction, and Foam::read().
Referenced by surfaceRegion::processValues().
surfaceRegion | ( | const word & | name, |
const objectRegistry & | obr, | ||
const dictionary & | dict | ||
) |
Construct from name, objectRegistry and dictionary.
Definition at line 674 of file surfaceRegion.C.
References Foam::exit(), Foam::FatalError, FatalErrorInFunction, and Foam::read().
|
virtual |
Destructor.
Definition at line 706 of file surfaceRegion.C.
References surfaceRegion::read().
|
protected |
Initialise, e.g. face addressing.
Definition at line 422 of file surfaceRegion.C.
References Foam::endl(), Foam::exit(), Foam::FatalError, FatalErrorInFunction, Foam::FatalIOError, FatalIOErrorInFunction, dictionary::found(), Foam::Info, dictionary::lookup(), Foam::name(), surfaceWriter::New(), Foam::nl, dictionary::readIfPresent(), List< T >::size(), dictionary::subOrEmptyDict(), Foam::type(), and surfaceRegion::writeFileHeader().
Referenced by NamedEnum< Enum, nEnum >::names().
|
protected |
Return true if the field name is valid.
Definition at line 37 of file surfaceRegionTemplates.C.
References surfaceRegion::getFieldValues(), and sf().
|
protected |
Return field values by looking up field name.
Referenced by surfaceRegion::validField().
|
protected |
Apply the 'operation' to the values. Operation has to.
preserve Type.
Definition at line 129 of file surfaceRegionTemplates.C.
References Foam::cmptMag(), Foam::component(), Field< Type >::component(), Foam::exit(), Foam::FatalError, FatalErrorInFunction, Foam::mag(), Foam::max(), Foam::min(), surfaceRegion::processValues(), Foam::setComponent(), List< T >::size(), List< Type >::size(), Foam::sqr(), Foam::sqrt(), Foam::sum(), and Foam::Zero.
Referenced by surfaceRegion::getFieldValues().
|
protected |
Apply the 'operation' to the values. Wrapper around.
processSameTypeValues. See also template specialisation below.
Definition at line 258 of file surfaceRegionTemplates.C.
References surfaceRegion::writeValues().
Referenced by surfaceRegion::processSameTypeValues(), surfaceRegion::processValues(), and surfaceRegion::writeFileHeader().
|
protectedvirtual |
Output file header information.
Reimplemented from writeFile.
Definition at line 537 of file surfaceRegion.C.
References Foam::endl(), forAll, surfaceRegion::processValues(), and Foam::tab.
Referenced by surfaceRegion::initialise().
TypeName | ( | "surfaceRegion" | ) |
Run-time type information.
|
inline |
Return the region type.
Definition at line 31 of file surfaceRegionI.H.
References surfaceRegion::regionType_.
|
inline |
Return the local list of face IDs.
Definition at line 38 of file surfaceRegionI.H.
References surfaceRegion::faceId_.
|
inline |
Return the local list of patch ID per face.
Definition at line 45 of file surfaceRegionI.H.
References surfaceRegion::facePatchId_.
|
inline |
Return the list of +1/-1 representing face flip map.
Definition at line 52 of file surfaceRegionI.H.
References surfaceRegion::faceSign_.
bool writeValues | ( | const word & | fieldName, |
const scalarField & | weightField, | ||
const bool | orient | ||
) |
Templated helper function to output field values.
Definition at line 273 of file surfaceRegionTemplates.C.
References Foam::endl(), surfaceRegion::filterField(), Log, mesh, Foam::name(), points, and Foam::tab.
Referenced by surfaceRegion::processValues().
tmp<Field<Type> > filterField | ( | const GeometricField< Type, fvsPatchField, surfaceMesh > & | field, |
const bool | applyOrientation | ||
) | const |
Filter a surface field according to faceIds.
Referenced by surfaceRegion::filterField(), and surfaceRegion::writeValues().
tmp<Field<Type> > filterField | ( | const GeometricField< Type, fvPatchField, volMesh > & | field, |
const bool | applyOrientation | ||
) | const |
Filter a volume field according to faceIds.
|
virtual |
Read from dictionary.
Reimplemented from fieldValue.
Definition at line 713 of file surfaceRegion.C.
References fieldValue::read().
Referenced by surfaceRegion::~surfaceRegion().
|
virtual |
Calculate and write.
Reimplemented from fieldValue.
Definition at line 724 of file surfaceRegion.C.
References Foam::endl(), forAll, Log, UPstream::master(), Foam::tab, WarningInFunction, and fieldValue::write().
Foam::scalar processValues | ( | const Field< scalar > & | values, |
const vectorField & | Sf, | ||
const scalarField & | weightField | ||
) | const |
Definition at line 567 of file surfaceRegion.C.
References Foam::mag(), n, Foam::neg(), Foam::pos(), surfaceRegion::processValues(), and Foam::sum().
Foam::vector processValues | ( | const Field< vector > & | values, |
const vectorField & | Sf, | ||
const scalarField & | weightField | ||
) | const |
Definition at line 598 of file surfaceRegion.C.
References Foam::mag(), n, Foam::pos(), Foam::sum(), and surfaceRegion::surfaceRegion().
scalar processValues | ( | const Field< scalar > & | values, |
const vectorField & | Sf, | ||
const scalarField & | weightField | ||
) | const |
Specialisation for scalar.
vector processValues | ( | const Field< vector > & | values, |
const vectorField & | Sf, | ||
const scalarField & | weightField | ||
) | const |
Specialisation for vector.
Foam::tmp<Foam::Field<Type> > getFieldValues | ( | const word & | fieldName, |
const bool | mustGet, | ||
const bool | applyOrientation | ||
) | const |
Definition at line 60 of file surfaceRegionTemplates.C.
References Foam::abort(), f(), Foam::FatalError, FatalErrorInFunction, fld(), forAll, Foam::MULES::interpolate(), surfaceRegion::processSameTypeValues(), tmp< T >::ref(), sf(), List< T >::size(), and Foam::Zero.
Foam::tmp<Foam::Field<Type> > filterField | ( | const GeometricField< Type, fvPatchField, volMesh > & | field, |
const bool | applyOrientation | ||
) | const |
Definition at line 360 of file surfaceRegionTemplates.C.
References Foam::abort(), GeometricField< Type, PatchField, GeoMesh >::boundaryField(), Foam::FatalError, FatalErrorInFunction, surfaceRegion::filterField(), forAll, Foam::name(), IOobject::name(), Foam::nl, patchi, tmp< T >::ref(), and Foam::type().
Foam::tmp<Foam::Field<Type> > filterField | ( | const GeometricField< Type, fvsPatchField, surfaceMesh > & | field, |
const bool | applyOrientation | ||
) | const |
Definition at line 402 of file surfaceRegionTemplates.C.
References GeometricField< Type, PatchField, GeoMesh >::boundaryField(), forAll, patchi, and tmp< T >::ref().
|
static |
region type names
Definition at line 317 of file surfaceRegion.H.
Referenced by NamedEnum< Enum, nEnum >::names().
|
static |
Operation type names.
Definition at line 341 of file surfaceRegion.H.
Referenced by NamedEnum< Enum, nEnum >::names().
|
protected |
Surface writer.
Definition at line 380 of file surfaceRegion.H.
|
protected |
region type
Definition at line 383 of file surfaceRegion.H.
Referenced by surfaceRegion::regionType().
|
protected |
Operation to apply to values.
Definition at line 386 of file surfaceRegion.H.
|
protected |
Weight field name - optional.
Definition at line 389 of file surfaceRegion.H.
|
protected |
Flag to indicate if flipMap should be applied to the weight field.
Definition at line 392 of file surfaceRegion.H.
|
protected |
Start index of fields that require application of flipMap.
Definition at line 395 of file surfaceRegion.H.
|
protected |
Scale factor - optional.
Definition at line 398 of file surfaceRegion.H.
|
protected |
Total area of the surfaceRegion.
Definition at line 401 of file surfaceRegion.H.
|
protected |
Optionally write the area of the surfaceRegion.
Definition at line 404 of file surfaceRegion.H.
|
protected |
Global number of faces.
Definition at line 407 of file surfaceRegion.H.
|
protected |
Local list of face IDs.
Definition at line 413 of file surfaceRegion.H.
Referenced by surfaceRegion::faceId().
|
protected |
Local list of patch ID per face.
Definition at line 416 of file surfaceRegion.H.
Referenced by surfaceRegion::facePatch().
|
protected |
List of +1/-1 representing face flip map.
(1 use as is, -1 negate)
Definition at line 420 of file surfaceRegion.H.
Referenced by surfaceRegion::faceSign().
|
protected |
Underlying sampledSurface.
Definition at line 426 of file surfaceRegion.H.