From 5d7e40a05588658603fcd96a62f41b5c25c1b273 Mon Sep 17 00:00:00 2001 From: Thomas Fetzer <thomas.fetzer@iws.uni-stuttgart.de> Date: Tue, 27 Dec 2016 13:24:12 +0100 Subject: [PATCH] [common][io] Move serialize() of restart capability to be done before the time step is advanced Now willBeFinished, timeStepIdx, ... is the same for shouldWriteOutput() and shouldWriteRestart() --- CHANGELOG.md | 4 ++++ dumux/common/timemanager.hh | 12 ++++++------ dumux/io/adaptivegridrestart.hh | 6 +++--- dumux/io/restart.hh | 2 +- 4 files changed, 14 insertions(+), 10 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index fe531d40a5..9eb05d10f7 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -17,6 +17,10 @@ Differences Between DuMuX 2.10 and DuMuX 2.11 * IMPROVEMENTS and ENHANCEMENTS: * IMMEDIATE INTERFACE CHANGES not allowing/requiring a deprecation period: + - shouldWriteRestartFile() is now, as shouldWriteOutput() already was, + called before the time level is advanced. So it might be necessary to use + ...WillBeFinished instead of ...IsFinished for writing restart files at + the correct time. - In the ZeroEq models, the properties BBoxMinIsWall and BBoxMaxIsWall have been replaced by the functions bBoxMaxIsWall() and bBoxMaxIsWall() in the problem file. diff --git a/dumux/common/timemanager.hh b/dumux/common/timemanager.hh index a4984fea6b..690481a599 100644 --- a/dumux/common/timemanager.hh +++ b/dumux/common/timemanager.hh @@ -417,6 +417,10 @@ public: // prepare the model for the next time integration problem_->advanceTimeLevel(); + // write restart file if mandated by the problem + if (problem_->shouldWriteRestartFile()) + problem_->serialize(); + // advance the simulated time by the current time step size time_ += dt; ++timeStepIdx_; @@ -430,10 +434,6 @@ public: <<"\n"; } - // write restart file if mandated by the problem - if (problem_->shouldWriteRestartFile()) - problem_->serialize(); - // notify the problem if an episode is finished if (episodeIsFinished()) { //define what to do at the end of an episode in the problem @@ -485,8 +485,8 @@ public: res.serializeStream() << episodeIndex_ << " " << episodeStartTime_ << " " << episodeLength_ << " " - << time_ << " " - << timeStepIdx_ << " "; + << time_ + timeStepSize() << " " + << timeStepIdx_ + 1 << " "; res.serializeSectionEnd(); } diff --git a/dumux/io/adaptivegridrestart.hh b/dumux/io/adaptivegridrestart.hh index 468f318835..060fa0ede5 100644 --- a/dumux/io/adaptivegridrestart.hh +++ b/dumux/io/adaptivegridrestart.hh @@ -105,12 +105,11 @@ public: #if HAVE_DUNE_ALUGRID Dune::BackupRestoreFacility<Grid>::backup(problem.grid(), gridName); #else - double time = problem.timeManager().time(); problem.grid().template writeGrid #if ! DUNE_VERSION_NEWER(DUNE_COMMON, 2, 5) <Dune::xdr> #endif // Dune < 3.0 - (gridName, time); + (gridName, problem.timeManager().time() + problem.timeManager().timeStepSize()); #endif } @@ -139,7 +138,8 @@ private: std::cerr << "Be sure to provide a parameter Problem.Name if you want to restart." << std::endl; oss << problem.name(); } - oss << "_time=" << problem.timeManager().time() << "_rank=" << rank << ".grs"; + oss << "_time=" << problem.timeManager().time() + problem.timeManager().timeStepSize() + << "_rank=" << rank << ".grs"; return oss.str(); } }; diff --git a/dumux/io/restart.hh b/dumux/io/restart.hh index cd1fc50fa0..10dab4014f 100644 --- a/dumux/io/restart.hh +++ b/dumux/io/restart.hh @@ -93,7 +93,7 @@ public: const std::string magicCookie = magicRestartCookie_(problem.gridView()); fileName_ = restartFileName_(problem.gridView(), problem.name(), - problem.timeManager().time()); + problem.timeManager().time()+problem.timeManager().timeStepSize()); // open output file and write magic cookie outStream_.open(fileName_.c_str()); -- GitLab