ENH: fieldAverage - protect against numerical error when determining the next periodic restart

This commit is contained in:
Andrew Heather
2020-06-12 09:55:34 +01:00
parent ffa7bfb4f5
commit 98a9cde998

View File

@ -136,10 +136,16 @@ void Foam::functionObjects::fieldAverage::calcAverages()
} }
bool doRestart = false; bool doRestart = false;
if (periodicRestart_ && currentTime > restartPeriod_*periodIndex_) if (periodicRestart_)
{ {
doRestart = true; const scalar deltaT = obr().time().deltaTValue();
periodIndex_++; const scalar nextTime = restartPeriod_*periodIndex_ + 0.5*deltaT;
if (currentTime > nextTime)
{
doRestart = true;
++periodIndex_;
}
} }
if (currentTime >= restartTime_) if (currentTime >= restartTime_)