mirror of
https://github.com/OPM/opm-simulators.git
synced 2024-11-25 02:30:18 -06:00
Use unique_ptr instead of shared and raw pointers.
This commit is contained in:
parent
2bec485184
commit
9b30e2e0d7
@ -23,6 +23,7 @@
|
||||
|
||||
#include <opm/autodiff/AutoDiffBlock.hpp>
|
||||
#include <opm/core/utility/parameters/ParameterGroup.hpp>
|
||||
#include <memory>
|
||||
|
||||
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<PhysicalModel> model);
|
||||
std::unique_ptr<PhysicalModel> 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<PhysicalModel> model_;
|
||||
std::unique_ptr<PhysicalModel> model_;
|
||||
unsigned int newtonIterations_;
|
||||
unsigned int linearIterations_;
|
||||
unsigned int newtonIterationsLast_;
|
||||
|
@ -29,9 +29,9 @@ namespace Opm
|
||||
{
|
||||
template <class PhysicalModel>
|
||||
NewtonSolver<PhysicalModel>::NewtonSolver(const SolverParameters& param,
|
||||
std::shared_ptr<PhysicalModel> model)
|
||||
std::unique_ptr<PhysicalModel> model)
|
||||
: param_(param),
|
||||
model_(model),
|
||||
model_(std::move(model)),
|
||||
newtonIterations_(0),
|
||||
linearIterations_(0)
|
||||
{
|
||||
|
@ -151,7 +151,7 @@ namespace Opm
|
||||
WellState& well_state,
|
||||
const Wells* wells);
|
||||
|
||||
Solver* createSolver(const Wells* wells);
|
||||
std::unique_ptr<Solver> createSolver(const Wells* wells);
|
||||
|
||||
void
|
||||
computeRESV(const std::size_t step,
|
||||
|
@ -330,7 +330,7 @@ namespace Opm
|
||||
|
||||
template <class Implementation>
|
||||
auto SimulatorBase<Implementation>::createSolver(const Wells* wells)
|
||||
-> Solver*
|
||||
-> std::unique_ptr<Solver>
|
||||
{
|
||||
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<Solver>(new Solver(solverParams, std::move(model)));
|
||||
}
|
||||
|
||||
template <class Implementation>
|
||||
|
Loading…
Reference in New Issue
Block a user