fieldAverage Class Reference

Calculates average quantities for a user-specified selection of volumetric and surface fields. More...

Inheritance diagram for fieldAverage:
Collaboration diagram for fieldAverage:

Public Types

enum class  baseType { iter , time }
 Enumeration defining the averaging base type. More...
 

Public Member Functions

 TypeName ("fieldAverage")
 Runtime type information. More...
 
 fieldAverage (const word &name, const Time &runTime, const dictionary &)
 Construct from Time and dictionary. More...
 
 fieldAverage (const fieldAverage &)=delete
 Disallow default bitwise copy construction. More...
 
virtual ~fieldAverage ()
 Destructor. More...
 
const word base () const
 Return averaging base type name. More...
 
Switch iterBase () const
 Return true if base is iter. More...
 
Switch timeBase () const
 Return true if base is time. More...
 
scalar window () const
 
const wordwindowName () const
 
virtual bool read (const dictionary &)
 Read the field average data. More...
 
virtual wordList fields () const
 Return the list of fields required. More...
 
virtual bool executeAtStart () const
 Do not average at the start of the run. More...
 
virtual bool execute ()
 Calculate the field averages. More...
 
virtual bool write ()
 Write the field averages. More...
 
void operator= (const fieldAverage &)=delete
 Disallow default bitwise assignment. 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...
 
 fvMeshFunctionObject (const word &name, const objectRegistry &obr, const dictionary &dict)
 Construct from the region objectRegistry and dictionary. More...
 
 fvMeshFunctionObject (const fvMeshFunctionObject &)=delete
 Disallow default bitwise copy construction. More...
 
virtual ~fvMeshFunctionObject ()
 Destructor. More...
 
void operator= (const fvMeshFunctionObject &)=delete
 Disallow default bitwise assignment. 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...
 
 regionFunctionObject (const regionFunctionObject &)=delete
 Disallow default bitwise copy construction. More...
 
virtual ~regionFunctionObject ()
 Destructor. More...
 
void operator= (const regionFunctionObject &)=delete
 Disallow default bitwise assignment. More...
 
- Public Member Functions inherited from functionObject
 ClassName ("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, const Time &runTime)
 Construct from components. More...
 
autoPtr< functionObjectclone () const
 Return clone. More...
 
 functionObject (const functionObject &)=delete
 Disallow default bitwise copy construction. 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 scalar timeToNextAction ()
 Called by Time::adjustTimeStep(). Allows the functionObject to. More...
 
virtual void movePoints (const polyMesh &mesh)
 Update topology using the given map. More...
 
virtual void topoChange (const polyTopoChangeMap &map)
 Update topology using the given map. More...
 
virtual void mapMesh (const polyMeshMap &)
 Update from another mesh using the given map. More...
 
virtual void distribute (const polyDistributionMap &)
 Redistribute or update using the given distribution map. More...
 
void operator= (const functionObject &)=delete
 Disallow default bitwise assignment. More...
 

Protected Member Functions

void initialise ()
 Reset lists (clear existing values) and initialise averaging. More...
 
void restart ()
 Restart averaging for restartOnOutput. More...
 
template<class Type >
void readMeanFieldType (const label fieldi)
 Read the mean average field. More...
 
template<class Type >
void readMeanField (const label fieldi)
 Read the mean average field. More...
 
template<class Type >
void initialiseMeanFieldType (const label fieldi)
 Initialise the mean average field. More...
 
template<class Type >
void initialiseMeanField (const label fieldi)
 Initialise the mean average field. More...
 
template<class Type1 , class Type2 >
void readPrime2MeanFieldType (const label fieldi)
 Read the prime-squared average field. More...
 
template<class Type1 , class Type2 >
void readPrime2MeanField (const label fieldi)
 Read the prime-squared average field. More...
 
template<class Type1 , class Type2 >
void initialisePrime2MeanFieldType (const label fieldi)
 Initialise the prime-squared average field. More...
 
template<class Type1 , class Type2 >
void initialisePrime2MeanField (const label fieldi)
 Initialise the prime-squared average field. 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 read (const dictionary &dict, const bool construct)
 Read. 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 >
void cannotFindObject (const word &fieldName)
 Prints a warning message that fieldName cannot be found. More...
 
void cannotFindObject (const word &fieldName)
 Prints a warning message that fieldName cannot be found. More...
 
template<class ObjectType >
const ObjectType & lookupObject (const word &fieldName) const
 Lookup object from the objectRegistry. More...
 
template<class ObjectType >
ObjectType & lookupObjectRef (const word &fieldName)
 Lookup non-const object reference from the objectRegistry. More...
 
template<class ObjectType >
bool store (const tmp< ObjectType > &tfield)
 Store the given field in the objectRegistry. More...
 
template<class ObjectType >
bool store (const 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...
 
baseType base_
 Averaging base type. More...
 
scalar window_
 Averaging window - defaults to -1 for 'all iters/time'. More...
 
word windowName_
 Averaging window name - defaults to 'window'. More...
 
Switch mean_
 Compute mean flag. More...
 
Switch prime2Mean_
 Compute prime-squared mean flag. More...
 
PtrList< 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 objectRegistryobr_
 Reference to the region objectRegistry. More...
 
- Protected Attributes inherited from functionObject
const Timetime_
 Reference to time. More...
 

Static Protected Attributes

static const NamedEnum< baseType, 2 > baseTypeNames_
 Averaging base type names. More...
 

Friends

class fieldAverageItem
 

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...
 
Switch executeAtStart_
 Switch write log to Info. More...
 
- Static Public Attributes inherited from functionObject
static bool postProcess
 Global post-processing mode switch. More...
 

Detailed Description

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
  • prime2Mean: prime-squared mean
  • base: average over 'time', or 'iteration'
  • window: optional averaging window, specified in 'base' units

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

  • arithmetic mean field, UMean
  • prime-squared field, UPrime2Mean

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");

    writeControl        writeTime;

    restartOnRestart    false;
    restartOnOutput     false;
    periodicRestart     false;
    restartPeriod       0.002;

    base                time;
    window              10.0;
    windowName          w1;

    mean                yes;
    prime2Mean          yes;

    fields              (U p);
}
Usage
Property Description Required Default
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 selected.

See also
Foam::functionObjects::fvMeshFunctionObject Foam::functionObject
Source files

Definition at line 160 of file fieldAverage.H.

Member Enumeration Documentation

◆ baseType

enum baseType
strong

Enumeration defining the averaging base type.

Enumerator
iter 
time 

Definition at line 167 of file fieldAverage.H.

Constructor & Destructor Documentation

◆ fieldAverage() [1/2]

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

Construct from Time and dictionary.

Definition at line 380 of file fieldAverage.C.

References dict, Foam::endl(), fieldAverage::faItems_, forAll, Log, functionObject::name(), Foam::nl, regionFunctionObject::read(), fieldAverage::read(), and functionObject::type().

Here is the call graph for this function:

◆ fieldAverage() [2/2]

fieldAverage ( const fieldAverage )
delete

Disallow default bitwise copy construction.

◆ ~fieldAverage()

~fieldAverage ( )
virtual

Destructor.

Definition at line 428 of file fieldAverage.C.

Member Function Documentation

◆ initialise()

void initialise ( )
protected

Reset lists (clear existing values) and initialise averaging.

Check requested field averages are valid, populate field lists

Definition at line 59 of file fieldAverage.C.

References fieldAverage::faItems_, forAll, and fieldAverage::totalTime_.

◆ restart()

void restart ( )
protected

Restart averaging for restartOnOutput.

Definition at line 87 of file fieldAverage.C.

References forAll, Log, and Foam::nl.

◆ readMeanFieldType()

◆ readMeanField()

void readMeanField ( const label  fieldi)
protected

Read the mean average field.

Definition at line 72 of file fieldAverageTemplates.C.

◆ initialiseMeanFieldType()

void initialiseMeanFieldType ( const label  fieldi)
protected

Initialise the mean average field.

Definition at line 84 of file fieldAverageTemplates.C.

References Foam::endl(), and Log.

Here is the call graph for this function:

◆ initialiseMeanField()

void initialiseMeanField ( const label  fieldi)
protected

Initialise the mean average field.

Definition at line 128 of file fieldAverageTemplates.C.

◆ readPrime2MeanFieldType()

void readPrime2MeanFieldType ( const label  fieldi)
protected

Read the prime-squared average field.

Definition at line 154 of file fieldAverageTemplates.C.

References Foam::endl(), IOobject::headerClassName(), IOobject::headerOk(), Log, IOobject::MUST_READ, and IOobject::NO_WRITE.

Here is the call graph for this function:

◆ readPrime2MeanField()

void readPrime2MeanField ( const label  fieldi)
protected

Read the prime-squared average field.

Definition at line 195 of file fieldAverageTemplates.C.

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

Here is the call graph for this function:

◆ initialisePrime2MeanFieldType()

void initialisePrime2MeanFieldType ( const label  fieldi)
protected

Initialise the prime-squared average field.

Definition at line 221 of file fieldAverageTemplates.C.

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

Here is the call graph for this function:

◆ initialisePrime2MeanField()

void initialisePrime2MeanField ( const label  fieldi)
protected

Initialise the prime-squared average field.

Definition at line 267 of file fieldAverageTemplates.C.

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

Here is the call graph for this function:

◆ calcAverages()

void calcAverages ( )
protectedvirtual

Main calculation routine.

Definition at line 123 of file fieldAverage.C.

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

Here is the call graph for this function:

◆ calculateMeanFieldType()

void calculateMeanFieldType ( const label  fieldi) const
protected

Calculate mean average fields.

Definition at line 304 of file fieldAverageTemplates.C.

◆ calculateMeanFields()

void calculateMeanFields
protected

Calculate mean average fields.

Definition at line 342 of file fieldAverageTemplates.C.

References forAll.

◆ calculatePrime2MeanFieldType()

void calculatePrime2MeanFieldType ( const label  fieldi) const
protected

Calculate prime-squared average fields.

Definition at line 368 of file fieldAverageTemplates.C.

References Foam::sqr().

Here is the call graph for this function:

◆ calculatePrime2MeanFields()

void calculatePrime2MeanFields
protected

Calculate prime-squared average fields.

Definition at line 411 of file fieldAverageTemplates.C.

References forAll.

◆ addMeanSqrToPrime2MeanType()

void addMeanSqrToPrime2MeanType ( const label  fieldi) const
protected

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

Definition at line 440 of file fieldAverageTemplates.C.

References Foam::sqr().

Here is the call graph for this function:

◆ addMeanSqrToPrime2Mean()

void addMeanSqrToPrime2Mean
protected

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

Definition at line 456 of file fieldAverageTemplates.C.

References forAll.

◆ writeAverages()

void writeAverages ( ) const
protectedvirtual

Write averages.

Definition at line 172 of file fieldAverage.C.

References Foam::endl(), forAll, Log, Foam::name(), Foam::nl, IOobject::NO_READ, IOobject::NO_WRITE, propsDict(), and Foam::type().

Here is the call graph for this function:

◆ writeFieldType()

void writeFieldType ( const word fieldName) const
protected

Write fields.

Definition at line 485 of file fieldAverageTemplates.C.

References f().

Here is the call graph for this function:

◆ writeFields()

void writeFields
protected

Write fields.

Definition at line 499 of file fieldAverageTemplates.C.

References forAll.

◆ read() [1/2]

void read ( const dictionary dict,
const bool  construct 
)
protected

Read.

Definition at line 211 of file fieldAverage.C.

References dict, Foam::first(), forAll, typeIOobject< Type >::headerOk(), Log, dictionary::lookup(), IOobject::MUST_READ_IF_MODIFIED, Foam::name(), Foam::nl, IOobject::NO_WRITE, propsDict(), List< T >::transfer(), and PtrList< T >::transfer().

Referenced by fieldAverage::fieldAverage().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ TypeName()

TypeName ( "fieldAverage"  )

Runtime type information.

◆ base()

const word base ( ) const
inline

Return averaging base type name.

Definition at line 348 of file fieldAverage.H.

References fieldAverage::base_, and fieldAverage::baseTypeNames_.

◆ iterBase()

Switch iterBase ( ) const
inline

Return true if base is iter.

Definition at line 354 of file fieldAverage.H.

References fieldAverage::base_, and fieldAverage::iter.

◆ timeBase()

Switch timeBase ( ) const
inline

Return true if base is time.

Definition at line 360 of file fieldAverage.H.

References fieldAverage::base_, and fieldAverage::time.

◆ window()

scalar window ( ) const
inline

Definition at line 365 of file fieldAverage.H.

References fieldAverage::window_.

◆ windowName()

const word& windowName ( ) const
inline

Definition at line 370 of file fieldAverage.H.

References fieldAverage::windowName_.

◆ read() [2/2]

bool read ( const dictionary dict)
virtual

Read the field average data.

Reimplemented from regionFunctionObject.

Definition at line 434 of file fieldAverage.C.

References dict, Foam::endl(), Log, Foam::name(), Foam::nl, Foam::read(), regionFunctionObject::read(), and Foam::type().

Here is the call graph for this function:

◆ fields()

Foam::wordList fields ( ) const
virtual

Return the list of fields required.

Implements functionObject.

Definition at line 448 of file fieldAverage.C.

References fields, and forAll.

◆ executeAtStart()

virtual bool executeAtStart ( ) const
inlinevirtual

Do not average at the start of the run.

Reimplemented from functionObject.

Definition at line 383 of file fieldAverage.H.

◆ execute()

bool execute ( )
virtual

Calculate the field averages.

Implements functionObject.

Definition at line 461 of file fieldAverage.C.

References Foam::endl(), functionObject::postProcess, and WarningInFunction.

Here is the call graph for this function:

◆ write()

bool write ( )
virtual

Write the field averages.

Implements functionObject.

Definition at line 478 of file fieldAverage.C.

◆ operator=()

void operator= ( const fieldAverage )
delete

Disallow default bitwise assignment.

Friends And Related Function Documentation

◆ fieldAverageItem

friend class fieldAverageItem
friend

Definition at line 318 of file fieldAverage.H.

Member Data Documentation

◆ prevTimeIndex_

label prevTimeIndex_
protected

Time at last call, prevents repeated averaging.

Definition at line 179 of file fieldAverage.H.

◆ restartOnRestart_

Switch restartOnRestart_
protected

Restart the averaging process on restart.

Definition at line 182 of file fieldAverage.H.

◆ restartOnOutput_

Switch restartOnOutput_
protected

Restart the averaging process on output.

Definition at line 185 of file fieldAverage.H.

◆ periodicRestart_

Switch periodicRestart_
protected

Periodically restart the averaging process.

Definition at line 188 of file fieldAverage.H.

◆ restartPeriod_

scalar restartPeriod_
protected

Restart period.

Definition at line 191 of file fieldAverage.H.

◆ baseTypeNames_

const Foam::NamedEnum< Foam::functionObjects::fieldAverage::baseType, 2 > baseTypeNames_
staticprotected

Averaging base type names.

Definition at line 194 of file fieldAverage.H.

Referenced by fieldAverage::base().

◆ base_

baseType base_
protected

Averaging base type.

Definition at line 197 of file fieldAverage.H.

Referenced by fieldAverage::base(), fieldAverage::iterBase(), and fieldAverage::timeBase().

◆ window_

scalar window_
protected

Averaging window - defaults to -1 for 'all iters/time'.

Definition at line 200 of file fieldAverage.H.

Referenced by fieldAverageItem::fieldAverageItem(), and fieldAverage::window().

◆ windowName_

word windowName_
protected

Averaging window name - defaults to 'window'.

Definition at line 203 of file fieldAverage.H.

Referenced by fieldAverageItem::fieldAverageItem(), and fieldAverage::windowName().

◆ mean_

Switch mean_
protected

Compute mean flag.

Definition at line 206 of file fieldAverage.H.

Referenced by fieldAverageItem::fieldAverageItem().

◆ prime2Mean_

Switch prime2Mean_
protected

Compute prime-squared mean flag.

Definition at line 209 of file fieldAverage.H.

Referenced by fieldAverageItem::fieldAverageItem().

◆ faItems_

PtrList<fieldAverageItem> faItems_
protected

List of field average items, describing what averages to be.

calculated and output

Definition at line 213 of file fieldAverage.H.

Referenced by fieldAverage::fieldAverage(), fieldAverage::initialise(), and fieldAverage::readMeanFieldType().

◆ totalIter_

List<label> totalIter_
protected

Iteration steps counter.

Definition at line 216 of file fieldAverage.H.

◆ totalTime_

List<scalar> totalTime_
protected

Total time counter.

Definition at line 219 of file fieldAverage.H.

Referenced by fieldAverage::initialise().

◆ periodIndex_

label periodIndex_
protected

Index for periodic restart.

Definition at line 222 of file fieldAverage.H.


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