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...

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...
 

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 () 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 Attributes

word name_
 Name of this set of field averages. More...
 
const objectRegistryobr_
 Database this class is registered to. More...
 
bool active_
 On/off switch. 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...
 
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...
 

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
Note
To employ the prime2Mean option, the mean option must be selecetd.
See also
Foam::functionObject Foam::OutputFilterFunctionObject
Source files

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

References Foam::endl(), Foam::nl, Foam::read(), and WarningIn.

Here is the call graph for this function:

~fieldAverage ( )
virtual

Destructor.

Definition at line 290 of file fieldAverage.C.

Member Function Documentation

void resetFields ( )
protected

Checkout fields (causes deletion) from the database.

and reset lists

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

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

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 82 of file fieldAverageTemplates.C.

References fieldAverage::faItems_, objectRegistry::foundObject(), and fieldAverage::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 152 of file fieldAverageTemplates.C.

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

Here is the call graph for this function:

void calcAverages ( )
protectedvirtual

Main calculation routine.

Definition at line 107 of file fieldAverage.C.

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

Here is the call graph for this function:

void calculateMeanFieldType ( const label  fieldI) const
protected
void calculateMeanFields ( ) const
protected

Calculate mean average fields.

Definition at line 230 of file fieldAverageTemplates.C.

References fieldAverage::faItems_, and forAll.

void calculatePrime2MeanFieldType ( const label  fieldI) const
protected
void calculatePrime2MeanFields ( ) const
protected

Calculate prime-squared average fields.

Definition at line 294 of file fieldAverageTemplates.C.

References fieldAverage::faItems_, and forAll.

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 fieldAverage::faItems_, objectRegistry::foundObject(), objectRegistry::lookupObject(), fieldAverage::obr_, and Foam::sqr().

Here is the call graph for this function:

void addMeanSqrToPrime2Mean ( ) const
protected

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

Definition at line 334 of file fieldAverageTemplates.C.

References fieldAverage::faItems_, and forAll.

void writeAverages ( ) const
protectedvirtual

Write averages.

Definition at line 150 of file fieldAverage.C.

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

Here is the call graph for this function:

void writeFieldType ( const word fieldName) const
protected

Write fields.

Definition at line 354 of file fieldAverageTemplates.C.

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

Here is the call graph for this function:

void writeFields ( ) const
protected

Write fields.

Definition at line 365 of file fieldAverageTemplates.C.

References fieldAverage::faItems_, and forAll.

void writeAveragingProperties ( ) const
protected

Write averaging properties - steps and time.

Definition at line 162 of file fieldAverage.C.

References dictionary::add(), forAll, IOobject::NO_READ, IOobject::NO_WRITE, propsDict(), and dictionary::subDict().

Here is the call graph for this function:

void readAveragingProperties ( )
protected

Read averaging properties - steps and time.

Definition at line 190 of file fieldAverage.C.

References fieldAverage::fieldAverage(), forAll, dictionary::found(), IOobject::headerOk(), Foam::Info, IOobject::MUST_READ_IF_MODIFIED, Foam::nl, IOobject::NO_WRITE, propsDict(), Foam::readLabel(), Foam::readScalar(), and dictionary::subDict().

Here is the call graph for this function:

void operator= ( const fieldAverage )
protected

Disallow default bitwise assignment.

TypeName ( "fieldAverage"  )

Runtime type information.

virtual const word& name ( ) const
inlinevirtual

Return name of the set of field averages.

Definition at line 317 of file fieldAverage.H.

References fieldAverage::end(), fieldAverage::execute(), fieldAverage::movePoints(), fieldAverage::name_, fieldAverage::read(), fieldAverage::timeSet(), fieldAverage::updateMesh(), and fieldAverage::write().

Here is the call graph for this function:

void read ( const dictionary dict)
virtual

Read the field average data.

Definition at line 296 of file fieldAverage.C.

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

Referenced by fieldAverage::name().

Here is the call graph for this function:

Here is the caller graph for this function:

void execute ( )
virtual

Execute the averaging.

Definition at line 315 of file fieldAverage.C.

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

Referenced by fieldAverage::name().

Here is the call graph for this function:

Here is the caller graph for this function:

void end ( )
virtual

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

Definition at line 325 of file fieldAverage.C.

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

Referenced by fieldAverage::name().

Here is the call graph for this function:

Here is the caller graph for this function:

void timeSet ( )
virtual

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

Definition at line 335 of file fieldAverage.C.

Referenced by fieldAverage::name().

Here is the caller graph for this function:

void write ( )
virtual

Calculate the field average data and write.

Definition at line 339 of file fieldAverage.C.

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

Referenced by fieldAverage::name().

Here is the call graph for this function:

Here is the caller graph for this function:

void updateMesh ( const mapPolyMesh )
virtual

Update mesh.

Definition at line 365 of file fieldAverage.C.

Referenced by fieldAverage::name().

Here is the caller graph for this function:

void movePoints ( const polyMesh )
virtual

Move points.

Definition at line 371 of file fieldAverage.C.

Referenced by fieldAverage::name().

Here is the caller graph for this function:

Member Data Documentation

word name_
protected

Name of this set of field averages.

Definition at line 172 of file fieldAverage.H.

Referenced by fieldAverage::name().

const objectRegistry& obr_
protected
bool active_
protected

On/off switch.

Definition at line 178 of file fieldAverage.H.

label prevTimeIndex_
protected

Time at last call, prevents repeated averaging.

Definition at line 181 of file fieldAverage.H.

Switch resetOnRestart_
protected

Reset the averaging process on restart flag.

Definition at line 184 of file fieldAverage.H.

Switch resetOnOutput_
protected

Reset the averaging process on output flag.

Definition at line 187 of file fieldAverage.H.

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

bool initialised_
protected

Initialised flag.

Definition at line 190 of file fieldAverage.H.

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

Iteration steps counter.

Definition at line 199 of file fieldAverage.H.

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

List<scalar> totalTime_
protected

Total time counter.

Definition at line 202 of file fieldAverage.H.

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


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