diff --git a/opm/autodiff/NewtonSolver.hpp b/opm/autodiff/NewtonSolver.hpp index afa019177..462d4e210 100644 --- a/opm/autodiff/NewtonSolver.hpp +++ b/opm/autodiff/NewtonSolver.hpp @@ -23,6 +23,7 @@ #include #include +#include namespace Opm { @@ -64,13 +65,13 @@ namespace Opm { /// Construct solver for a given model. /// - /// The model is a std::shared_ptr because the object to which model points to is + /// The model is a std::unique_ptr because the object to which model points to is /// not allowed to be deleted as long as the NewtonSolver object exists. /// /// \param[in] param parameters controlling nonlinear Newton process /// \param[in, out] model physical simulation model. explicit NewtonSolver(const SolverParameters& param, - std::shared_ptr model); + std::unique_ptr model); /// Take a single forward step, after which the states will be modified /// according to the physical model. @@ -98,7 +99,7 @@ namespace Opm { private: // --------- Data members --------- SolverParameters param_; - std::shared_ptr model_; + std::unique_ptr model_; unsigned int newtonIterations_; unsigned int linearIterations_; unsigned int newtonIterationsLast_; diff --git a/opm/autodiff/NewtonSolver_impl.hpp b/opm/autodiff/NewtonSolver_impl.hpp index eda423d90..1e931b6ef 100644 --- a/opm/autodiff/NewtonSolver_impl.hpp +++ b/opm/autodiff/NewtonSolver_impl.hpp @@ -29,9 +29,9 @@ namespace Opm { template NewtonSolver::NewtonSolver(const SolverParameters& param, - std::shared_ptr model) + std::unique_ptr model) : param_(param), - model_(model), + model_(std::move(model)), newtonIterations_(0), linearIterations_(0) { diff --git a/opm/autodiff/SimulatorBase.hpp b/opm/autodiff/SimulatorBase.hpp index 3be441c2d..ed99bf23e 100644 --- a/opm/autodiff/SimulatorBase.hpp +++ b/opm/autodiff/SimulatorBase.hpp @@ -151,7 +151,7 @@ namespace Opm WellState& well_state, const Wells* wells); - Solver* createSolver(const Wells* wells); + std::unique_ptr createSolver(const Wells* wells); void computeRESV(const std::size_t step, diff --git a/opm/autodiff/SimulatorBase_impl.hpp b/opm/autodiff/SimulatorBase_impl.hpp index 9c7755365..cbc1b9c26 100644 --- a/opm/autodiff/SimulatorBase_impl.hpp +++ b/opm/autodiff/SimulatorBase_impl.hpp @@ -330,7 +330,7 @@ namespace Opm template auto SimulatorBase::createSolver(const Wells* wells) - -> Solver* + -> std::unique_ptr { typedef typename Traits::Model Model; typedef typename Model::ModelParameters ModelParams; @@ -354,7 +354,7 @@ namespace Opm typedef typename Solver::SolverParameters SolverParams; SolverParams solverParams( param_ ); - return new Solver(solverParams, std::move(model)); + return std::unique_ptr(new Solver(solverParams, std::move(model))); } template