Skip to content

Commit

Permalink
Fix modernize-make-unique. (#259)
Browse files Browse the repository at this point in the history
  • Loading branch information
jrood-nrel authored Sep 20, 2023
1 parent 6aa2c8b commit b61c45a
Show file tree
Hide file tree
Showing 11 changed files with 96 additions and 84 deletions.
5 changes: 3 additions & 2 deletions Source/PeleLM.cpp
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
#include <PeleLM.H>
#include <memory>

#ifdef PELELM_USE_SPRAY
#include "SprayParticles.H"
Expand Down Expand Up @@ -46,9 +47,9 @@ PeleLM::getLevelDataPtr(
if (a_time == AmrNewTime) {
return m_leveldata_new[lev].get();
} else {
m_leveldata_floating.reset(new LevelData(
m_leveldata_floating = std::make_unique<LevelData>(
grids[lev], dmap[lev], *m_factory[lev], m_incompressible, m_has_divu,
m_nAux, m_nGrowState, m_use_soret, static_cast<int>(m_do_les)));
m_nAux, m_nGrowState, m_use_soret, static_cast<int>(m_do_les));
Real time = getTime(lev, a_time);
fillpatch_state(lev, time, m_leveldata_floating->state, m_nGrowState);
// if (useUMac) {
Expand Down
9 changes: 5 additions & 4 deletions Source/PeleLMAdvance.cpp
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
#include <PeleLM.H>
#include <PeleLMUtils.H>
#include <AMReX_MemProfiler.H>
#include <memory>

using namespace amrex;

Expand Down Expand Up @@ -64,12 +65,12 @@ PeleLM::Advance(int is_initIter)
//----------------------------------------------------------------
// Data for the advance, only live for the duration of the advance
std::unique_ptr<AdvanceDiffData> diffData;
diffData.reset(new AdvanceDiffData(
finest_level, grids, dmap, m_factory, m_nGrowAdv, m_use_wbar, m_use_soret));
diffData = std::make_unique<AdvanceDiffData>(
finest_level, grids, dmap, m_factory, m_nGrowAdv, m_use_wbar, m_use_soret);
std::unique_ptr<AdvanceAdvData> advData;
advData.reset(new AdvanceAdvData(
advData = std::make_unique<AdvanceAdvData>(
finest_level, grids, dmap, m_factory, m_incompressible, m_nGrowAdv,
m_nGrowMAC));
m_nGrowMAC);

for (int lev = 0; lev <= finest_level; lev++) {
m_extSource[lev]->setVal(0.);
Expand Down
13 changes: 7 additions & 6 deletions Source/PeleLMBC.cpp
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
#include <PeleLM.H>
#include <PeleLMBCfill.H>
#include <AMReX_FillPatchUtil.H>
#include <memory>
#ifdef AMREX_USE_EB
#include <AMReX_EBInterpolater.H>
#endif
Expand Down Expand Up @@ -293,11 +294,11 @@ PeleLM::fillPatchState(int lev, Real a_time, int nGrow)

std::unique_ptr<MultiFab> mf;
if (m_incompressible != 0) {
mf.reset(new MultiFab(
grids[lev], dmap[lev], AMREX_SPACEDIM, nGrow, MFInfo(), Factory(lev)));
mf = std::make_unique<MultiFab>(
grids[lev], dmap[lev], AMREX_SPACEDIM, nGrow, MFInfo(), Factory(lev));
} else {
mf.reset(
new MultiFab(grids[lev], dmap[lev], NVAR, nGrow, MFInfo(), Factory(lev)));
mf = std::make_unique<MultiFab>(
grids[lev], dmap[lev], NVAR, nGrow, MFInfo(), Factory(lev));
}
fillpatch_state(lev, a_time, *mf, nGrow);

Expand All @@ -314,8 +315,8 @@ PeleLM::fillPatchReact(int lev, Real a_time, int nGrow)
IRsize += 1;
#endif
std::unique_ptr<MultiFab> mf;
mf.reset(
new MultiFab(grids[lev], dmap[lev], IRsize, nGrow, MFInfo(), Factory(lev)));
mf = std::make_unique<MultiFab>(
grids[lev], dmap[lev], IRsize, nGrow, MFInfo(), Factory(lev));
fillpatch_reaction(lev, a_time, *mf, nGrow);

return mf;
Expand Down
7 changes: 4 additions & 3 deletions Source/PeleLMDiffusion.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
#include <PeleLM_K.H>
#include <DiffusionOp.H>
#include <AMReX_PlotFileUtil.H>
#include <memory>

#ifdef AMREX_USE_EB
#include <AMReX_EB_utils.H>
Expand All @@ -15,7 +16,7 @@ DiffusionOp*
PeleLM::getDiffusionOp()
{
if (!m_diffusion_op) {
m_diffusion_op.reset(new DiffusionOp(this));
m_diffusion_op = std::make_unique<DiffusionOp>(this);
}
return m_diffusion_op.get();
}
Expand All @@ -24,7 +25,7 @@ DiffusionOp*
PeleLM::getMCDiffusionOp(int ncomp)
{
if (!m_mcdiffusion_op || m_mcdiffusion_op->m_ncomp != ncomp) {
m_mcdiffusion_op.reset(new DiffusionOp(this, ncomp));
m_mcdiffusion_op = std::make_unique<DiffusionOp>(this, ncomp);
}
return m_mcdiffusion_op.get();
}
Expand All @@ -33,7 +34,7 @@ DiffusionTensorOp*
PeleLM::getDiffusionTensorOp()
{
if (!m_diffusionTensor_op) {
m_diffusionTensor_op.reset(new DiffusionTensorOp(this));
m_diffusionTensor_op = std::make_unique<DiffusionTensorOp>(this);
}
return m_diffusionTensor_op.get();
}
Expand Down
5 changes: 3 additions & 2 deletions Source/PeleLMEos.cpp
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
#include <PeleLM.H>
#include <PeleLM_K.H>
#include <memory>

using namespace amrex;

Expand Down Expand Up @@ -280,8 +281,8 @@ PeleLM::adjustPandDivU(std::unique_ptr<AdvanceAdvData>& advData)
// Get theta = 1 / (\Gamma * P_amb) at half time
for (int lev = 0; lev <= finest_level; ++lev) {

ThetaHalft[lev].reset(
new MultiFab(grids[lev], dmap[lev], 1, 0, MFInfo(), *m_factory[lev]));
ThetaHalft[lev] = std::make_unique<MultiFab>(
grids[lev], dmap[lev], 1, 0, MFInfo(), *m_factory[lev]);
auto const& tma = ThetaHalft[lev]->arrays();
auto const& sma_o = getLevelDataPtr(lev, AmrOldTime)->state.const_arrays();
auto const& sma_n = getLevelDataPtr(lev, AmrNewTime)->state.const_arrays();
Expand Down
29 changes: 15 additions & 14 deletions Source/PeleLMEvaluate.cpp
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
#include <PeleLM.H>
#include <AMReX_PlotFileUtil.H>
#include <memory>

using namespace amrex;

Expand Down Expand Up @@ -111,9 +112,9 @@ PeleLM::MLevaluate(

// Light version of the diffusion data container
std::unique_ptr<AdvanceDiffData> diffData;
diffData.reset(new AdvanceDiffData(
diffData = std::make_unique<AdvanceDiffData>(
finest_level, grids, dmap, m_factory, m_nGrowAdv, m_use_wbar, m_use_soret,
is_initialization));
is_initialization);
calcDivU(
is_initialization, computeDiffusionTerm, do_avgDown, AmrNewTime,
diffData);
Expand All @@ -130,9 +131,9 @@ PeleLM::MLevaluate(

// Light version of the diffusion data container
std::unique_ptr<AdvanceDiffData> diffData;
diffData.reset(new AdvanceDiffData(
diffData = std::make_unique<AdvanceDiffData>(
finest_level, grids, dmap, m_factory, m_nGrowAdv, m_use_wbar,
is_initialization));
is_initialization);
calcDivU(
is_initialization, computeDiffusionTerm, do_avgDown, AmrNewTime,
diffData);
Expand Down Expand Up @@ -166,9 +167,9 @@ PeleLM::MLevaluate(
// Use the diffusion data holder, get diffusivity and calc D
// Finally, copy into a_MFVec
std::unique_ptr<AdvanceDiffData> diffData;
diffData.reset(new AdvanceDiffData(
diffData = std::make_unique<AdvanceDiffData>(
finest_level, grids, dmap, m_factory, m_nGrowAdv, m_use_wbar,
m_use_soret));
m_use_soret);
calcDiffusivity(AmrNewTime);
computeDifferentialDiffusionTerms(AmrNewTime, diffData);
for (int lev = 0; lev <= finest_level; ++lev) {
Expand Down Expand Up @@ -270,12 +271,12 @@ PeleLM::evaluateChemExtForces(
//----------------------------------------------------------------
// Data for the advance, only live for the duration of the advance
std::unique_ptr<AdvanceDiffData> diffData;
diffData.reset(new AdvanceDiffData(
finest_level, grids, dmap, m_factory, m_nGrowAdv, m_use_wbar, m_use_soret));
diffData = std::make_unique<AdvanceDiffData>(
finest_level, grids, dmap, m_factory, m_nGrowAdv, m_use_wbar, m_use_soret);
std::unique_ptr<AdvanceAdvData> advData;
advData.reset(new AdvanceAdvData(
advData = std::make_unique<AdvanceAdvData>(
finest_level, grids, dmap, m_factory, m_incompressible, m_nGrowAdv,
m_nGrowMAC));
m_nGrowMAC);

//----------------------------------------------------------------
// Advance setup
Expand Down Expand Up @@ -372,12 +373,12 @@ PeleLM::evaluateAdvectionTerms(
//----------------------------------------------------------------
// Data for the advance, only live for the duration of the advance
std::unique_ptr<AdvanceDiffData> diffData;
diffData.reset(new AdvanceDiffData(
finest_level, grids, dmap, m_factory, m_nGrowAdv, m_use_wbar, m_use_soret));
diffData = std::make_unique<AdvanceDiffData>(
finest_level, grids, dmap, m_factory, m_nGrowAdv, m_use_wbar, m_use_soret);
std::unique_ptr<AdvanceAdvData> advData;
advData.reset(new AdvanceAdvData(
advData = std::make_unique<AdvanceAdvData>(
finest_level, grids, dmap, m_factory, m_incompressible, m_nGrowAdv,
m_nGrowMAC));
m_nGrowMAC);

//----------------------------------------------------------------
// Advance setup
Expand Down
32 changes: 17 additions & 15 deletions Source/PeleLMInit.cpp
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
#include <PeleLM.H>
#include <memory>
#include <pelelm_prob.H>
#ifdef AMREX_USE_EB
#include <AMReX_EB_utils.H>
Expand Down Expand Up @@ -55,24 +56,25 @@ PeleLM::MakeNewLevelFromScratch(
m_factory[lev] = makeEBFabFactory(
geom[lev], grids[lev], dmap[lev], {6, 6, 6}, EBSupport::full);
#else
m_factory[lev].reset(new FArrayBoxFactory());
m_factory[lev] = std::make_unique<FArrayBoxFactory>();
#endif

// Initialize the LevelData
m_leveldata_old[lev].reset(new LevelData(
m_leveldata_old[lev] = std::make_unique<LevelData>(
grids[lev], dmap[lev], *m_factory[lev], m_incompressible, m_has_divu,
m_nAux, m_nGrowState, m_use_soret, static_cast<int>(m_do_les)));
m_leveldata_new[lev].reset(new LevelData(
m_nAux, m_nGrowState, m_use_soret, static_cast<int>(m_do_les));
m_leveldata_new[lev] = std::make_unique<LevelData>(
grids[lev], dmap[lev], *m_factory[lev], m_incompressible, m_has_divu,
m_nAux, m_nGrowState, m_use_soret, static_cast<int>(m_do_les)));
m_nAux, m_nGrowState, m_use_soret, static_cast<int>(m_do_les));

if (max_level > 0 && lev != max_level) {
m_coveredMask[lev].reset(new iMultiFab(grids[lev], dmap[lev], 1, 0));
m_coveredMask[lev] =
std::make_unique<iMultiFab>(grids[lev], dmap[lev], 1, 0);
m_resetCoveredMask = 1;
}
if (m_do_react != 0) {
m_leveldatareact[lev].reset(
new LevelDataReact(grids[lev], dmap[lev], *m_factory[lev]));
m_leveldatareact[lev] =
std::make_unique<LevelDataReact>(grids[lev], dmap[lev], *m_factory[lev]);
m_leveldatareact[lev]->functC.setVal(0.0);
}

Expand Down Expand Up @@ -109,12 +111,12 @@ PeleLM::MakeNewLevelFromScratch(
MLMG::Location::FaceCentroid, // Location of beta
MLMG::Location::CellCenter)); // Location of solution variable phi
#else
macproj.reset(new Hydro::MacProjector(Geom(0, finest_level)));
macproj = std::make_unique<Hydro::MacProjector>(Geom(0, finest_level));
#endif
m_macProjOldSize = finest_level + 1;
m_extSource[lev].reset(new MultiFab(
m_extSource[lev] = std::make_unique<MultiFab>(
grids[lev], dmap[lev], NVAR, amrex::max(m_nGrowAdv, m_nGrowMAC), MFInfo(),
*m_factory[lev]));
*m_factory[lev]);
m_extSource[lev]->setVal(0.);

#ifdef AMREX_USE_EB
Expand Down Expand Up @@ -377,9 +379,9 @@ PeleLM::projectInitSolution()

// Light version of the diffusion data container
std::unique_ptr<AdvanceDiffData> diffData;
diffData.reset(new AdvanceDiffData(
diffData = std::make_unique<AdvanceDiffData>(
finest_level, grids, dmap, m_factory, m_nGrowAdv, m_use_wbar,
m_use_soret, is_initialization));
m_use_soret, is_initialization);
calcDivU(
is_initialization, computeDiffusionTerm, do_avgDown, AmrNewTime,
diffData);
Expand Down Expand Up @@ -432,9 +434,9 @@ PeleLM::projectInitSolution()

// Light version of the diffusion data container
std::unique_ptr<AdvanceDiffData> diffData;
diffData.reset(new AdvanceDiffData(
diffData = std::make_unique<AdvanceDiffData>(
finest_level, grids, dmap, m_factory, m_nGrowAdv, m_use_wbar,
m_use_soret, is_initialization));
m_use_soret, is_initialization);
calcDivU(
is_initialization, computeDiffusionTerm, do_avgDown, AmrNewTime,
diffData);
Expand Down
3 changes: 2 additions & 1 deletion Source/PeleLMPlot.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
#include <AMReX_ParmParse.H>
#include <PeleLMBCfill.H>
#include <AMReX_FillPatchUtil.H>
#include <memory>
#ifdef AMREX_USE_EB
#include <AMReX_EBInterpolater.H>
#endif
Expand Down Expand Up @@ -304,7 +305,7 @@ PeleLM::WritePlotFile()

if (m_plotHeatRelease != 0) {
std::unique_ptr<MultiFab> mf;
mf.reset(new MultiFab(grids[lev], dmap[lev], 1, 0));
mf = std::make_unique<MultiFab>(grids[lev], dmap[lev], 1, 0);
getHeatRelease(lev, mf.get());
MultiFab::Copy(mf_plt[lev], *mf, 0, cnt, 1, 0);
cnt += 1;
Expand Down
25 changes: 13 additions & 12 deletions Source/PeleLMProjection.cpp
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
#include <PeleLM.H>
#include <memory>

using namespace amrex;

Expand Down Expand Up @@ -26,8 +27,8 @@ PeleLM::initialProjection()
if (m_incompressible == 0) {
for (int lev = 0; lev <= finest_level; ++lev) {

sigma[lev].reset(new MultiFab(
grids[lev], dmap[lev], 1, nGhost, MFInfo(), *m_factory[lev]));
sigma[lev] = std::make_unique<MultiFab>(
grids[lev], dmap[lev], 1, nGhost, MFInfo(), *m_factory[lev]);

auto* ldata_p = getLevelDataPtr(lev, AmrNewTime);

Expand Down Expand Up @@ -137,8 +138,8 @@ PeleLM::initialPressProjection()
if (m_incompressible == 0) {
for (int lev = 0; lev <= finest_level; ++lev) {

sigma[lev].reset(new MultiFab(
grids[lev], dmap[lev], 1, nGhost, MFInfo(), *m_factory[lev]));
sigma[lev] = std::make_unique<MultiFab>(
grids[lev], dmap[lev], 1, nGhost, MFInfo(), *m_factory[lev]);

auto* ldata_p = getLevelDataPtr(lev, AmrNewTime);

Expand Down Expand Up @@ -193,8 +194,8 @@ PeleLM::velocityProjection(
rhoHalf = getDensityVect(a_rhoTime);
for (int lev = 0; lev <= finest_level; ++lev) {

sigma[lev].reset(new MultiFab(
grids[lev], dmap[lev], 1, nGhost, MFInfo(), *m_factory[lev]));
sigma[lev] = std::make_unique<MultiFab>(
grids[lev], dmap[lev], 1, nGhost, MFInfo(), *m_factory[lev]);

#ifdef AMREX_USE_OMP
#pragma omp parallel if (Gpu::notInLaunchRegion())
Expand Down Expand Up @@ -426,16 +427,16 @@ PeleLM::doNodalProject(

if (m_incompressible != 0) {
Real constant_sigma = scaling_factor / m_rho;
nodal_projector.reset(new Hydro::NodalProjector(
a_vel, constant_sigma, Geom(0, finest_level), info));
nodal_projector = std::make_unique<Hydro::NodalProjector>(
a_vel, constant_sigma, Geom(0, finest_level), info);
} else {
if (has_rhs != 0) {
nodal_projector.reset(new Hydro::NodalProjector(
nodal_projector = std::make_unique<Hydro::NodalProjector>(
a_vel, GetVecOfConstPtrs(a_sigma), Geom(0, finest_level), info, rhs_cc,
rhs_nd));
rhs_nd);
} else {
nodal_projector.reset(new Hydro::NodalProjector(
a_vel, GetVecOfConstPtrs(a_sigma), Geom(0, finest_level), info));
nodal_projector = std::make_unique<Hydro::NodalProjector>(
a_vel, GetVecOfConstPtrs(a_sigma), Geom(0, finest_level), info);
}
}

Expand Down
Loading

0 comments on commit b61c45a

Please sign in to comment.