Time: Set writeTimeIndex_ to correspond to beginTime_ for restarted cases

This commit is contained in:
Henry Weller
2020-12-11 17:09:09 +00:00
parent 7aca9bfa78
commit b594bcb753

View File

@ -89,7 +89,10 @@ void Foam::Time::adjustDeltaT()
functionObjects_.timeToNextWrite()
);
Info << "timeToNextWrite " << timeToNextWrite << endl;
const scalar nSteps = timeToNextWrite/deltaT_;
Info << "nSteps " << nSteps << endl;
// Ensure nStepsToNextWrite does not overflow
if (nSteps < labelMax)
@ -97,7 +100,11 @@ void Foam::Time::adjustDeltaT()
// Allow the time-step to increase by up to 1%
// to accommodate the next write time before splitting
const label nStepsToNextWrite = label(max(nSteps, 1) + 0.99);
Info << "nStepsToNextWrite " << nStepsToNextWrite << endl;
deltaT_ = timeToNextWrite/nStepsToNextWrite;
Info << "deltaT " << deltaT_ << endl;
}
}
@ -265,6 +272,23 @@ void Foam::Time::setControls()
timeIndex_ = startTimeIndex_;
}
// Set writeTimeIndex_ to correspond to beginTime_ for restarted cases
if
(
restart()
&& (
writeControl_ == writeControl::runTime
|| writeControl_ == writeControl::adjustableRunTime
)
)
{
writeTimeIndex_ = label
(
((value() - beginTime_) + 0.5*deltaT_)
/ writeInterval_
);
}
// Check if values stored in time dictionary are consistent