ENH: updated initialisation for fieldAverage function object - mantis #841

This commit is contained in:
andy 2013-05-13 15:32:04 +01:00
parent a41c30ff04
commit 1ecf2b471a
2 changed files with 14 additions and 4 deletions

View File

@ -311,6 +311,7 @@ Foam::fieldAverage::fieldAverage
prevTimeIndex_(-1),
resetOnRestart_(false),
resetOnOutput_(false),
initialised_(false),
faItems_(),
meanScalarFields_(),
meanVectorFields_(),
@ -361,11 +362,7 @@ void Foam::fieldAverage::read(const dictionary& dict)
dict.readIfPresent("resetOnOutput", resetOnOutput_);
dict.lookup("fields") >> faItems_;
initialize();
readAveragingProperties();
// ensure first averaging works unconditionally
prevTimeIndex_ = -1;
}
}
@ -374,6 +371,16 @@ void Foam::fieldAverage::execute()
{
if (active_)
{
if (!initialised_)
{
initialize();
// ensure first averaging works unconditionally
prevTimeIndex_ = -1;
initialised_ = true;
}
calcAverages();
}
}

View File

@ -171,6 +171,9 @@ protected:
//- Reset the averaging process on output flag
Switch resetOnOutput_;
//- Initialised flag
bool initialised_;
//- List of field average items, describing what averages to be
// calculated and output
List<fieldAverageItem> faItems_;