From a9b72ab45bde083c642a196cef4039c5b4ef1211 Mon Sep 17 00:00:00 2001 From: Tor Harald Sandve Date: Mon, 13 May 2019 12:17:19 +0200 Subject: [PATCH] Fix episode index for restart --- ebos/eclwriter.hh | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/ebos/eclwriter.hh b/ebos/eclwriter.hh index f1859451d..8f7ddb266 100644 --- a/ebos/eclwriter.hh +++ b/ebos/eclwriter.hh @@ -266,10 +266,16 @@ public: std::vector extraKeys = {{"OPMEXTRA", Opm::UnitSystem::measure::identity, false}, {"THRESHPR", Opm::UnitSystem::measure::pressure, inputThpres.active()}}; - unsigned episodeIdx = simulator_.episodeIndex(); + // The episodeIndex is rewined one back before beginRestart is called + // and can not be used here. + // We just ask the initconfig directly to be sure that we use the correct + // index. + const auto& initconfig = simulator_.vanguard().eclState().getInitConfig(); + int restartStepIdx = initconfig.getRestartStep(); + const auto& gridView = simulator_.vanguard().gridView(); unsigned numElements = gridView.size(/*codim=*/0); - eclOutputModule_.allocBuffers(numElements, episodeIdx, /*isSubStep=*/false, /*log=*/false); + eclOutputModule_.allocBuffers(numElements, restartStepIdx, /*isSubStep=*/false, /*log=*/false); auto restartValues = eclIO_->loadRestart(solutionKeys, extraKeys); for (unsigned elemIdx = 0; elemIdx < numElements; ++elemIdx) {