Public Types | Public Member Functions | Static Public Attributes | Protected Member Functions | Protected Attributes | List of all members
volRegion Class Reference

This function object provides a 'cell region' 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...

Inheritance diagram for volRegion:
Inheritance graph
[legend]
Collaboration diagram for volRegion:
Collaboration graph
[legend]

Public Types

enum  regionTypes { stCellZone, stAll }
 region type enumeration More...
 
enum  operationType {
  opNone, opSum, opSumMag, opAverage,
  opWeightedAverage, opVolAverage, opWeightedVolAverage, opVolIntegrate,
  opMin, opMax, opCoV
}
 Operation type enumeration. More...
 

Public Member Functions

 TypeName ("volRegion")
 Run-time type information. More...
 
 volRegion (const word &name, const Time &runTime, const dictionary &dict)
 Construct from name, Time and dictionary. More...
 
 volRegion (const word &name, const objectRegistry &obr, const dictionary &dict)
 Construct from name, objectRegistry and dictionary. More...
 
virtual ~volRegion ()
 Destructor. More...
 
const regionTypesregionType () const
 Return the region type. More...
 
const labelListcellId () const
 Return the local list of cell IDs. More...
 
template<class Type >
bool writeValues (const word &fieldName)
 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...
 
virtual bool read (const dictionary &)
 Read from dictionary. More...
 
virtual bool write ()
 Calculate and write. 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
 
- 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 dictionarydict () const
 Return the reference to the construction dictionary. More...
 
const wordregionName () const
 Return the region name. More...
 
const wordListfields () const
 Return the list of field names. More...
 
const SwitchwriteFields () const
 Return the output field values flag. More...
 
const fvMeshmesh () const
 Helper function to return the reference to the mesh. More...
 
const dictionaryresultDict () 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 wordListnames () const
 Return const access to the names. More...
 
OFstreamfile ()
 Return access to the file (if only 1) More...
 
PtrList< OFstream > & files ()
 Return access to the files. More...
 
OFstreamfile (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 wordtype () 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< functionObjectclone () const
 Return clone. More...
 
virtual ~functionObject ()
 Destructor. More...
 
const wordname () 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, 2 > regionTypeNames_
 region type names More...
 
static const NamedEnum< operationType, 11 > 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. 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 (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

regionTypes regionType_
 region 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 volRegion. More...
 
bool writeVolume_
 Optionally write the volume of the volRegion. 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 Timetime_
 Reference to the Time. More...
 
const objectRegistryobr_
 Reference to the region objectRegistry. More...
 

Additional Inherited Members

- Static Public Member Functions inherited from fieldValue
static autoPtr< fieldValueNew (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< functionObjectNew (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...
 

Detailed Description

This function object provides a 'cell region' 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:

volRegion1
{
    type            volRegion;
    libs ("libfieldFunctionObjects.so");
    ...
    log             true;
    writeFields     true;
    regionType      cellZone;
    name            c0;
    operation       volAverage;
    weightField     alpha1;
    fields
    (
        p
        U
    );
}
Usage
Property Description Required Default value
type Type name: volRegion yes
log Write data to standard output no no
writeFields Write the region field values yes
writeVolume Write the volume of the volRegion no
regionType cell regionType: see below yes
name name of cell regionType 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 regionType is defined by

cellZone : requires a 'name' 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
See also
Foam::fieldValues Foam::functionObject
Source files

Definition at line 222 of file volRegion.H.

Member Enumeration Documentation

region type enumeration

Enumerator
stCellZone 
stAll 

Definition at line 232 of file volRegion.H.

Operation type enumeration.

Enumerator
opNone 
opSum 
opSumMag 
opAverage 
opWeightedAverage 
opVolAverage 
opWeightedVolAverage 
opVolIntegrate 
opMin 
opMax 
opCoV 

Definition at line 243 of file volRegion.H.

Constructor & Destructor Documentation

volRegion ( const word name,
const Time runTime,
const dictionary dict 
)

Construct from name, Time and dictionary.

Definition at line 207 of file volRegion.C.

References Foam::exit(), Foam::FatalError, FatalErrorInFunction, and Foam::read().

Referenced by volRegion::writeFileHeader().

Here is the call graph for this function:

Here is the caller graph for this function:

volRegion ( const word name,
const objectRegistry obr,
const dictionary dict 
)

Construct from name, objectRegistry and dictionary.

Definition at line 232 of file volRegion.C.

References Foam::exit(), Foam::FatalError, FatalErrorInFunction, and Foam::read().

Here is the call graph for this function:

~volRegion ( )
virtual

Destructor.

Definition at line 258 of file volRegion.C.

References volRegion::read().

Here is the call graph for this function:

Member Function Documentation

void initialise ( const dictionary dict)
protected

Initialise, e.g. cell addressing.

Definition at line 144 of file volRegion.C.

References Foam::endl(), Foam::exit(), Foam::FatalError, FatalErrorInFunction, Foam::Info, Foam::name(), Foam::nl, dictionary::readIfPresent(), Foam::type(), and volRegion::writeFileHeader().

Referenced by NamedEnum< Enum, nEnum >::names().

Here is the call graph for this function:

Here is the caller graph for this function:

bool validField ( const word fieldName) const
protected

Return true if the field name is valid.

Definition at line 33 of file volRegionTemplates.C.

References volRegion::setFieldValues().

Here is the call graph for this function:

tmp<Field<Type> > setFieldValues ( const word fieldName,
const bool  mustGet = false 
) const
protected

Insert field values into values list.

Referenced by volRegion::validField().

Here is the caller graph for this function:

Type processValues ( const Field< Type > &  values,
const scalarField V,
const scalarField weightField 
) const
protected

Apply the 'operation' to the values.

Definition at line 76 of file volRegionTemplates.C.

References Foam::cmptMag(), Foam::component(), Field< Type >::component(), Foam::max(), Foam::min(), Foam::setComponent(), List< Type >::size(), Foam::sqr(), Foam::sqrt(), Foam::sum(), volRegion::writeValues(), and Foam::Zero.

Referenced by volRegion::setFieldValues().

Here is the call graph for this function:

Here is the caller graph for this function:

void writeFileHeader ( const label  i)
protectedvirtual

Output file header information.

Reimplemented from writeFile.

Definition at line 176 of file volRegion.C.

References Foam::endl(), forAll, Foam::tab, and volRegion::volRegion().

Referenced by volRegion::initialise().

Here is the call graph for this function:

Here is the caller graph for this function:

TypeName ( "volRegion"  )

Run-time type information.

Return the region type.

Definition at line 31 of file volRegionI.H.

References volRegion::regionType_.

const Foam::labelList & cellId ( ) const
inline

Return the local list of cell IDs.

Definition at line 38 of file volRegionI.H.

References volRegion::cellId_.

bool writeValues ( const word fieldName)

Templated helper function to output field values.

Definition at line 159 of file volRegionTemplates.C.

References Foam::endl(), volRegion::filterField(), Log, mesh, List< Type >::size(), Foam::tab, and regIOobject::write().

Referenced by volRegion::processValues().

Here is the call graph for this function:

Here is the caller graph for this function:

tmp<Field<Type> > filterField ( const Field< Type > &  field) const

Filter a field according to cellIds.

Referenced by volRegion::writeValues().

Here is the caller graph for this function:

bool read ( const dictionary dict)
virtual

Read from dictionary.

Reimplemented from fieldValue.

Definition at line 265 of file volRegion.C.

References fieldValue::read().

Referenced by volRegion::~volRegion().

Here is the call graph for this function:

Here is the caller graph for this function:

bool write ( )
virtual

Calculate and write.

Reimplemented from fieldValue.

Definition at line 278 of file volRegion.C.

References Foam::endl(), forAll, Log, UPstream::master(), Foam::tab, WarningInFunction, and fieldValue::write().

Here is the call graph for this function:

Foam::tmp<Foam::Field<Type> > setFieldValues ( const word fieldName,
const bool  mustGet 
) const

Definition at line 51 of file volRegionTemplates.C.

References Foam::abort(), Foam::FatalError, FatalErrorInFunction, and volRegion::processValues().

Here is the call graph for this function:

Foam::tmp<Foam::Field<Type> > filterField ( const Field< Type > &  field) const

Definition at line 221 of file volRegionTemplates.C.

Member Data Documentation

region type names

Definition at line 239 of file volRegion.H.

Referenced by NamedEnum< Enum, nEnum >::names().

Operation type names.

Definition at line 259 of file volRegion.H.

Referenced by NamedEnum< Enum, nEnum >::names().

regionTypes regionType_
protected

region type

Definition at line 281 of file volRegion.H.

Referenced by volRegion::regionType().

operationType operation_
protected

Operation to apply to values.

Definition at line 284 of file volRegion.H.

label nCells_
protected

Global number of cells.

Definition at line 287 of file volRegion.H.

labelList cellId_
protected

Local list of cell IDs.

Definition at line 290 of file volRegion.H.

Referenced by volRegion::cellId().

word weightFieldName_
protected

Weight field name - only used for opWeightedAverage mode.

Definition at line 293 of file volRegion.H.

scalar volume_
protected

Volume of the volRegion.

Definition at line 296 of file volRegion.H.

bool writeVolume_
protected

Optionally write the volume of the volRegion.

Definition at line 299 of file volRegion.H.


The documentation for this class was generated from the following files: