diff --git a/opm/autodiff/BlackoilModelEbos.hpp b/opm/autodiff/BlackoilModelEbos.hpp index 481ccc219..4f58f0155 100644 --- a/opm/autodiff/BlackoilModelEbos.hpp +++ b/opm/autodiff/BlackoilModelEbos.hpp @@ -185,11 +185,23 @@ namespace Opm { /// \param[in] timer simulation timer /// \param[in, out] reservoir_state reservoir state variables /// \param[in, out] well_state well state variables - void prepareStep(const SimulatorTimerInterface& /*timer*/, + void prepareStep(const SimulatorTimerInterface& timer, const ReservoirState& /*reservoir_state*/, const WellState& /* well_state */) { + // update the solution variables in ebos + + // if the last time step failed we need to update the curent solution + // and recalculate the Intesive Quantities. + if ( timer.lastStepFailed() ) { + ebosSimulator_.model().solution( 0 /* timeIdx */ ) = ebosSimulator_.model().solution( 1 /* timeIdx */ ); + ebosSimulator_.model().invalidateIntensiveQuantitiesCache(/*timeIdx=*/0); + } else { + // set the initial solution. + ebosSimulator_.model().solution( 1 /* timeIdx */ ) = ebosSimulator_.model().solution( 0 /* timeIdx */ ); + } + unsigned numDof = ebosSimulator_.model().numGridDof(); wasSwitched_.resize(numDof); std::fill(wasSwitched_.begin(), wasSwitched_.end(), false); @@ -305,7 +317,7 @@ namespace Opm { // Apply the update, with considering model-dependent limitations and // chopping of the update. - updateState(x,iteration); + updateState(x); report.update_time += perfTimer.stop(); } @@ -580,8 +592,7 @@ namespace Opm { /// \param[in] dx updates to apply to primary variables /// \param[in, out] reservoir_state reservoir state variables /// \param[in, out] well_state well state variables - void updateState(const BVector& dx, - const int iterationIdx) + void updateState(const BVector& dx) { using namespace Opm::AutoDiffGrid; @@ -593,12 +604,6 @@ namespace Opm { const auto& elemEndIt = gridView.template end(); SolutionVector& solution = ebosSimulator_.model().solution( 0 /* timeIdx */ ); - // Store the initial solution. - if( iterationIdx == 0 ) - { - ebosSimulator_.model().solution( 1 /* timeIdx */ ) = solution; - } - for (auto elemIt = gridView.template begin(); elemIt != elemEndIt; ++elemIt) @@ -1564,12 +1569,6 @@ namespace Opm { { ebosSimulator_.problem().beginTimeStep(); } - // if the last time step failed we need to update the solution varables in ebos - // and recalculate the Intesive Quantities. - if ( timer.lastStepFailed() && iterationIdx == 0 ) { - ebosSimulator_.model().solution( 0 /* timeIdx */ ) = ebosSimulator_.model().solution( 1 /* timeIdx */ ); - ebosSimulator_.model().invalidateIntensiveQuantitiesCache(/*timeIdx=*/0); - } ebosSimulator_.problem().beginIteration(); ebosSimulator_.model().linearizer().linearize();