This function object provides a 'face source' 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 | sourceType { stFaceZone, stPatch, stSampledSurface } |
Source 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 ("faceSource") | |
Run-time type information. More... | |
faceSource (const word &name, const objectRegistry &obr, const dictionary &dict, const bool loadFromFiles=false) | |
Construct from components. More... | |
virtual | ~faceSource () |
Destructor. More... | |
const sourceType & | source () const |
Return the source 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... | |
virtual void | read (const dictionary &) |
Read from dictionary. More... | |
virtual void | write () |
Calculate and write. 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... | |
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 of processing scalars. More... | |
template<> | |
vector | processValues (const Field< vector > &values, const vectorField &Sf, const scalarField &weightField) const |
Specialisation of processing vectors. 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 |
![]() | |
TypeName ("fieldValue") | |
Run-time type information. More... | |
declareRunTimeSelectionTable (autoPtr, fieldValue, dictionary,( const word &name, const objectRegistry &obr, const dictionary &dict, const bool loadFromFiles ),(name, obr, dict, loadFromFiles)) | |
fieldValue (const word &name, const objectRegistry &obr, const dictionary &dict, const word &valueType, const bool loadFromFiles=false) | |
Construct from components. More... | |
virtual | ~fieldValue () |
Destructor. More... | |
const word & | name () const |
Return the name of the geometric source. More... | |
const objectRegistry & | obr () const |
Return the reference to the object registry. More... | |
const dictionary & | dict () const |
Return the reference to the construction dictionary. More... | |
bool | active () const |
Return the active flag. More... | |
const Switch & | log () const |
Return the switch to send output to Info as well as to file. More... | |
const word & | sourceName () const |
Return the source name. More... | |
const wordList & | fields () const |
Return the list of field names. More... | |
const Switch & | valueOutput () 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 void | execute () |
Execute. More... | |
virtual void | end () |
Execute the at the final time-loop, currently does nothing. More... | |
virtual void | timeSet () |
Called when time was set at the end of the Time::operator++. More... | |
virtual void | updateMesh (const mapPolyMesh &) |
Update mesh. More... | |
virtual void | movePoints (const polyMesh &) |
Move points. More... | |
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... | |
![]() | |
functionObjectFile (const objectRegistry &obr, const word &prefix) | |
Construct null. More... | |
functionObjectFile (const objectRegistry &obr, const word &prefix, const word &name) | |
Construct from components. More... | |
functionObjectFile (const objectRegistry &obr, const word &prefix, const wordList &names) | |
Construct from components. More... | |
virtual | ~functionObjectFile () |
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... | |
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... | |
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... | |
Static Public Attributes | |
static const NamedEnum< sourceType, 3 > | sourceTypeNames_ |
Source type names. More... | |
static const NamedEnum< operationType, 15 > | operationTypeNames_ |
Operation type names. More... | |
![]() | |
static const word | outputPrefix = "postProcessing" |
Directory prefix. More... | |
static label | addChars = 7 |
Additional characters for writing. 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... | |
![]() | |
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 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... | |
virtual Omanip< int > | valueWidth (const label offset=0) const |
Return the value width when writing to stream with optional offset. More... | |
functionObjectFile (const functionObjectFile &) | |
Disallow default bitwise copy construct. More... | |
void | operator= (const functionObjectFile &) |
Disallow default bitwise assignment. More... | |
Protected Attributes | |
autoPtr< surfaceWriter > | surfaceWriterPtr_ |
Surface writer. More... | |
sourceType | source_ |
Source 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 faceSource. More... | |
bool | writeArea_ |
Optionally write the area of the faceSource. 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... | |
![]() | |
word | name_ |
Name of this fieldValue object. More... | |
const objectRegistry & | obr_ |
Database this class is registered to. More... | |
dictionary | dict_ |
Construction dictionary. More... | |
bool | active_ |
Active flag. More... | |
Switch | log_ |
Switch to send output to Info as well as to file. More... | |
word | sourceName_ |
Name of source object. More... | |
wordList | fields_ |
List of field names to operate on. More... | |
Switch | valueOutput_ |
Output field values flag. More... | |
dictionary | resultDict_ |
Results dictionary for external access of results. More... | |
Additional Inherited Members | |
![]() | |
static autoPtr< fieldValue > | New (const word &name, const objectRegistry &obr, const dictionary &dict, const bool loadFromFiles=false, const bool output=true) |
Return a reference to the selected fieldValue. More... | |
This function object provides a 'face source' 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:
faceSource1 { type faceSource; functionObjectLibs ("libfieldFunctionObjects.so"); ... log yes; valueOutput true; surfaceFormat none; source faceZone; sourceName f0; operation sum; weightField alpha1; fields ( p phi U ); }
Function object usage
Property | Description | Required | Default value |
---|---|---|---|
type | type name: faceSource | yes | |
log | write data to standard output | no | no |
valueOutput | write the output values | yes | |
writeArea | Write the area of the faceSource | no | |
surfaceFormat | output value format | no | |
source | face source: see below | yes | |
sourceName | name of face source 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 source
is defined by
faceZone | : | requires a 'sourceName' entry to specify the faceZone |
patch | : | requires a 'sourceName' 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 303 of file faceSource.H.
enum sourceType |
Source type enumeration.
Enumerator | |
---|---|
stFaceZone | |
stPatch | |
stSampledSurface |
Definition at line 313 of file faceSource.H.
enum operationType |
Operation type enumeration.
Definition at line 325 of file faceSource.H.
faceSource | ( | const word & | name, |
const objectRegistry & | obr, | ||
const dictionary & | dict, | ||
const bool | loadFromFiles = false |
||
) |
Construct from components.
Definition at line 638 of file faceSource.C.
References Foam::read().
Referenced by faceSource::processValues().
|
virtual |
Destructor.
Definition at line 665 of file faceSource.C.
|
protected |
Initialise, e.g. face addressing.
Definition at line 401 of file faceSource.C.
References Foam::endl(), Foam::exit(), Foam::FatalError, FatalErrorIn, Foam::FatalIOError, FatalIOErrorIn, dictionary::found(), Foam::Info, dictionary::lookup(), surfaceWriter::New(), Foam::nl, dictionary::readIfPresent(), List< T >::size(), dictionary::subOrEmptyDict(), Foam::type(), and WarningIn.
|
protected |
Return true if the field name is valid.
Definition at line 35 of file faceSourceTemplates.C.
References objectRegistry::foundObject(), faceSource::getFieldValues(), fieldValue::obr_, sf(), faceSource::source_, and faceSource::stSampledSurface.
|
protected |
Return field values by looking up field name.
Referenced by faceSource::validField().
|
protected |
Apply the 'operation' to the values. Operation has to.
preserve Type.
Definition at line 132 of file faceSourceTemplates.C.
References Foam::cmptMag(), Foam::component(), Field< Type >::component(), Foam::exit(), Foam::FatalError, FatalErrorIn, Foam::mag(), Foam::max(), Foam::min(), faceSource::opAreaAverage, faceSource::opAreaIntegrate, faceSource::opAverage, faceSource::opCoV, faceSource::operation_, faceSource::operationTypeNames_, faceSource::opMax, faceSource::opMin, faceSource::opSum, faceSource::opSumDirection, faceSource::opSumDirectionBalance, faceSource::opSumMag, faceSource::opWeightedAreaAverage, faceSource::opWeightedAverage, faceSource::processValues(), Foam::setComponent(), List< T >::size(), List< Type >::size(), Foam::sqr(), Foam::sqrt(), and Foam::sum().
Referenced by faceSource::getFieldValues(), and faceSource::processValues().
|
protected |
Apply the 'operation' to the values. Wrapper around.
processSameTypeValues. See also template specialisation below.
Definition at line 277 of file faceSourceTemplates.C.
References faceSource::processSameTypeValues(), and faceSource::writeValues().
Referenced by faceSource::processSameTypeValues(), faceSource::processValues(), faceSource::writeFileHeader(), and faceSource::writeValues().
|
protectedvirtual |
Output file header information.
Reimplemented from functionObjectFile.
Definition at line 533 of file faceSource.C.
References Foam::endl(), forAll, faceSource::processValues(), and Foam::tab.
TypeName | ( | "faceSource" | ) |
Run-time type information.
|
inline |
Return the source type.
Definition at line 31 of file faceSourceI.H.
References faceSource::source_.
|
inline |
Return the local list of face IDs.
Definition at line 38 of file faceSourceI.H.
References faceSource::faceId_.
|
inline |
Return the local list of patch ID per face.
Definition at line 45 of file faceSourceI.H.
References faceSource::facePatchId_.
|
inline |
Return the list of +1/-1 representing face flip map.
Definition at line 52 of file faceSourceI.H.
References faceSource::faceSign_.
|
virtual |
Read from dictionary.
Reimplemented from fieldValue.
Definition at line 671 of file faceSource.C.
References fieldValue::read().
|
virtual |
Calculate and write.
Reimplemented from fieldValue.
Definition at line 682 of file faceSource.C.
References Foam::endl(), forAll, Foam::Info, UPstream::master(), Foam::tab, WarningIn, and fieldValue::write().
bool writeValues | ( | const word & | fieldName, |
const scalarField & | weightField, | ||
const bool | orient | ||
) |
Templated helper function to output field values.
Definition at line 292 of file faceSourceTemplates.C.
References dictionary::add(), functionObjectFile::baseFileDir(), fieldValue::combineFields(), Foam::endl(), functionObjectFile::file(), faceSource::filterField(), Foam::Info, fieldValue::log_, UPstream::master(), fieldValue::mesh(), fieldValue::name_, fieldValue::obr_, faceSource::operation_, faceSource::operationTypeNames_, points, faceSource::processValues(), fieldValue::resultDict_, faceSource::scaleFactor_, faceSource::source_, fieldValue::sourceName_, faceSource::sourceTypeNames_, faceSource::surfacePtr_, faceSource::surfaceWriterPtr_, Foam::tab, objectRegistry::time(), and Time::timeName().
Referenced by faceSource::processValues().
tmp<Field<Type> > filterField | ( | const GeometricField< Type, fvsPatchField, surfaceMesh > & | field, |
const bool | applyOrientation | ||
) | const |
Filter a surface field according to faceIds.
Referenced by faceSource::filterField(), faceSource::getFieldValues(), and faceSource::writeValues().
tmp<Field<Type> > filterField | ( | const GeometricField< Type, fvPatchField, volMesh > & | field, |
const bool | applyOrientation | ||
) | const |
Filter a volume field according to faceIds.
Foam::scalar processValues | ( | const Field< scalar > & | values, |
const vectorField & | Sf, | ||
const scalarField & | weightField | ||
) | const |
Definition at line 561 of file faceSource.C.
References Foam::mag(), n, Foam::neg(), Foam::pos(), faceSource::processValues(), and Foam::sum().
Foam::vector processValues | ( | const Field< vector > & | values, |
const vectorField & | Sf, | ||
const scalarField & | weightField | ||
) | const |
Definition at line 592 of file faceSource.C.
References faceSource::faceSource(), Foam::mag(), n, Foam::pos(), and Foam::sum().
scalar processValues | ( | const Field< scalar > & | values, |
const vectorField & | Sf, | ||
const scalarField & | weightField | ||
) | const |
Specialisation of processing scalars.
vector processValues | ( | const Field< vector > & | values, |
const vectorField & | Sf, | ||
const scalarField & | weightField | ||
) | const |
Specialisation of processing vectors.
Foam::tmp<Foam::Field<Type> > getFieldValues | ( | const word & | fieldName, |
const bool | mustGet, | ||
const bool | applyOrientation | ||
) | const |
Definition at line 55 of file faceSourceTemplates.C.
References Foam::abort(), f(), Foam::FatalError, FatalErrorIn, faceSource::filterField(), fld(), forAll, objectRegistry::foundObject(), Foam::interpolate(), objectRegistry::lookupObject(), fieldValue::obr_, faceSource::processSameTypeValues(), sf(), List< T >::size(), faceSource::source_, faceSource::stSampledSurface, and faceSource::surfacePtr_.
Foam::tmp<Foam::Field<Type> > filterField | ( | const GeometricField< Type, fvPatchField, volMesh > & | field, |
const bool | applyOrientation | ||
) | const |
Definition at line 378 of file faceSourceTemplates.C.
References Foam::abort(), GeometricField< Type, PatchField, GeoMesh >::boundaryField(), faceSource::faceId_, faceSource::facePatchId_, faceSource::faceSign_, Foam::FatalError, FatalErrorIn, faceSource::filterField(), forAll, IOobject::name(), fieldValue::name_, Foam::nl, List< T >::size(), faceSource::source_, fieldValue::sourceName_, faceSource::sourceTypeNames_, and Foam::type().
Foam::tmp<Foam::Field<Type> > filterField | ( | const GeometricField< Type, fvsPatchField, surfaceMesh > & | field, |
const bool | applyOrientation | ||
) | const |
Definition at line 425 of file faceSourceTemplates.C.
References GeometricField< Type, PatchField, GeoMesh >::boundaryField(), faceSource::faceId_, faceSource::facePatchId_, faceSource::faceSign_, forAll, and List< T >::size().
|
static |
Source type names.
Definition at line 321 of file faceSource.H.
Referenced by faceSource::filterField(), NamedEnum< Enum, nEnum >::names(), and faceSource::writeValues().
|
static |
Operation type names.
Definition at line 345 of file faceSource.H.
Referenced by NamedEnum< Enum, nEnum >::names(), faceSource::processSameTypeValues(), and faceSource::writeValues().
|
protected |
Surface writer.
Definition at line 384 of file faceSource.H.
Referenced by faceSource::writeValues().
|
protected |
Source type.
Definition at line 387 of file faceSource.H.
Referenced by faceSource::filterField(), faceSource::getFieldValues(), faceSource::source(), faceSource::validField(), and faceSource::writeValues().
|
protected |
Operation to apply to values.
Definition at line 390 of file faceSource.H.
Referenced by faceSource::processSameTypeValues(), and faceSource::writeValues().
|
protected |
Weight field name - optional.
Definition at line 393 of file faceSource.H.
|
protected |
Flag to indicate if flipMap should be applied to the weight field.
Definition at line 396 of file faceSource.H.
|
protected |
Start index of fields that require application of flipMap.
Definition at line 399 of file faceSource.H.
|
protected |
Scale factor - optional.
Definition at line 402 of file faceSource.H.
Referenced by faceSource::writeValues().
|
protected |
Total area of the faceSource.
Definition at line 405 of file faceSource.H.
|
protected |
Optionally write the area of the faceSource.
Definition at line 408 of file faceSource.H.
|
protected |
Global number of faces.
Definition at line 411 of file faceSource.H.
|
protected |
Local list of face IDs.
Definition at line 417 of file faceSource.H.
Referenced by faceSource::faceId(), and faceSource::filterField().
|
protected |
Local list of patch ID per face.
Definition at line 420 of file faceSource.H.
Referenced by faceSource::facePatch(), and faceSource::filterField().
|
protected |
List of +1/-1 representing face flip map.
(1 use as is, -1 negate)
Definition at line 424 of file faceSource.H.
Referenced by faceSource::faceSign(), and faceSource::filterField().
|
protected |
Underlying sampledSurface.
Definition at line 430 of file faceSource.H.
Referenced by faceSource::getFieldValues(), and faceSource::writeValues().