Public Member Functions | Protected Member Functions | Protected Attributes
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 objectRegistry &, const dictionary &, const bool loadFromFiles=false)
 Construct for given objectRegistry and dictionary. More...
 
virtual ~fieldAverage ()
 Destructor. More...
 
virtual const wordname () const
 Return name of the set of field averages. More...
 
virtual void read (const dictionary &)
 Read the field average data. More...
 
virtual void execute ()
 Execute the averaging. More...
 
virtual void end ()
 Execute the averaging 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 write ()
 Calculate the field average data and write. More...
 
virtual void updateMesh (const mapPolyMesh &)
 Update mesh. More...
 
virtual void movePoints (const polyMesh &)
 Move points. More...
 
- Public Member Functions inherited from functionObjectState
 functionObjectState (const objectRegistry &obr, const word &name)
 Construct from components. More...
 
virtual ~functionObjectState ()
 Destructor. More...
 
const wordname () const
 Return the name. More...
 
bool active () const
 Return the active flag. More...
 
const IOdictionarystateDict () const
 Return access to the state dictionary. More...
 
dictionarypropertyDict ()
 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< wordobjectResultEntries () const
 Retrieve the result entries. More...
 
List< wordobjectResultEntries (const word &objectName) const
 Return result entries for named object. 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...
 
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 ()
 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 functionObjectState
 functionObjectState (const functionObjectState &)
 Disallow default bitwise copy construct. More...
 
void operator= (const functionObjectState &)
 Disallow default bitwise assignment. More...
 

Protected Attributes

const objectRegistryobr_
 Reference to the database. More...
 
label prevTimeIndex_
 Time at last call, prevents repeated averaging. More...
 
Switch resetOnRestart_
 Reset the averaging process on restart flag. More...
 
Switch resetOnOutput_
 Reset the averaging process on output flag. More...
 
Switch log_
 Switch to send output to Info as well as to file. 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...
 
- Protected Attributes inherited from functionObjectState
const word name_
 Name of model. More...
 
bool active_
 Flag to indicate whether the object is active. More...
 
IOdictionarystateDict_
 Reference to the state dictionary. 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 fieldAveragingProperties dictionary, located in <time>/uniform

When restarting form a previous calculation, the averaging is continuous. However, the averaging process can be restarted using the resetOnRestart option.

To restart the averaging process after each calculation output time, use the resetOnOutput option.

Example of function object specification:

fieldAverage1
{
    type fieldAverage;
    functionObjectLibs ("libfieldFunctionObjects.so");
    ...
    resetOnRestart true;
    resetOnOutput false;
    fields
    (
        U
        {
            mean            on;
            prime2Mean      on;
            base            time;
            window          10.0;
            windowName      w1;
        }
        p
        {
            mean            on;
            prime2Mean      on;
            base            time;
        }
    );
}


Function object usage

Property Description Required Default value
type type name: fieldAverage yes
resetOnRestart flag to reset the averaging on restart yes
resetOnOutput flag to reset the averaging on output yes
fields list of fields and averaging options yes
log Log to standard output no yes
Note
To employ the prime2Mean option, the mean option must be selecetd.
See also
Foam::functionObject Foam::OutputFilterFunctionObject
Source files

Definition at line 172 of file fieldAverage.H.

Constructor & Destructor Documentation

◆ fieldAverage() [1/2]

fieldAverage ( const fieldAverage )
protected

Disallow default bitwise copy construct.

◆ fieldAverage() [2/2]

fieldAverage ( const word name,
const objectRegistry obr,
const dictionary dict,
const bool  loadFromFiles = false 
)

Construct for given objectRegistry and dictionary.

Allow the possibility to load fields from files

Definition at line 225 of file fieldAverage.C.

References dict, and Foam::read().

Here is the call graph for this function:

◆ ~fieldAverage()

~fieldAverage ( )
virtual

Destructor.

Definition at line 253 of file fieldAverage.C.

Member Function Documentation

◆ resetFields()

void resetFields ( )
protected

Checkout fields (causes deletion) from the database.

and reset lists

Definition at line 42 of file fieldAverage.C.

References objectRegistry::checkOut(), fieldAverage::faItems_, forAll, HashTable::found(), and fieldAverage::obr_.

Here is the call graph for this function:

◆ initialize()

void initialize ( )
protected

Reset lists (clear existing values) and initialize averaging.

Check requested field averages are valid, populate field lists

Definition at line 65 of file fieldAverage.C.

References Foam::endl(), forAll, Foam::Info, Foam::nl, Foam::type(), and WarningInFunction.

Here is the call graph for this function:

◆ addMeanFieldType()

void addMeanFieldType ( const label  fieldI)
protected

◆ addMeanField()

void addMeanField ( const label  fieldI)
protected

Add mean average field to database.

Definition at line 83 of file fieldAverageTemplates.C.

◆ addPrime2MeanFieldType()

void addPrime2MeanFieldType ( const label  fieldI)
protected

Add prime-squared average field to database.

Definition at line 105 of file fieldAverageTemplates.C.

References Foam::endl(), Foam::Info, IOobject::NO_READ, IOobject::NO_WRITE, IOobject::READ_IF_PRESENT, and Foam::sqr().

Here is the call graph for this function:

◆ addPrime2MeanField()

void addPrime2MeanField ( const label  fieldI)
protected

Add prime-squared average field to database.

Definition at line 155 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 108 of file fieldAverage.C.

References forAll, Foam::Info, 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 188 of file fieldAverageTemplates.C.

References Foam::constant::atomic::alpha, beta(), and w().

Here is the call graph for this function:

◆ calculateMeanFields()

void calculateMeanFields
protected

Calculate mean average fields.

Definition at line 230 of file fieldAverageTemplates.C.

References forAll.

◆ calculatePrime2MeanFieldType()

void calculatePrime2MeanFieldType ( const label  fieldI) const
protected

Calculate prime-squared average fields.

Definition at line 247 of file fieldAverageTemplates.C.

References Foam::constant::atomic::alpha, beta(), Foam::sqr(), and w().

Here is the call graph for this function:

◆ calculatePrime2MeanFields()

void calculatePrime2MeanFields
protected

Calculate prime-squared average fields.

Definition at line 294 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 314 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 334 of file fieldAverageTemplates.C.

References forAll.

◆ writeAverages()

void writeAverages ( ) const
protectedvirtual

Write averages.

Definition at line 151 of file fieldAverage.C.

References Foam::endl(), and Foam::Info.

Here is the call graph for this function:

◆ writeFieldType()

void writeFieldType ( const word fieldName) const
protected

Write fields.

Definition at line 354 of file fieldAverageTemplates.C.

References f().

Here is the call graph for this function:

◆ writeFields()

void writeFields
protected

Write fields.

Definition at line 365 of file fieldAverageTemplates.C.

References forAll.

◆ writeAveragingProperties()

void writeAveragingProperties ( )
protected

Write averaging properties - steps and time.

Definition at line 163 of file fieldAverage.C.

References dictionary::add(), forAll, and propsDict().

Here is the call graph for this function:

◆ readAveragingProperties()

void readAveragingProperties ( )
protected

Read averaging properties - steps and time.

Definition at line 177 of file fieldAverage.C.

References Foam::endl(), forAll, Foam::Info, dictionary::lookup(), Foam::nl, Foam::readLabel(), and Foam::readScalar().

Here is the call graph for this function:

◆ operator=()

void operator= ( const fieldAverage )
protected

Disallow default bitwise assignment.

◆ TypeName()

TypeName ( "fieldAverage"  )

Runtime type information.

◆ name()

virtual const word& name ( ) const
inlinevirtual

Return name of the set of field averages.

Definition at line 323 of file fieldAverage.H.

References functionObjectState::name_.

◆ read()

void read ( const dictionary dict)
virtual

Read the field average data.

Definition at line 259 of file fieldAverage.C.

References dict, Foam::endl(), Foam::Info, dictionary::lookup(), Foam::nl, dictionary::readIfPresent(), and Foam::type().

Here is the call graph for this function:

◆ execute()

void execute ( )
virtual

Execute the averaging.

Definition at line 280 of file fieldAverage.C.

References Foam::endl(), and Foam::Info.

Here is the call graph for this function:

◆ end()

void end ( )
virtual

Execute the averaging at the final time-loop, currently does nothing.

Definition at line 290 of file fieldAverage.C.

◆ timeSet()

void timeSet ( )
virtual

Called when time was set at the end of the Time::operator++.

Definition at line 294 of file fieldAverage.C.

◆ write()

void write ( )
virtual

Calculate the field average data and write.

Definition at line 298 of file fieldAverage.C.

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

Here is the call graph for this function:

◆ updateMesh()

void updateMesh ( const mapPolyMesh )
virtual

Update mesh.

Definition at line 325 of file fieldAverage.C.

◆ movePoints()

void movePoints ( const polyMesh )
virtual

Move points.

Definition at line 331 of file fieldAverage.C.

Field Documentation

◆ obr_

const objectRegistry& obr_
protected

Reference to the database.

Definition at line 181 of file fieldAverage.H.

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

◆ prevTimeIndex_

label prevTimeIndex_
protected

Time at last call, prevents repeated averaging.

Definition at line 184 of file fieldAverage.H.

◆ resetOnRestart_

Switch resetOnRestart_
protected

Reset the averaging process on restart flag.

Definition at line 187 of file fieldAverage.H.

◆ resetOnOutput_

Switch resetOnOutput_
protected

Reset the averaging process on output flag.

Definition at line 190 of file fieldAverage.H.

Referenced by fieldAverage::addMeanFieldType().

◆ log_

Switch log_
protected

Switch to send output to Info as well as to file.

Definition at line 193 of file fieldAverage.H.

Referenced by fieldAverage::addMeanFieldType().

◆ initialised_

bool initialised_
protected

Initialised flag.

Definition at line 196 of file fieldAverage.H.

◆ faItems_

List<fieldAverageItem> faItems_
protected

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

calculated and output

Definition at line 200 of file fieldAverage.H.

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

◆ totalIter_

List<label> totalIter_
protected

Iteration steps counter.

Definition at line 205 of file fieldAverage.H.

◆ totalTime_

List<scalar> totalTime_
protected

Total time counter.

Definition at line 208 of file fieldAverage.H.


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