Public Member Functions | Protected Member Functions | Protected Attributes | List of all members
fieldAverage Class Reference

This function object calculates average quantities for a user-specified selection of volumetric and surface fields. Fields are entered as a list of sub-dictionaries, which indicate the type of averages to perform, and can be updated during the calculation. The current options include: More...

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

Public Member Functions

 TypeName ("fieldAverage")
 Runtime type information. More...
 
 fieldAverage (const word &name, const Time &runTime, const dictionary &)
 Construct from Time and dictionary. More...
 
virtual ~fieldAverage ()
 Destructor. More...
 
virtual bool read (const dictionary &)
 Read the field average data. More...
 
virtual bool execute ()
 Calculate the field averages. More...
 
virtual bool write ()
 Write the field averages. More...
 
- Public Member Functions inherited from fvMeshFunctionObject
 TypeName ("fvMeshFunctionObject")
 Runtime type information. More...
 
 fvMeshFunctionObject (const word &name, const Time &runTime, const dictionary &dict)
 Construct from Time and dictionary. More...
 
virtual ~fvMeshFunctionObject ()
 Destructor. 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...
 

Protected Member Functions

void resetFields ()
 Checkout fields (causes deletion) from the database. More...
 
void initialize ()
 Reset lists (clear existing values) and initialize averaging. More...
 
void restart ()
 Restart averaging for restartOnOutput. More...
 
template<class Type >
void addMeanFieldType (const label fieldi)
 Add mean average field to database. More...
 
template<class Type >
void addMeanField (const label fieldi)
 Add mean average field to database. More...
 
template<class Type1 , class Type2 >
void addPrime2MeanFieldType (const label fieldi)
 Add prime-squared average field to database. More...
 
template<class Type1 , class Type2 >
void addPrime2MeanField (const label fieldi)
 Add prime-squared average field to database. More...
 
virtual void calcAverages ()
 Main calculation routine. More...
 
template<class Type >
void calculateMeanFieldType (const label fieldi) const
 Calculate mean average fields. More...
 
template<class Type >
void calculateMeanFields () const
 Calculate mean average fields. More...
 
template<class Type1 , class Type2 >
void calculatePrime2MeanFieldType (const label fieldi) const
 Calculate prime-squared average fields. More...
 
template<class Type1 , class Type2 >
void calculatePrime2MeanFields () const
 Calculate prime-squared average fields. More...
 
template<class Type1 , class Type2 >
void addMeanSqrToPrime2MeanType (const label fieldi) const
 Add mean-squared field value to prime-squared mean field. More...
 
template<class Type1 , class Type2 >
void addMeanSqrToPrime2Mean () const
 Add mean-squared field value to prime-squared mean field. More...
 
virtual void writeAverages () const
 Write averages. More...
 
template<class Type >
void writeFieldType (const word &fieldName) const
 Write fields. More...
 
template<class Type >
void writeFields () const
 Write fields. More...
 
void writeAveragingProperties () const
 Write averaging properties - steps and time. More...
 
void readAveragingProperties ()
 Read averaging properties - steps and time. More...
 
 fieldAverage (const fieldAverage &)
 Disallow default bitwise copy construct. More...
 
void operator= (const fieldAverage &)
 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

label prevTimeIndex_
 Time at last call, prevents repeated averaging. More...
 
Switch restartOnRestart_
 Restart the averaging process on restart. More...
 
Switch restartOnOutput_
 Restart the averaging process on output. More...
 
Switch periodicRestart_
 Periodically restart the averaging process. More...
 
scalar restartPeriod_
 Restart period. More...
 
bool initialised_
 Initialised flag. More...
 
List< fieldAverageItemfaItems_
 List of field average items, describing what averages to be. More...
 
List< labeltotalIter_
 Iteration steps counter. More...
 
List< scalar > totalTime_
 Total time counter. More...
 
label periodIndex_
 Index for periodic restart. More...
 
- Protected Attributes inherited from fvMeshFunctionObject
const fvMeshmesh_
 Reference to the fvMesh. 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 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...
 
- Static Public Attributes inherited from functionObject
static int debug
 
static bool postProcess
 Global post-processing mode switch. More...
 

Detailed Description

This function object calculates average quantities for a user-specified selection of volumetric and surface fields. Fields are entered as a list of sub-dictionaries, which indicate the type of averages to perform, and can be updated during the calculation. The current options include:

- mean: arithmetic mean:

\[ \overline{x} = \frac{1}{N}\displaystyle\sum\limits_{i=0}^N x_i \]

Average field names are constructed by concatenating the base field with the averaging type, e.g. when averaging field 'U', the resultant fields are:

Information regarding the number of averaging steps, and total averaging time are written on a per-field basis to the "<functionObject name>Properties" dictionary, located in <time>/uniform

When restarting form a previous calculation, the averaging is continuous or may be restarted using the restartOnRestart option.

The averaging process may be restarted after each calculation output time using the restartOnOutput option or restarted periodically using the periodicRestart option and setting restartPeriod to the required averaging period.

Example of function object specification:

fieldAverage1
{
    type fieldAverage;
    libs ("libfieldFunctionObjects.so");
    ...
    restartOnRestart    false;
    restartOnOutput     false;
    periodicRestart     false;
    restartPeriod       0.002;
    fields
    (
        U
        {
            mean            on;
            prime2Mean      on;
            base            time;
            window          10.0;
            windowName      w1;
        }
        p
        {
            mean            on;
            prime2Mean      on;
            base            time;
        }
    );
}
Usage
Property Description Required Default value
type type name: fieldAverage yes
restartOnRestart Restart the averaging on restart no no
restartOnOutput Restart the averaging on output no no
periodicRestart Periodically restart the averaging no no
restartPeriod Periodic restart period conditional
fields list of fields and averaging options yes
Note
To employ the prime2Mean option, the mean option must be selecetd.
See also
Foam::functionObjects::fvMeshFunctionObject Foam::functionObject
Source files

Definition at line 175 of file fieldAverage.H.

Constructor & Destructor Documentation

fieldAverage ( const fieldAverage )
protected

Disallow default bitwise copy construct.

Referenced by fieldAverage::readAveragingProperties().

Here is the caller graph for this function:

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

Construct from Time and dictionary.

Definition at line 269 of file fieldAverage.C.

References Foam::read().

Here is the call graph for this function:

~fieldAverage ( )
virtual

Destructor.

Definition at line 293 of file fieldAverage.C.

Member Function Documentation

void resetFields ( )
protected

Checkout fields (causes deletion) from the database.

and reset lists

Definition at line 45 of file fieldAverage.C.

References forAll.

void initialize ( )
protected

Reset lists (clear existing values) and initialize averaging.

Check requested field averages are valid, populate field lists

Definition at line 68 of file fieldAverage.C.

References forAll.

void restart ( )
protected

Restart averaging for restartOnOutput.

Definition at line 96 of file fieldAverage.C.

References Foam::endl(), Log, and Foam::nl.

Here is the call graph for this function:

void addMeanFieldType ( const label  fieldi)
protected
void addMeanField ( const label  fieldi)
protected

Add mean average field to database.

Definition at line 80 of file fieldAverageTemplates.C.

References fieldAverage::addPrime2MeanFieldType(), fieldAverage::faItems_, objectRegistry::foundObject(), and regionFunctionObject::obr_.

Here is the call graph for this function:

void addPrime2MeanFieldType ( const label  fieldi)
protected
void addPrime2MeanField ( const label  fieldi)
protected

Add prime-squared average field to database.

Definition at line 156 of file fieldAverageTemplates.C.

References fieldAverage::calculateMeanFieldType(), Foam::exit(), fieldAverage::faItems_, Foam::FatalError, FatalErrorInFunction, objectRegistry::foundObject(), Foam::nl, and regionFunctionObject::obr_.

Here is the call graph for this function:

void calcAverages ( )
protectedvirtual

Main calculation routine.

Definition at line 112 of file fieldAverage.C.

References Foam::endl(), forAll, Log, Foam::name(), Foam::nl, and Foam::type().

Here is the call graph for this function:

void calculateMeanFieldType ( const label  fieldi) const
protected

Calculate mean average fields.

Definition at line 193 of file fieldAverageTemplates.C.

References Foam::constant::atomic::alpha, beta(), TimeState::deltaTValue(), fieldAverage::faItems_, objectRegistry::foundObject(), objectRegistry::lookupObject(), regionFunctionObject::obr_, objectRegistry::time(), fieldAverage::totalIter_, and fieldAverage::totalTime_.

Referenced by fieldAverage::addPrime2MeanField().

Here is the call graph for this function:

Here is the caller graph for this function:

void calculateMeanFields ( ) const
protected

Calculate mean average fields.

Definition at line 237 of file fieldAverageTemplates.C.

References fieldAverage::calculatePrime2MeanFieldType(), fieldAverage::faItems_, and forAll.

Here is the call graph for this function:

void calculatePrime2MeanFieldType ( const label  fieldi) const
protected

Calculate prime-squared average fields.

Definition at line 255 of file fieldAverageTemplates.C.

References Foam::constant::atomic::alpha, beta(), TimeState::deltaTValue(), fieldAverage::faItems_, objectRegistry::foundObject(), objectRegistry::lookupObject(), regionFunctionObject::obr_, Foam::sqr(), objectRegistry::time(), fieldAverage::totalIter_, and fieldAverage::totalTime_.

Referenced by fieldAverage::calculateMeanFields().

Here is the call graph for this function:

Here is the caller graph for this function:

void calculatePrime2MeanFields ( ) const
protected

Calculate prime-squared average fields.

Definition at line 304 of file fieldAverageTemplates.C.

References fieldAverage::addMeanSqrToPrime2MeanType(), fieldAverage::faItems_, and forAll.

Here is the call graph for this function:

void addMeanSqrToPrime2MeanType ( const label  fieldi) const
protected

Add mean-squared field value to prime-squared mean field.

Definition at line 332 of file fieldAverageTemplates.C.

References fieldAverage::faItems_, objectRegistry::foundObject(), objectRegistry::lookupObject(), regionFunctionObject::obr_, and Foam::sqr().

Referenced by fieldAverage::calculatePrime2MeanFields().

Here is the call graph for this function:

Here is the caller graph for this function:

void addMeanSqrToPrime2Mean ( ) const
protected

Add mean-squared field value to prime-squared mean field.

Definition at line 354 of file fieldAverageTemplates.C.

References fieldAverage::faItems_, forAll, and fieldAverage::writeFieldType().

Here is the call graph for this function:

void writeAverages ( ) const
protectedvirtual

Write averages.

Definition at line 163 of file fieldAverage.C.

References Foam::endl(), and Log.

Here is the call graph for this function:

void writeFieldType ( const word fieldName) const
protected

Write fields.

Definition at line 375 of file fieldAverageTemplates.C.

References f(), objectRegistry::foundObject(), objectRegistry::lookupObject(), and regionFunctionObject::obr_.

Referenced by fieldAverage::addMeanSqrToPrime2Mean().

Here is the call graph for this function:

Here is the caller graph for this function:

void writeFields ( ) const
protected

Write fields.

Definition at line 388 of file fieldAverageTemplates.C.

References fieldAverage::faItems_, and forAll.

void writeAveragingProperties ( ) const
protected

Write averaging properties - steps and time.

Definition at line 177 of file fieldAverage.C.

References dictionary::add(), Foam::endl(), forAll, Log, Foam::name(), IOobject::NO_READ, IOobject::NO_WRITE, propsDict(), and dictionary::subDict().

Here is the call graph for this function:

void readAveragingProperties ( )
protected
void operator= ( const fieldAverage )
protected

Disallow default bitwise assignment.

TypeName ( "fieldAverage"  )

Runtime type information.

bool read ( const dictionary dict)
virtual

Read the field average data.

Reimplemented from regionFunctionObject.

Definition at line 299 of file fieldAverage.C.

References Foam::endl(), Log, dictionary::lookup(), Foam::name(), Foam::nl, regionFunctionObject::read(), dictionary::readIfPresent(), and Foam::type().

Here is the call graph for this function:

bool execute ( )
virtual

Calculate the field averages.

Implements functionObject.

Definition at line 325 of file fieldAverage.C.

bool write ( )
virtual

Write the field averages.

Implements functionObject.

Definition at line 333 of file fieldAverage.C.

Member Data Documentation

label prevTimeIndex_
protected

Time at last call, prevents repeated averaging.

Definition at line 184 of file fieldAverage.H.

Switch restartOnRestart_
protected

Restart the averaging process on restart.

Definition at line 187 of file fieldAverage.H.

Switch restartOnOutput_
protected

Restart the averaging process on output.

Definition at line 190 of file fieldAverage.H.

Referenced by fieldAverage::addMeanFieldType(), and fieldAverage::addPrime2MeanFieldType().

Switch periodicRestart_
protected

Periodically restart the averaging process.

Definition at line 193 of file fieldAverage.H.

scalar restartPeriod_
protected

Restart period.

Definition at line 196 of file fieldAverage.H.

bool initialised_
protected

Initialised flag.

Definition at line 199 of file fieldAverage.H.

List<fieldAverageItem> faItems_
protected
List<label> totalIter_
protected

Iteration steps counter.

Definition at line 208 of file fieldAverage.H.

Referenced by fieldAverage::calculateMeanFieldType(), and fieldAverage::calculatePrime2MeanFieldType().

List<scalar> totalTime_
protected

Total time counter.

Definition at line 211 of file fieldAverage.H.

Referenced by fieldAverage::calculateMeanFieldType(), and fieldAverage::calculatePrime2MeanFieldType().

label periodIndex_
protected

Index for periodic restart.

Definition at line 214 of file fieldAverage.H.


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