This function object provides a 'cell source' variant of the fieldValues function object. Given a list of user-specified fields and a selection of mesh cells, a number of operations can be performed, such as sums, averages and integrations. More...
Public Types | |
enum | sourceType { stCellZone, stAll } |
Source type enumeration. More... | |
enum | operationType { opNone, opSum, opSumMag, opAverage, opWeightedAverage, opVolAverage, opWeightedVolAverage, opVolIntegrate, opMin, opMax, opCoV } |
Operation type enumeration. More... | |
Public Member Functions | |
TypeName ("cellSource") | |
Run-time type information. More... | |
cellSource (const word &name, const objectRegistry &obr, const dictionary &dict, const bool loadFromFiles=false) | |
Construct from components. More... | |
virtual | ~cellSource () |
Destructor. More... | |
const sourceType & | source () const |
Return the source type. More... | |
const labelList & | cellId () const |
Return the local list of cell IDs. 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) |
Templated helper function to output field values. More... | |
template<class Type > | |
tmp< Field< Type > > | filterField (const Field< Type > &field) const |
Filter a field according to cellIds. More... | |
template<class Type > | |
Foam::tmp< Foam::Field< Type > > | setFieldValues (const word &fieldName, const bool mustGet) const |
template<class Type > | |
Foam::tmp< Foam::Field< Type > > | filterField (const Field< Type > &field) 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... | |
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... | |
![]() | |
functionObjectState (const objectRegistry &obr, const word &name) | |
Construct from components. More... | |
virtual | ~functionObjectState () |
Destructor. More... | |
const word & | name () const |
Return the name. More... | |
bool | active () const |
Return the active flag. More... | |
const IOdictionary & | stateDict () const |
Return access to the state dictionary. More... | |
dictionary & | propertyDict () |
Return access to the property dictionary. More... | |
template<class Type > | |
bool | setActive () |
Set the active status by querying objectRegistry type. More... | |
bool | foundProperty (const word &entryName) const |
Return true if the property exists. More... | |
template<class Type > | |
Type | getProperty (const word &entryName, const Type &defaultValue=pTraits< Type >::zero) const |
Retrieve generic property. More... | |
template<class Type > | |
void | getProperty (const word &entryName, Type &value) const |
Retrieve generic property. More... | |
template<class Type > | |
void | setProperty (const word &entryName, const Type &value) |
Add generic property. More... | |
template<class Type > | |
Type | getObjectProperty (const word &objectName, const word &entryName, const Type &defaultValue=pTraits< Type >::zero) const |
Retrieve generic property from named object. More... | |
template<class Type > | |
void | getObjectProperty (const word &objectName, const word &entryName, Type &value) const |
Retrieve generic property from named object. More... | |
template<class Type > | |
void | setObjectProperty (const word &objectName, const word &entryName, const Type &value) |
Add generic property from named object. More... | |
template<class Type > | |
void | setResult (const word &entryName, const Type &value) |
Add result. More... | |
template<class Type > | |
void | setObjectResult (const word &objectName, const word &entryName, const Type &value) |
Add result from named object. More... | |
template<class Type > | |
Type | getResult (const word &entryName, const Type &defaultValue=pTraits< Type >::zero) const |
Retrieve result. More... | |
template<class Type > | |
Type | getObjectResult (const word &objectName, const word &entryName, const Type &defaultValue=pTraits< Type >::zero) const |
Retrieve result from named object. More... | |
template<class Type > | |
void | getObjectResult (const word &objectName, const word &entryName, Type &value) const |
Retrieve result from named object. More... | |
word | resultType (const word &entryName) const |
Retrieve the result type. More... | |
word | objectResultType (const word &objectName, const word &entryName) const |
Return the type of result. More... | |
List< word > | objectResultEntries () const |
Retrieve the result entries. More... | |
List< word > | objectResultEntries (const word &objectName) const |
Return result entries for named object. More... | |
![]() | |
functionObjectFile (const objectRegistry &obr, const word &prefix) | |
Construct null. More... | |
functionObjectFile (const objectRegistry &obr, const word &prefix, const word &fileName, const dictionary &dict) | |
Construct from components and read options from dictionary. More... | |
virtual | ~functionObjectFile () |
Destructor. More... | |
void | read (const dictionary &dict) |
Read. More... | |
OFstream & | file () |
Return access to the file (if only 1) More... | |
bool | writeToFile () const |
Return true if can write to file. 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... | |
Static Public Attributes | |
static const NamedEnum< sourceType, 2 > | sourceTypeNames_ |
Source type names. More... | |
static const NamedEnum< operationType, 11 > | 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. cell 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 > > | setFieldValues (const word &fieldName, const bool mustGet=false) const |
Insert field values into values list. More... | |
template<class Type > | |
Type | processValues (const Field< Type > &values, const scalarField &V, const scalarField &weightField) const |
Apply the 'operation' to the values. More... | |
virtual void | writeFileHeader (Ostream &os) const |
Output file header information. More... | |
![]() | |
functionObjectState (const functionObjectState &) | |
Disallow default bitwise copy construct. More... | |
void | operator= (const functionObjectState &) |
Disallow default bitwise assignment. 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 autoPtr< OFstream > | createFile (const word &name) const |
Return an autoPtr to a new file. More... | |
virtual void | resetFile (const word &name) |
Reset internal file pointer to new file with new name. 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 | |
sourceType | source_ |
Source type. More... | |
operationType | operation_ |
Operation to apply to values. More... | |
label | nCells_ |
Global number of cells. More... | |
labelList | cellId_ |
Local list of cell IDs. More... | |
word | weightFieldName_ |
Weight field name - only used for opWeightedAverage mode. More... | |
scalar | volume_ |
Volume of the cellSource. More... | |
bool | writeVolume_ |
Optionally write the volume of the cellSource. More... | |
![]() | |
const objectRegistry & | obr_ |
Database this class is registered to. More... | |
dictionary | dict_ |
Construction dictionary. 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... | |
scalar | scaleFactor_ |
Scale factor - optional. More... | |
![]() | |
const word | name_ |
Name of model. More... | |
bool | active_ |
Flag to indicate whether the object is active. More... | |
IOdictionary & | stateDict_ |
Reference to the state dictionary. More... | |
![]() | |
bool | writeToFile_ |
Flag to enable/disable writing to file. More... | |
Private Member Functions | |
void | setCellZoneCells () |
Set cells to evaluate based on a cell zone. More... | |
void | setPatchCells () |
Set cells to evaluate based on a patch. More... | |
scalar | volume () const |
Calculate and return volume of the cellSource: sum(V) 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 'cell source' variant of the fieldValues function object. Given a list of user-specified fields and a selection of mesh cells, a number of operations can be performed, such as sums, averages and integrations.
Example of function object specification:
cellSource1 { type cellSource; functionObjectLibs ("libfieldFunctionObjects.so"); ... log true; valueOutput true; source cellZone; sourceName c0; operation volAverage; weightField alpha1; fields ( p U ); }
Function object usage
Property | Description | Required | Default value |
---|---|---|---|
type | Type name: cellSource | yes | |
log | Write data to standard output | no | no |
valueOutput | Write the raw output values | yes | |
writeVolume | Write the volume of the cellSource | no | |
source | Cell source: see below | yes | |
sourceName | Name of cell source if required | no | |
operation | Operation to perform | yes | |
weightField | Name of field to apply weighting | no | |
fields | List of fields to operate on | yes |
Where source
is defined by
cellZone | : | requires a 'sourceName' entry to specify the cellZone |
all | : | all cells |
The operation
is one of:
none | : | no operation |
sum | : | sum |
sumMag | : | sum of component magnitudes |
average | : | ensemble average |
weightedAverage | : | weighted average |
volAverage | : | volume weighted average |
weightedVolAverage | : | weighted volume average |
volIntegrate | : | volume integral |
min | : | minimum |
max | : | maximum |
CoV | : | coefficient of variation: standard deviation/mean |
Definition at line 225 of file cellSource.H.
enum sourceType |
enum operationType |
Operation type enumeration.
Enumerator | |
---|---|
opNone | |
opSum | |
opSumMag | |
opAverage | |
opWeightedAverage | |
opVolAverage | |
opWeightedVolAverage | |
opVolIntegrate | |
opMin | |
opMax | |
opCoV |
Definition at line 246 of file cellSource.H.
cellSource | ( | const word & | name, |
const objectRegistry & | obr, | ||
const dictionary & | dict, | ||
const bool | loadFromFiles = false |
||
) |
Construct from components.
Definition at line 188 of file cellSource.C.
References dict, and Foam::read().
|
virtual |
Destructor.
Definition at line 213 of file cellSource.C.
|
private |
Set cells to evaluate based on a cell zone.
Definition at line 76 of file cellSource.C.
References cellSource::cellId_, polyMesh::cellZones(), Foam::endl(), Foam::exit(), Foam::FatalError, FatalErrorInFunction, ZoneMesh::findZoneID(), Foam::identity(), fieldValue::mesh(), ZoneMesh::names(), cellSource::nCells_, Foam::nl, Foam::Pout, Foam::returnReduce(), List::size(), cellSource::source_, fieldValue::sourceName_, cellSource::sourceTypeNames_, cellSource::stAll, and cellSource::stCellZone.
|
private |
Set cells to evaluate based on a patch.
|
private |
Calculate and return volume of the cellSource: sum(V)
Definition at line 119 of file cellSource.C.
References Foam::gSum(), and mesh.
|
protected |
Initialise, e.g. cell addressing.
Definition at line 127 of file cellSource.C.
References dict, Foam::endl(), Foam::Info, Foam::nl, Foam::type(), and WarningInFunction.
|
protected |
Return true if the field name is valid.
Definition at line 32 of file cellSourceTemplates.C.
References objectRegistry::foundObject(), and fieldValue::obr_.
|
protected |
Insert field values into values list.
|
protected |
Apply the 'operation' to the values.
Definition at line 72 of file cellSourceTemplates.C.
References Foam::cmptMag(), Foam::component(), Foam::gMax(), Foam::gMin(), Foam::gSum(), n, Foam::returnReduce(), Foam::setComponent(), Foam::sqr(), and Foam::sqrt().
|
protectedvirtual |
Output file header information.
Definition at line 160 of file cellSource.C.
References Foam::endl(), forAll, and Foam::tab.
TypeName | ( | "cellSource" | ) |
Run-time type information.
|
inline |
Return the source type.
Definition at line 31 of file cellSourceI.H.
References cellSource::source_.
|
inline |
Return the local list of cell IDs.
Definition at line 38 of file cellSourceI.H.
|
virtual |
Read from dictionary.
Reimplemented from fieldValue.
Definition at line 219 of file cellSource.C.
References dict, and fieldValue::read().
|
virtual |
Calculate and write.
Reimplemented from fieldValue.
Definition at line 231 of file cellSource.C.
References Foam::endl(), forAll, Foam::Info, Foam::tab, WarningInFunction, and fieldValue::write().
bool writeValues | ( | const word & | fieldName, |
const scalarField & | weightField | ||
) |
Templated helper function to output field values.
Definition at line 171 of file cellSourceTemplates.C.
References Foam::endl(), Foam::Info, UPstream::master(), mesh, IOobject::NO_READ, IOobject::NO_WRITE, Foam::tab, and regIOobject::write().
Filter a field according to cellIds.
Foam::tmp<Foam::Field<Type> > setFieldValues | ( | const word & | fieldName, |
const bool | mustGet | ||
) | const |
Definition at line 47 of file cellSourceTemplates.C.
References Foam::abort(), Foam::FatalError, and FatalErrorInFunction.
Foam::tmp<Foam::Field<Type> > filterField | ( | const Field< Type > & | field | ) | const |
Definition at line 230 of file cellSourceTemplates.C.
|
static |
Source type names.
Definition at line 242 of file cellSource.H.
Referenced by cellSource::setCellZoneCells().
|
static |
Operation type names.
Definition at line 262 of file cellSource.H.
|
protected |
Source type.
Definition at line 284 of file cellSource.H.
Referenced by cellSource::setCellZoneCells(), and cellSource::source().
|
protected |
Operation to apply to values.
Definition at line 287 of file cellSource.H.
|
protected |
Global number of cells.
Definition at line 290 of file cellSource.H.
Referenced by cellSource::setCellZoneCells().
|
protected |
Local list of cell IDs.
Definition at line 293 of file cellSource.H.
Referenced by cellSource::setCellZoneCells().
|
protected |
Weight field name - only used for opWeightedAverage mode.
Definition at line 296 of file cellSource.H.
|
protected |
Volume of the cellSource.
Definition at line 299 of file cellSource.H.
|
protected |
Optionally write the volume of the cellSource.
Definition at line 302 of file cellSource.H.
Copyright © 2011-2018 OpenFOAM | OPENFOAM® is a registered trademark of OpenCFD Ltd.