diff --git a/dumux/common/timeloop.hh b/dumux/common/timeloop.hh index 3144c45db1a3f62268806cee3be32ddfc39e6971..5d91a3865ed30f046a1c19b2027a0de3dd35e041 100644 --- a/dumux/common/timeloop.hh +++ b/dumux/common/timeloop.hh @@ -134,15 +134,16 @@ public: time_ = startTime; endTime_ = tEnd; - timeStepSize_ = dt; lastTimeStepSize_ = 0.0; - maxTimeStepSize_ = std::numeric_limits<Scalar>::max(); - userSetMaxTimeStepSize_ = maxTimeStepSize_; + userSetMaxTimeStepSize_ = std::numeric_limits<Scalar>::max(); timeStepIdx_ = 0; finished_ = false; timeAfterLastTimeStep_ = 0.0; timeStepWallClockTime_ = 0.0; + // ensure that dt is not greater than tEnd-startTime + setTimeStepSize(dt); + timer_.stop(); timer_.reset(); } @@ -160,6 +161,9 @@ public: const auto cpuTime = wallClockTime(); timeStepWallClockTime_ = cpuTime - timeAfterLastTimeStep_; timeAfterLastTimeStep_ = cpuTime; + + // ensure that using current dt we don't exceed tEnd in next time step + setTimeStepSize(timeStepSize_); } /*!