From 19f4cef6c1eaff81edc576ef3f80cba622ece4e5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Atgeirr=20Fl=C3=B8=20Rasmussen?= Date: Fri, 15 Jan 2016 15:16:40 +0100 Subject: [PATCH] Add new step() overload taking initial states separately. --- opm/autodiff/NonlinearSolver.hpp | 25 +++++++++++++++++++++---- opm/autodiff/NonlinearSolver_impl.hpp | 16 +++++++++++++++- 2 files changed, 36 insertions(+), 5 deletions(-) diff --git a/opm/autodiff/NonlinearSolver.hpp b/opm/autodiff/NonlinearSolver.hpp index 641cb2fd0..d67ee6122 100644 --- a/opm/autodiff/NonlinearSolver.hpp +++ b/opm/autodiff/NonlinearSolver.hpp @@ -76,15 +76,32 @@ namespace Opm { /// Take a single forward step, after which the states will be modified /// according to the physical model. - /// \param[in] dt time step size - /// \param[in] reservoir_state reservoir state variables - /// \param[in] well_state well state variables - /// \return number of linear iterations used + /// \param[in] dt time step size + /// \param[in, out] reservoir_state reservoir state variables + /// \param[in, out] well_state well state variables + /// \return number of linear iterations used int step(const double dt, ReservoirState& reservoir_state, WellState& well_state); + /// Take a single forward step, after which the states will be modified + /// according to the physical model. This version allows for the + /// states passed as in/out arguments to be different from the initial + /// states. + /// \param[in] dt time step size + /// \param[in] initial_reservoir_state reservoir state variables at start of timestep + /// \param[in] initial_well_state well state variables at start of timestep + /// \param[in, out] reservoir_state reservoir state variables + /// \param[in, out] well_state well state variables + /// \return number of linear iterations used + int + step(const double dt, + const ReservoirState& initial_reservoir_state, + const WellState& initial_well_state, + ReservoirState& reservoir_state, + WellState& well_state); + /// Number of nonlinear solver iterations used in all calls to step(). unsigned int nonlinearIterations() const; diff --git a/opm/autodiff/NonlinearSolver_impl.hpp b/opm/autodiff/NonlinearSolver_impl.hpp index d35d1fa8f..9b52235e5 100644 --- a/opm/autodiff/NonlinearSolver_impl.hpp +++ b/opm/autodiff/NonlinearSolver_impl.hpp @@ -85,9 +85,23 @@ namespace Opm step(const double dt, ReservoirState& reservoir_state, WellState& well_state) + { + return step(dt, reservoir_state, well_state, reservoir_state, well_state); + } + + + + template + int + NonlinearSolver:: + step(const double dt, + const ReservoirState& initial_reservoir_state, + const WellState& initial_well_state, + ReservoirState& reservoir_state, + WellState& well_state) { // Do model-specific once-per-step calculations. - model_->prepareStep(dt, reservoir_state, well_state); + model_->prepareStep(dt, initial_reservoir_state, initial_well_state); int iteration = 0;