Skip to content
Snippets Groups Projects
Commit 1ecf2b47 authored by andy's avatar andy
Browse files

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

parent a41c30ff
No related merge requests found
......@@ -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();
}
}
......
......@@ -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_;
......
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment