use std::make_unique where applicable

This commit is contained in:
Arne Morten Kvarving 2020-09-02 15:35:39 +02:00
parent 4b45623333
commit 7305f84351
9 changed files with 14 additions and 14 deletions

View File

@ -230,7 +230,7 @@ public:
{ {
typedef GlobalIndexDataHandle<GridView> DataHandle ; typedef GlobalIndexDataHandle<GridView> DataHandle ;
assert(&grid_ == &gridView.grid()); assert(&grid_ == &gridView.grid());
return std::unique_ptr<DataHandle>(new DataHandle(gridView, cartesianIndex_)); return std::make_unique<DataHandle>(gridView, cartesianIndex_);
} }
protected: protected:

View File

@ -239,7 +239,7 @@ public:
tmp.emplace_back(Opm::ParseContext::SUMMARY_UNKNOWN_GROUP, Opm::InputError::WARN); tmp.emplace_back(Opm::ParseContext::SUMMARY_UNKNOWN_GROUP, Opm::InputError::WARN);
tmp.emplace_back(Opm::ParseContext::PARSE_EXTRA_RECORDS, Opm::InputError::WARN); tmp.emplace_back(Opm::ParseContext::PARSE_EXTRA_RECORDS, Opm::InputError::WARN);
std::unique_ptr<Opm::ParseContext> parseContext(new Opm::ParseContext(tmp)); auto parseContext = std::make_unique<Opm::ParseContext>(tmp);
const std::string ignoredKeywords = EWOMS_GET_PARAM(TypeTag, std::string, IgnoreKeywords); const std::string ignoredKeywords = EWOMS_GET_PARAM(TypeTag, std::string, IgnoreKeywords);
if (ignoredKeywords.size() > 0) { if (ignoredKeywords.size() > 0) {

View File

@ -69,7 +69,7 @@ int main(int argc, char **argv)
std::unique_ptr<Opm::ParseContext> parseContext std::unique_ptr<Opm::ParseContext> parseContext
= Opm::ebosBlackOilCreateParseContext(argc, argv); = Opm::ebosBlackOilCreateParseContext(argc, argv);
std::unique_ptr<Opm::ErrorGuard> errorGuard(new Opm::ErrorGuard); auto errorGuard = std::make_unique<Opm::ErrorGuard>();
// deal with parallel runs // deal with parallel runs
int myRank = Dune::MPIHelper::instance(argc, argv).rank(); int myRank = Dune::MPIHelper::instance(argc, argv).rank();
@ -78,7 +78,7 @@ int main(int argc, char **argv)
// parse the deck file // parse the deck file
if (myRank == 0) if (myRank == 0)
std::cout << "Parsing deck file \"" << deckFileName << "\"" << std::endl; std::cout << "Parsing deck file \"" << deckFileName << "\"" << std::endl;
std::unique_ptr<Opm::Deck> deck(new Opm::Deck(parser.parseFile(deckFileName, *parseContext, *errorGuard))); auto deck = std::make_unique<Opm::Deck>(parser.parseFile(deckFileName, *parseContext, *errorGuard));
// TODO: check which variant ought to be used // TODO: check which variant ought to be used
bool waterActive = deck->hasKeyword("WATER"); bool waterActive = deck->hasKeyword("WATER");

View File

@ -330,12 +330,12 @@ protected:
std::unique_ptr<Solver> createSolver(WellModel& wellModel) std::unique_ptr<Solver> createSolver(WellModel& wellModel)
{ {
auto model = std::unique_ptr<Model>(new Model(ebosSimulator_, auto model = std::make_unique<Model>(ebosSimulator_,
modelParam_, modelParam_,
wellModel, wellModel,
terminalOutput_)); terminalOutput_);
return std::unique_ptr<Solver>(new Solver(solverParam_, std::move(model))); return std::make_unique<Solver>(solverParam_, std::move(model));
} }
void outputTimestampFIP(const SimulatorTimer& timer, const std::string version) void outputTimestampFIP(const SimulatorTimer& timer, const std::string version)

View File

@ -122,7 +122,7 @@ scaleMatrixDRS(const Operator& op, std::size_t pressureEqnIndex, const Vector& w
using Matrix = typename Operator::matrix_type; using Matrix = typename Operator::matrix_type;
using Block = typename Matrix::block_type; using Block = typename Matrix::block_type;
using BlockVector = typename Vector::block_type; using BlockVector = typename Vector::block_type;
std::unique_ptr<Matrix> matrix(new Matrix(op.getmat())); auto matrix = std::make_unique<Matrix>(op.getmat());
if (param.cpr_use_drs_) { if (param.cpr_use_drs_) {
const auto endi = matrix->end(); const auto endi = matrix->end();
for (auto i = matrix->begin(); i != endi; ++i) { for (auto i = matrix->begin(); i != endi; ++i) {

View File

@ -517,7 +517,7 @@ DenseMatrix transposeDenseMatrix(const DenseMatrix& M)
const MILU_VARIANT ilu_milu = parameters_.ilu_milu_; const MILU_VARIANT ilu_milu = parameters_.ilu_milu_;
const bool ilu_redblack = parameters_.ilu_redblack_; const bool ilu_redblack = parameters_.ilu_redblack_;
const bool ilu_reorder_spheres = parameters_.ilu_reorder_sphere_; const bool ilu_reorder_spheres = parameters_.ilu_reorder_sphere_;
std::unique_ptr<SeqPreconditioner> precond(new SeqPreconditioner(opA.getmat(), ilu_fillin, relax, ilu_milu, ilu_redblack, ilu_reorder_spheres)); auto precond = std::make_unique<SeqPreconditioner>(opA.getmat(), ilu_fillin, relax, ilu_milu, ilu_redblack, ilu_reorder_spheres);
return precond; return precond;
} }

View File

@ -167,7 +167,7 @@ AdaptiveSimulatorTimer& AdaptiveSimulatorTimer::operator++ ()
std::unique_ptr< SimulatorTimerInterface > std::unique_ptr< SimulatorTimerInterface >
AdaptiveSimulatorTimer::clone() const AdaptiveSimulatorTimer::clone() const
{ {
return std::unique_ptr< SimulatorTimerInterface > (new AdaptiveSimulatorTimer( *this )); return std::make_unique<AdaptiveSimulatorTimer>(*this);
} }

View File

@ -165,7 +165,7 @@ namespace Opm
std::unique_ptr< SimulatorTimerInterface > std::unique_ptr< SimulatorTimerInterface >
SimulatorTimer::clone() const SimulatorTimer::clone() const
{ {
return std::unique_ptr< SimulatorTimerInterface > (new SimulatorTimer( *this )); return std::make_unique<SimulatorTimer>(*this);
} }

View File

@ -169,7 +169,7 @@ namespace Opm {
using VT = typename AttributeMap::value_type; using VT = typename AttributeMap::value_type;
for (const auto& r : rmap.activeRegions()) { for (const auto& r : rmap.activeRegions()) {
auto v = std::unique_ptr<Value>(new Value(attr)); auto v = std::make_unique<Value>(attr);
const auto stat = attr_.insert(VT(r, std::move(v))); const auto stat = attr_.insert(VT(r, std::move(v)));