BUG: inconsistency in periodic restart for fieldAverage (issue #330)

- the interval for the next restart was not being adjusted when the
  file was reread, or when doing a complete simulation restart.
This commit is contained in:
Mark Olesen
2016-12-08 09:32:55 +00:00
parent 1b2cfde773
commit b4182c60a3

View File

@ -302,17 +302,39 @@ bool Foam::functionObjects::fieldAverage::read(const dictionary& dict)
dict.readIfPresent("periodicRestart", periodicRestart_);
dict.lookup("fields") >> faItems_;
const scalar currentTime = obr().time().value();
if (periodicRestart_)
{
dict.lookup("restartPeriod") >> restartPeriod_;
Info<< " Restart period " << restartPeriod_
<< nl << endl;
if (restartPeriod_ > 0)
{
// Determine the appropriate interval for the next restart
periodIndex_ = 1;
while (currentTime > restartPeriod_*periodIndex_)
{
++periodIndex_;
}
Info<< " Restart period " << restartPeriod_
<< " - next restart at " << (restartPeriod_*periodIndex_)
<< nl << endl;
}
else
{
periodicRestart_ = false;
Info<< " Restart period " << restartPeriod_
<< " - ignored"
<< nl << endl;
}
}
restartTime_ = GREAT;
if (dict.readIfPresent("restartTime", restartTime_))
{
if (restartTime_ < obr_.time().value())
if (currentTime > restartTime_)
{
// The restart time is already in the past - ignore
restartTime_ = GREAT;