From 6cdf256835b6f61a48c50d313f843638a8cd6643 Mon Sep 17 00:00:00 2001 From: Weiqun Zhang Date: Tue, 19 Mar 2024 15:29:27 -0700 Subject: [PATCH] Clang-Tidy 17: cppcoreguidelines-avoid-const-or-ref-data-members (#3817) --- Src/Amr/AMReX_AmrLevel.H | 8 +- Src/Amr/AMReX_AmrLevel.cpp | 100 +++++++++---------- Src/Amr/AMReX_StateData.H | 2 +- Src/Amr/AMReX_StateData.cpp | 34 +++---- Src/Base/AMReX_GpuRange.H | 6 +- Src/Base/AMReX_MFIter.H | 10 +- Src/Base/AMReX_MFIter.cpp | 26 ++--- Src/Base/AMReX_ParmParse.H | 6 +- Src/Base/AMReX_ParmParse.cpp | 164 +++++++++++++++---------------- Src/Base/AMReX_Utility.H | 2 +- Src/Base/AMReX_Utility.cpp | 28 +++--- Src/EB/AMReX_EB_chkpt_file.H | 20 ++-- Src/EB/AMReX_algoim_K.H | 44 ++++----- Src/Particle/AMReX_BinIterator.H | 2 +- Src/Particle/AMReX_ParIter.H | 27 ++--- Src/Particle/AMReX_Particle.H | 50 +++++----- 16 files changed, 265 insertions(+), 264 deletions(-) diff --git a/Src/Amr/AMReX_AmrLevel.H b/Src/Amr/AMReX_AmrLevel.H index 8abb00b5475..37d0bdb9200 100644 --- a/Src/Amr/AMReX_AmrLevel.H +++ b/Src/Amr/AMReX_AmrLevel.H @@ -553,8 +553,8 @@ private: // // The data. // - AmrLevel& m_amrlevel; - MultiFab& m_leveldata; + AmrLevel* m_amrlevel; + MultiFab* m_leveldata; std::vector< std::pair > m_range; MultiFab m_fabs; int m_ncomp; @@ -591,8 +591,8 @@ private: // // The data. // - AmrLevel& m_amrlevel; - MultiFab& m_leveldata; + AmrLevel* m_amrlevel; + MultiFab* m_leveldata; MultiFabCopyDescriptor m_mfcd; Vector< Vector > m_mfid; // [level][oldnew] Interpolater* m_map = nullptr; diff --git a/Src/Amr/AMReX_AmrLevel.cpp b/Src/Amr/AMReX_AmrLevel.cpp index ab16f6ba827..ee36bad35d1 100644 --- a/Src/Amr/AMReX_AmrLevel.cpp +++ b/Src/Amr/AMReX_AmrLevel.cpp @@ -663,17 +663,17 @@ AmrLevel::setPhysBoundaryValues (FArrayBox& dest, FillPatchIteratorHelper::FillPatchIteratorHelper (AmrLevel& amrlevel, MultiFab& leveldata) : - m_amrlevel(amrlevel), - m_leveldata(leveldata), - m_mfid(m_amrlevel.level+1) + m_amrlevel(&amrlevel), + m_leveldata(&leveldata), + m_mfid(m_amrlevel->level+1) {} FillPatchIterator::FillPatchIterator (AmrLevel& amrlevel, MultiFab& leveldata) : MFIter(leveldata), - m_amrlevel(amrlevel), - m_leveldata(leveldata), + m_amrlevel(&amrlevel), + m_leveldata(&leveldata), m_ncomp(0) { MFIter::depth = 0; @@ -688,9 +688,9 @@ FillPatchIteratorHelper::FillPatchIteratorHelper (AmrLevel& amrlevel, int ncomp, InterpBase* mapper) : - m_amrlevel(amrlevel), - m_leveldata(leveldata), - m_mfid(m_amrlevel.level+1), + m_amrlevel(&amrlevel), + m_leveldata(&leveldata), + m_mfid(m_amrlevel->level+1), m_time(time), m_growsize(boxGrow), m_index(index), @@ -709,8 +709,8 @@ FillPatchIterator::FillPatchIterator (AmrLevel& amrlevel, int ncomp) : MFIter(leveldata), - m_amrlevel(amrlevel), - m_leveldata(leveldata), + m_amrlevel(&amrlevel), + m_leveldata(&leveldata), m_ncomp(ncomp) { BL_ASSERT(scomp >= 0); @@ -757,24 +757,24 @@ FillPatchIteratorHelper::Initialize (int boxGrow, m_index = idx; m_scomp = scomp; m_ncomp = ncomp; - m_FixUpCorners = NeedToTouchUpPhysCorners(m_amrlevel.geom); + m_FixUpCorners = NeedToTouchUpPhysCorners(m_amrlevel->geom); const int MyProc = ParallelDescriptor::MyProc(); - auto& amrLevels = m_amrlevel.parent->getAmrLevels(); - const AmrLevel& topLevel = *amrLevels[m_amrlevel.level]; + auto& amrLevels = m_amrlevel->parent->getAmrLevels(); + const AmrLevel& topLevel = *amrLevels[m_amrlevel->level]; const Box& topPDomain = topLevel.state[m_index].getDomain(); - const IndexType& boxType = m_leveldata.boxArray().ixType(); + const IndexType& boxType = m_leveldata->boxArray().ixType(); const bool extrap = AmrLevel::desc_lst[m_index].extrap(); // // Check that the interpolaters are identical. // BL_ASSERT(AmrLevel::desc_lst[m_index].identicalInterps(scomp,ncomp)); - for (int l = 0; l <= m_amrlevel.level; ++l) + for (int l = 0; l <= m_amrlevel->level; ++l) { amrLevels[l]->state[m_index].RegisterData(m_mfcd, m_mfid[l]); } - for (int i = 0, N = static_cast(m_leveldata.boxArray().size()); i < N; ++i) + for (int i = 0, N = static_cast(m_leveldata->boxArray().size()); i < N; ++i) { // // A couple typedefs we'll use in the next code segment. @@ -783,20 +783,20 @@ FillPatchIteratorHelper::Initialize (int boxGrow, using IntAAAFBIDMapValType = std::map > > >::value_type; - if (m_leveldata.DistributionMap()[i] != MyProc) { continue; } + if (m_leveldata->DistributionMap()[i] != MyProc) { continue; } // // Insert with a hint since the indices are ordered lowest to highest. // IntAAAFBIDMapValType v1(i,Vector > >()); - m_fbid.insert(m_fbid.end(),v1)->second.resize(m_amrlevel.level+1); + m_fbid.insert(m_fbid.end(),v1)->second.resize(m_amrlevel->level+1); IntAABoxMapValType v2(i,Vector >()); - m_fbox.insert(m_fbox.end(),v2)->second.resize(m_amrlevel.level+1); - m_cbox.insert(m_cbox.end(),v2)->second.resize(m_amrlevel.level+1); + m_fbox.insert(m_fbox.end(),v2)->second.resize(m_amrlevel->level+1); + m_cbox.insert(m_cbox.end(),v2)->second.resize(m_amrlevel->level+1); - m_ba.insert(m_ba.end(),std::map::value_type(i,amrex::grow(m_leveldata.boxArray()[i],m_growsize))); + m_ba.insert(m_ba.end(),std::map::value_type(i,amrex::grow(m_leveldata->boxArray()[i],m_growsize))); } BoxList tempUnfillable(boxType); @@ -863,7 +863,7 @@ FillPatchIteratorHelper::Initialize (int boxGrow, Vector< Vector >& TheFineBoxes = m_fbox[bxidx]; Vector< Vector< Vector > >& TheFBIDs = m_fbid[bxidx]; - for (int l = m_amrlevel.level; l >= 0 && !Done; --l) + for (int l = m_amrlevel->level; l >= 0 && !Done; --l) { unfillableThisLevel.clear(); @@ -893,7 +893,7 @@ FillPatchIteratorHelper::Initialize (int boxGrow, { crse_boxes.push_back(fbx); - if (l != m_amrlevel.level) + if (l != m_amrlevel->level) { const Box& cbox = m_map->CoarseBox(fbx,fine_ratio); @@ -1000,15 +1000,15 @@ FillPatchIterator::Initialize (int boxGrow, m_ncomp = ncomp; m_range = desc.sameInterps(scomp,ncomp); - m_fabs.define(m_leveldata.boxArray(),m_leveldata.DistributionMap(), - m_ncomp,boxGrow,MFInfo(),m_leveldata.Factory()); + m_fabs.define(m_leveldata->boxArray(),m_leveldata->DistributionMap(), + m_ncomp,boxGrow,MFInfo(),m_leveldata->Factory()); - const Geometry& geom = m_amrlevel.Geom(); + const Geometry& geom = m_amrlevel->Geom(); m_fabs.setDomainBndry(std::numeric_limits::quiet_NaN(), geom); - const IndexType& boxType = m_leveldata.boxArray().ixType(); - const int level = m_amrlevel.level; + const IndexType& boxType = m_leveldata->boxArray().ixType(); + const int level = m_amrlevel->level; for (int i = 0, DComp = 0; i < static_cast(m_range.size()); i++) { @@ -1022,8 +1022,8 @@ FillPatchIterator::Initialize (int boxGrow, else { if (level == 1 || - amrex::ProperlyNested(m_amrlevel.crse_ratio, - m_amrlevel.parent->blockingFactor(m_amrlevel.level), + amrex::ProperlyNested(m_amrlevel->crse_ratio, + m_amrlevel->parent->blockingFactor(m_amrlevel->level), boxGrow, boxType, desc.interp(SComp))) { FillFromTwoLevels(time, idx, SComp, DComp, NComp); @@ -1035,7 +1035,7 @@ FillPatchIterator::Initialize (int boxGrow, # endif { IntVect new_blocking_factor = AmrLevel::ProperBlockingFactor - (m_amrlevel, boxGrow, boxType, desc, SComp); + (*m_amrlevel, boxGrow, boxType, desc, SComp); amrex::Print() << "WARNING: Grids are not properly nested. Consider using amr.blocking_factor = " << AMREX_D_TERM(new_blocking_factor[0], << " " << new_blocking_factor[1], @@ -1050,7 +1050,7 @@ FillPatchIterator::Initialize (int boxGrow, first = false; if (ParallelDescriptor::IOProcessor() && amrex::Verbose()) { IntVect new_blocking_factor = AmrLevel::ProperBlockingFactor - (m_amrlevel, boxGrow, boxType, desc, SComp); + (*m_amrlevel, boxGrow, boxType, desc, SComp); amrex::Print() << "WARNING: Grids are not properly nested. We might have to use\n" << " two coarse levels to do fillpatch. Consider using\n"; if (new_blocking_factor < IntVect{AMREX_D_DECL(128,128,128)}) { @@ -1061,8 +1061,8 @@ FillPatchIterator::Initialize (int boxGrow, } } - auto* fph = new FillPatchIteratorHelper(m_amrlevel, - m_leveldata, + auto* fph = new FillPatchIteratorHelper(*m_amrlevel, + *m_leveldata, boxGrow, time, idx, @@ -1087,7 +1087,7 @@ FillPatchIterator::Initialize (int boxGrow, // // Call hack to touch up fillPatched data. // - m_amrlevel.set_preferred_boundary_values(m_fabs, + m_amrlevel->set_preferred_boundary_values(m_fabs, idx, scomp, 0, @@ -1099,15 +1099,15 @@ void FillPatchIterator::FillFromLevel0 (Real time, int idx, int scomp, int dcomp, int ncomp) { BL_PROFILE("FillPatchIterator::FillFromLevel0()"); - BL_ASSERT(m_amrlevel.level == 0); + BL_ASSERT(m_amrlevel->level == 0); - StateData& statedata = m_amrlevel.state[idx]; + StateData& statedata = m_amrlevel->state[idx]; Vector smf; Vector stime; statedata.getData(smf,stime,time); - const Geometry& geom = m_amrlevel.geom; + const Geometry& geom = m_amrlevel->geom; StateDataPhysBCFunct physbcf(statedata,scomp,geom); @@ -1118,13 +1118,13 @@ void FillPatchIterator::FillFromTwoLevels (Real time, int idx, int scomp, int dcomp, int ncomp) { BL_PROFILE("FillPatchIterator::FillFromTwoLevels()"); - int ilev_fine = m_amrlevel.level; + int ilev_fine = m_amrlevel->level; int ilev_crse = ilev_fine-1; BL_ASSERT(ilev_crse >= 0); - AmrLevel& fine_level = m_amrlevel; - AmrLevel& crse_level = m_amrlevel.parent->getLevel(ilev_crse); + AmrLevel& fine_level = *m_amrlevel; + AmrLevel& crse_level = m_amrlevel->parent->getLevel(ilev_crse); const Geometry& geom_fine = fine_level.geom; const Geometry& geom_crse = crse_level.geom; @@ -1271,17 +1271,17 @@ FillPatchIteratorHelper::fill (FArrayBox& fab, BL_ASSERT(fab.box() == m_ba[idx]); BL_ASSERT(fab.nComp() >= dcomp + m_ncomp); - Vector< Vector > > cfab(m_amrlevel.level+1); + Vector< Vector > > cfab(m_amrlevel->level+1); Vector< Vector >& TheCrseBoxes = m_cbox[idx]; Vector< Vector >& TheFineBoxes = m_fbox[idx]; Vector< Vector< Vector > >& TheFBIDs = m_fbid[idx]; const bool extrap = AmrLevel::desc_lst[m_index].extrap(); - auto& amrLevels = m_amrlevel.parent->getAmrLevels(); + auto& amrLevels = m_amrlevel->parent->getAmrLevels(); // // Build all coarse fabs from which we'll interpolate and // fill them with coarse data as best we can. // - for (int l = 0; l <= m_amrlevel.level; l++) + for (int l = 0; l <= m_amrlevel->level; l++) { StateData& TheState = amrLevels[l]->state[m_index]; const Vector& CrseBoxes = TheCrseBoxes[l]; @@ -1326,7 +1326,7 @@ FillPatchIteratorHelper::fill (FArrayBox& fab, // // Now work from the bottom up interpolating to next higher level. // - for (int l = 0; l < m_amrlevel.level; l++) + for (int l = 0; l < m_amrlevel->level; l++) { auto& CrseFabs = cfab[l]; AmrLevel& TheLevel = *amrLevels[l]; @@ -1455,10 +1455,10 @@ FillPatchIteratorHelper::fill (FArrayBox& fab, // // Now for the finest level stuff. // - StateData& FineState = m_amrlevel.state[m_index]; + StateData& FineState = m_amrlevel->state[m_index]; const Box& FineDomain = FineState.getDomain(); - const Geometry& FineGeom = m_amrlevel.geom; - auto& FinestCrseFabs = cfab[m_amrlevel.level]; + const Geometry& FineGeom = m_amrlevel->geom; + auto& FinestCrseFabs = cfab[m_amrlevel->level]; // // Copy intersect coarse into destination fab. // @@ -1498,7 +1498,7 @@ FillPatchIteratorHelper::fill (FArrayBox& fab, // if (! FineState.getDomain().contains(fab.box())) { - m_amrlevel.setPhysBoundaryValues(fab, + m_amrlevel->setPhysBoundaryValues(fab, m_index, m_time, dcomp, @@ -1509,7 +1509,7 @@ FillPatchIteratorHelper::fill (FArrayBox& fab, if (m_FixUpCorners) { - FixUpPhysCorners(fab,m_amrlevel,m_index,m_time,m_scomp,dcomp,m_ncomp); + FixUpPhysCorners(fab,*m_amrlevel,m_index,m_time,m_scomp,dcomp,m_ncomp); Gpu::streamSynchronize(); // In case this runs on GPU } } diff --git a/Src/Amr/AMReX_StateData.H b/Src/Amr/AMReX_StateData.H index e6edb486c41..e030eacb5b1 100644 --- a/Src/Amr/AMReX_StateData.H +++ b/Src/Amr/AMReX_StateData.H @@ -470,7 +470,7 @@ public: private: StateData* statedata; int src_comp; - const Geometry& geom; + const Geometry* geom; }; diff --git a/Src/Amr/AMReX_StateData.cpp b/Src/Amr/AMReX_StateData.cpp index fffa8074e8b..7fd2c0c5745 100644 --- a/Src/Amr/AMReX_StateData.cpp +++ b/Src/Amr/AMReX_StateData.cpp @@ -863,7 +863,7 @@ StateData::printTimeInterval (std::ostream &os) const StateDataPhysBCFunct::StateDataPhysBCFunct (StateData&sd, int sc, const Geometry& geom_) : statedata(&sd), src_comp(sc), - geom(geom_) + geom(&geom_) { } void @@ -876,8 +876,8 @@ StateDataPhysBCFunct::operator() (MultiFab& mf, int dest_comp, int num_comp, Int const Box& domain_mt = amrex::convert(statedata->getDomain(),mf.ixType()); const int* domainlo = domain_mt.loVect(); const int* domainhi = domain_mt.hiVect(); - const Real* dx = geom.CellSize(); - const RealBox& prob_domain = geom.ProbDomain(); + const Real* dx = geom->CellSize(); + const RealBox& prob_domain = geom->ProbDomain(); bool has_bndryfunc_fab = statedata->desc->hasBndryFuncFab(); bool run_on_gpu = statedata->desc->RunOnGPU() && Gpu::inLaunchRegion(); @@ -901,7 +901,7 @@ StateDataPhysBCFunct::operator() (MultiFab& mf, int dest_comp, int num_comp, Int bool is_periodic = false; for (int i = 0; i < AMREX_SPACEDIM; ++i) { bool touch = bx.smallEnd(i) < domainlo[i] || bx.bigEnd(i) > domainhi[i]; - if (geom.isPeriodic(i)) { + if (geom->isPeriodic(i)) { is_periodic = is_periodic || touch; } else { has_phys_bc = has_phys_bc || touch; @@ -911,7 +911,7 @@ StateDataPhysBCFunct::operator() (MultiFab& mf, int dest_comp, int num_comp, Int if (has_phys_bc) { if (has_bndryfunc_fab) { - statedata->FillBoundary(bx, dest, time, geom, dest_comp, src_comp, num_comp); + statedata->FillBoundary(bx, dest, time, *geom, dest_comp, src_comp, num_comp); } else { statedata->FillBoundary(dest, time, dx, prob_domain, dest_comp, src_comp, num_comp); } @@ -922,7 +922,7 @@ StateDataPhysBCFunct::operator() (MultiFab& mf, int dest_comp, int num_comp, Int for (int dir = 0; dir < AMREX_SPACEDIM; dir++) { - if (!geom.isPeriodic(dir)) + if (!(geom->isPeriodic(dir))) { const int lo = domainlo[dir] - bx.smallEnd(dir); const int hi = bx.bigEnd(dir) - domainhi[dir]; @@ -933,12 +933,12 @@ StateDataPhysBCFunct::operator() (MultiFab& mf, int dest_comp, int num_comp, Int for (int dir = 0; dir < AMREX_SPACEDIM; dir++) { - if (!geom.isPeriodic(dir)) { continue; } + if (!(geom->isPeriodic(dir))) { continue; } Box lo_slab = bx; Box hi_slab = bx; - lo_slab.shift(dir, geom.period(dir)); - hi_slab.shift(dir,-geom.period(dir)); + lo_slab.shift(dir, geom->period(dir)); + hi_slab.shift(dir,-geom->period(dir)); lo_slab &= GrownDomain; hi_slab &= GrownDomain; @@ -950,7 +950,7 @@ StateDataPhysBCFunct::operator() (MultiFab& mf, int dest_comp, int num_comp, Int tmp.resize(lo_slab,num_comp); Elixir elitmp = tmp.elixir(); Array4 const& tmpa = tmp.array(); - const int ishift = -geom.period(dir); + const int ishift = -geom->period(dir); amrex::launch(lo_slab, [=] AMREX_GPU_DEVICE (Box const& tbx) noexcept { @@ -971,7 +971,7 @@ StateDataPhysBCFunct::operator() (MultiFab& mf, int dest_comp, int num_comp, Int } }); if (has_bndryfunc_fab) { - statedata->FillBoundary(lo_slab, tmp, time, geom, 0, src_comp, num_comp); + statedata->FillBoundary(lo_slab, tmp, time, *geom, 0, src_comp, num_comp); } else { statedata->FillBoundary(tmp, time, dx, prob_domain, 0, src_comp, num_comp); } @@ -999,10 +999,10 @@ StateDataPhysBCFunct::operator() (MultiFab& mf, int dest_comp, int num_comp, Int #endif { tmp.resize(lo_slab,num_comp); - const Box db = amrex::shift(lo_slab, dir, -geom.period(dir)); + const Box db = amrex::shift(lo_slab, dir, -geom->period(dir)); tmp.copy(dest, db, dest_comp, lo_slab, 0, num_comp); if (has_bndryfunc_fab) { - statedata->FillBoundary(lo_slab, tmp, time, geom, 0, src_comp, num_comp); + statedata->FillBoundary(lo_slab, tmp, time, *geom, 0, src_comp, num_comp); } else { statedata->FillBoundary(tmp, time, dx, prob_domain, 0, src_comp, num_comp); } @@ -1018,7 +1018,7 @@ StateDataPhysBCFunct::operator() (MultiFab& mf, int dest_comp, int num_comp, Int tmp.resize(hi_slab,num_comp); Elixir elitmp = tmp.elixir(); Array4 const& tmpa = tmp.array(); - const int ishift = geom.period(dir); + const int ishift = geom->period(dir); amrex::launch(hi_slab, [=] AMREX_GPU_DEVICE (Box const& tbx) noexcept { @@ -1039,7 +1039,7 @@ StateDataPhysBCFunct::operator() (MultiFab& mf, int dest_comp, int num_comp, Int } }); if (has_bndryfunc_fab) { - statedata->FillBoundary(hi_slab, tmp, time, geom, 0, src_comp, num_comp); + statedata->FillBoundary(hi_slab, tmp, time, *geom, 0, src_comp, num_comp); } else { statedata->FillBoundary(tmp, time, dx, prob_domain, 0, src_comp, num_comp); } @@ -1067,10 +1067,10 @@ StateDataPhysBCFunct::operator() (MultiFab& mf, int dest_comp, int num_comp, Int #endif { tmp.resize(hi_slab,num_comp); - const Box db = amrex::shift(hi_slab, dir, geom.period(dir)); + const Box db = amrex::shift(hi_slab, dir, geom->period(dir)); tmp.copy(dest, db, dest_comp, hi_slab, 0, num_comp); if (has_bndryfunc_fab) { - statedata->FillBoundary(hi_slab, tmp, time, geom, 0, src_comp, num_comp); + statedata->FillBoundary(hi_slab, tmp, time, *geom, 0, src_comp, num_comp); } else { statedata->FillBoundary(tmp, time, dx, prob_domain, 0, src_comp, num_comp); } diff --git a/Src/Base/AMReX_GpuRange.H b/Src/Base/AMReX_GpuRange.H index be5071dbf8a..5efe417d007 100644 --- a/Src/Base/AMReX_GpuRange.H +++ b/Src/Base/AMReX_GpuRange.H @@ -73,7 +73,7 @@ struct range_impl struct iterator { AMREX_GPU_HOST_DEVICE - iterator (T const& b, Long i, Long s) noexcept : mi_b(b), mi_i(i), mi_s(s) {} + iterator (T const& b, Long i, Long s) noexcept : mi_b(&b), mi_i(i), mi_s(s) {} AMREX_GPU_HOST_DEVICE void operator++ () noexcept { mi_i += mi_s; } @@ -82,10 +82,10 @@ struct range_impl bool operator!= (iterator const& rhs) const noexcept { return mi_i < rhs.mi_i; } AMREX_GPU_HOST_DEVICE - T operator* () const noexcept { return range_detail::at(mi_b,mi_i); } + T operator* () const noexcept { return range_detail::at(*mi_b,mi_i); } private: - T const& mi_b; + T const* mi_b; Long mi_i; Long mi_s; }; diff --git a/Src/Base/AMReX_MFIter.H b/Src/Base/AMReX_MFIter.H index bfad2d8c32f..7f0ca4d3539 100644 --- a/Src/Base/AMReX_MFIter.H +++ b/Src/Base/AMReX_MFIter.H @@ -129,10 +129,10 @@ public: [[nodiscard]] Box grownnodaltilebox (int dir, const IntVect& ng) const noexcept; //! Return the valid Box in which the current tile resides. - [[nodiscard]] Box validbox () const noexcept { return fabArray.box((*index_map)[currentIndex]); } + [[nodiscard]] Box validbox () const noexcept { return fabArray->box((*index_map)[currentIndex]); } //! Return the Box of the FAB at which we currently point. - [[nodiscard]] Box fabbox () const noexcept { return fabArray.fabbox((*index_map)[currentIndex]); } + [[nodiscard]] Box fabbox () const noexcept { return fabArray->fabbox((*index_map)[currentIndex]); } //! Increment iterator to the next tile we own. void operator++ () noexcept; @@ -159,11 +159,11 @@ public: [[nodiscard]] int LocalIndex () const noexcept { return local_index_map ? (*local_index_map)[currentIndex] : currentIndex; } //! Constant reference to FabArray over which we're iterating. - [[nodiscard]] const FabArrayBase& theFabArrayBase () const noexcept { return fabArray; } + [[nodiscard]] const FabArrayBase& theFabArrayBase () const noexcept { return *fabArray; } [[nodiscard]] int tileIndex () const noexcept {return currentIndex;} - [[nodiscard]] const DistributionMapping& DistributionMap () const noexcept { return fabArray.DistributionMap(); } + [[nodiscard]] const DistributionMapping& DistributionMap () const noexcept { return fabArray->DistributionMap(); } static int allowMultipleMFIters (int allow); @@ -173,7 +173,7 @@ protected: std::unique_ptr m_fa; //!< This must be the first member! - const FabArrayBase& fabArray; + const FabArrayBase* fabArray; IntVect tile_size; diff --git a/Src/Base/AMReX_MFIter.cpp b/Src/Base/AMReX_MFIter.cpp index b05d0bbb2af..f68ab9ce35f 100644 --- a/Src/Base/AMReX_MFIter.cpp +++ b/Src/Base/AMReX_MFIter.cpp @@ -20,7 +20,7 @@ MFIter::allowMultipleMFIters (int allow) MFIter::MFIter (const FabArrayBase& fabarray_, unsigned char flags_) : - fabArray(fabarray_), + fabArray(&fabarray_), tile_size((flags_ & Tiling) ? FabArrayBase::mfiter_tile_size : IntVect::TheZeroVector()), flags(flags_), streams(Gpu::numGpuStreams()), @@ -38,7 +38,7 @@ MFIter::MFIter (const FabArrayBase& fabarray_, MFIter::MFIter (const FabArrayBase& fabarray_, bool do_tiling_) : - fabArray(fabarray_), + fabArray(&fabarray_), tile_size((do_tiling_) ? FabArrayBase::mfiter_tile_size : IntVect::TheZeroVector()), flags(do_tiling_ ? Tiling : 0), streams(Gpu::numGpuStreams()), @@ -57,7 +57,7 @@ MFIter::MFIter (const FabArrayBase& fabarray_, const IntVect& tilesize_, unsigned char flags_) : - fabArray(fabarray_), + fabArray(&fabarray_), tile_size(tilesize_), flags(flags_ | Tiling), streams(Gpu::numGpuStreams()), @@ -75,7 +75,7 @@ MFIter::MFIter (const FabArrayBase& fabarray_, MFIter::MFIter (const BoxArray& ba, const DistributionMapping& dm, unsigned char flags_) : m_fa(std::make_unique(ba,dm,1,0)), - fabArray(*m_fa), + fabArray(m_fa.get()), tile_size((flags_ & Tiling) ? FabArrayBase::mfiter_tile_size : IntVect::TheZeroVector()), flags(flags_), streams(Gpu::numGpuStreams()), @@ -99,7 +99,7 @@ MFIter::MFIter (const BoxArray& ba, const DistributionMapping& dm, unsigned char MFIter::MFIter (const BoxArray& ba, const DistributionMapping& dm, bool do_tiling_) : m_fa(std::make_unique(ba,dm,1,0)), - fabArray(*m_fa), + fabArray(m_fa.get()), tile_size((do_tiling_) ? FabArrayBase::mfiter_tile_size : IntVect::TheZeroVector()), flags(do_tiling_ ? Tiling : 0), streams(Gpu::numGpuStreams()), @@ -125,7 +125,7 @@ MFIter::MFIter (const BoxArray& ba, const DistributionMapping& dm, const IntVect& tilesize_, unsigned char flags_) : m_fa(std::make_unique(ba,dm,1,0)), - fabArray(*m_fa), + fabArray(m_fa.get()), tile_size(tilesize_), flags(flags_ | Tiling), streams(Gpu::numGpuStreams()), @@ -150,7 +150,7 @@ MFIter::MFIter (const BoxArray& ba, const DistributionMapping& dm, MFIter::MFIter (const BoxArray& ba, const DistributionMapping& dm, const MFItInfo& info) : m_fa(std::make_unique(ba, dm, 1, 0)), - fabArray(*m_fa), + fabArray(m_fa.get()), tile_size(info.tilesize), flags(info.do_tiling ? Tiling : 0), streams(std::max(1,std::min(Gpu::numGpuStreams(),info.num_streams))), @@ -182,7 +182,7 @@ MFIter::MFIter (const BoxArray& ba, const DistributionMapping& dm, const MFItInf MFIter::MFIter (const FabArrayBase& fabarray_, const MFItInfo& info) : - fabArray(fabarray_), + fabArray(&fabarray_), tile_size(info.tilesize), flags(info.do_tiling ? Tiling : 0), streams(std::max(1,std::min(Gpu::numGpuStreams(),info.num_streams))), @@ -282,14 +282,14 @@ MFIter::Initialize () if (flags & AllBoxes) // a very special case { - index_map = &(fabArray.IndexArray()); + index_map = &(fabArray->IndexArray()); currentIndex = 0; beginIndex = 0; endIndex = static_cast(index_map->size()); } else { - const FabArrayBase::TileArray* pta = fabArray.getTileArray(tile_size); + const FabArrayBase::TileArray* pta = fabArray->getTileArray(tile_size); index_map = &(pta->indexMap); local_index_map = &(pta->localIndexMap); @@ -366,7 +366,7 @@ MFIter::Initialize () Gpu::Device::setStreamIndex(currentIndex%streams); #endif - typ = fabArray.boxArray().ixType(); + typ = fabArray->boxArray().ixType(); } } @@ -462,7 +462,7 @@ MFIter::growntilebox (int a_ng) const noexcept { Box bx = tilebox(); IntVect ngv{a_ng}; - if (a_ng < -100) { ngv = fabArray.nGrowVect(); } + if (a_ng < -100) { ngv = fabArray->nGrowVect(); } const Box& vbx = validbox(); for (int d=0; dnGrowVect(); } return grownnodaltilebox(dir, ngv); } diff --git a/Src/Base/AMReX_ParmParse.H b/Src/Base/AMReX_ParmParse.H index b6f4799f2e8..062db374029 100644 --- a/Src/Base/AMReX_ParmParse.H +++ b/Src/Base/AMReX_ParmParse.H @@ -1062,7 +1062,7 @@ public: struct PP_entry; using Table = std::list; static void appendTable(ParmParse::Table& tab); - [[nodiscard]] const Table& table() const {return m_table;} + [[nodiscard]] const Table& table() const {return *m_table;} protected: @@ -1080,7 +1080,7 @@ protected: // //! Prefix used in keyword search. std::stack m_pstack; - Table& m_table; + Table* m_table; }; struct ParmParse::PP_entry @@ -1115,7 +1115,7 @@ public: void pop(); [[nodiscard]] std::string getPrefix() const; private: - ParmParse& m_pp; + ParmParse* m_pp; int m_np{0}; }; diff --git a/Src/Base/AMReX_ParmParse.cpp b/Src/Base/AMReX_ParmParse.cpp index 741a055b95e..962617b7fc5 100644 --- a/Src/Base/AMReX_ParmParse.cpp +++ b/Src/Base/AMReX_ParmParse.cpp @@ -1124,20 +1124,20 @@ ParmParse::getPrefix() const ParmParse::ParmParse (const std::string& prefix) : - m_table(g_table) + m_table(&g_table) { m_pstack.push(prefix); } ParmParse::ParmParse (Table& a_table) - : m_table(a_table) + : m_table(&a_table) { m_pstack.emplace(""); } ParmParse::Frame::Frame (ParmParse& pp, const std::string& pfix) : - m_pp(pp) + m_pp(&pp) { push(pfix); BL_ASSERT( m_np == 1 ); @@ -1156,7 +1156,7 @@ ParmParse::Frame::~Frame () void ParmParse::Frame::push (const std::string& str) { - m_pp.pushPrefix(str); + m_pp->pushPrefix(str); m_np++; } @@ -1164,14 +1164,14 @@ void ParmParse::Frame::pop () { BL_ASSERT( m_np > 0); - m_pp.popPrefix(); + m_pp->popPrefix(); m_np--; } std::string ParmParse::Frame::getPrefix () const { - return m_pp.getPrefix(); + return m_pp->getPrefix(); } void @@ -1375,7 +1375,7 @@ ParmParse::countval (const char* name, // // First find n'th occurrence of name in table. // - const PP_entry* def = ppindex(m_table, n, prefixedName(name), false); + const PP_entry* def = ppindex(*m_table, n, prefixedName(name), false); return def == nullptr ? 0 : static_cast(def->m_vals.size()); } @@ -1386,7 +1386,7 @@ ParmParse::getkth (const char* name, bool& ref, int ival) const { - sgetval(m_table, prefixedName(name),ref,ival,k); + sgetval(*m_table, prefixedName(name),ref,ival,k); } void @@ -1394,7 +1394,7 @@ ParmParse::get (const char* name, bool& ref, int ival) const { - sgetval(m_table, prefixedName(name),ref,ival, LAST); + sgetval(*m_table, prefixedName(name),ref,ival, LAST); } int @@ -1403,7 +1403,7 @@ ParmParse::querykth (const char* name, bool& ref, int ival) const { - return squeryval(m_table, prefixedName(name),ref,ival,k); + return squeryval(*m_table, prefixedName(name),ref,ival,k); } int @@ -1411,7 +1411,7 @@ ParmParse::query (const char* name, bool& ref, int ival) const { - return squeryval(m_table, prefixedName(name),ref,ival, LAST); + return squeryval(*m_table, prefixedName(name),ref,ival, LAST); } void @@ -1425,25 +1425,25 @@ ParmParse::add (const char* name, void ParmParse::getkth (const char* name, int k, int& ref, int ival) const { - sgetval(m_table, prefixedName(name),ref,ival,k); + sgetval(*m_table, prefixedName(name),ref,ival,k); } void ParmParse::get (const char* name, int& ref, int ival) const { - sgetval(m_table, prefixedName(name),ref,ival, LAST); + sgetval(*m_table, prefixedName(name),ref,ival, LAST); } int ParmParse::querykth (const char* name, int k, int& ref, int ival) const { - return squeryval(m_table, prefixedName(name),ref,ival,k); + return squeryval(*m_table, prefixedName(name),ref,ival,k); } int ParmParse::query (const char* name, int& ref, int ival) const { - return squeryval(m_table, prefixedName(name),ref,ival, LAST); + return squeryval(*m_table, prefixedName(name),ref,ival, LAST); } void @@ -1456,28 +1456,28 @@ void ParmParse::getktharr (const char* name, int k, std::vector& ref, int start_ix, int num_val) const { - sgetarr(m_table, prefixedName(name),ref,start_ix,num_val,k); + sgetarr(*m_table, prefixedName(name),ref,start_ix,num_val,k); } void ParmParse::getarr (const char* name, std::vector& ref, int start_ix, int num_val) const { - sgetarr(m_table, prefixedName(name),ref,start_ix,num_val, LAST); + sgetarr(*m_table, prefixedName(name),ref,start_ix,num_val, LAST); } int ParmParse::queryktharr (const char* name, int k, std::vector& ref, int start_ix, int num_val) const { - return squeryarr(m_table, prefixedName(name),ref,start_ix,num_val,k); + return squeryarr(*m_table, prefixedName(name),ref,start_ix,num_val,k); } int ParmParse::queryarr (const char* name, std::vector& ref, int start_ix, int num_val) const { - return squeryarr(m_table, prefixedName(name),ref,start_ix,num_val, LAST); + return squeryarr(*m_table, prefixedName(name),ref,start_ix,num_val, LAST); } void @@ -1491,25 +1491,25 @@ ParmParse::addarr (const char* name, const std::vector& ref) void ParmParse::getkth (const char* name, int k, long& ref, int ival) const { - sgetval(m_table, prefixedName(name),ref,ival,k); + sgetval(*m_table, prefixedName(name),ref,ival,k); } void ParmParse::get (const char* name, long& ref, int ival) const { - sgetval(m_table, prefixedName(name),ref,ival, LAST); + sgetval(*m_table, prefixedName(name),ref,ival, LAST); } int ParmParse::querykth (const char* name, int k, long& ref, int ival) const { - return squeryval(m_table, prefixedName(name),ref,ival,k); + return squeryval(*m_table, prefixedName(name),ref,ival,k); } int ParmParse::query (const char* name, long& ref, int ival) const { - return squeryval(m_table, prefixedName(name),ref,ival, LAST); + return squeryval(*m_table, prefixedName(name),ref,ival, LAST); } void @@ -1523,28 +1523,28 @@ void ParmParse::getktharr (const char* name, int k, std::vector& ref, int start_ix, int num_val) const { - sgetarr(m_table, prefixedName(name),ref,start_ix,num_val,k); + sgetarr(*m_table, prefixedName(name),ref,start_ix,num_val,k); } void ParmParse::getarr (const char* name, std::vector& ref, int start_ix, int num_val) const { - sgetarr(m_table, prefixedName(name),ref,start_ix,num_val, LAST); + sgetarr(*m_table, prefixedName(name),ref,start_ix,num_val, LAST); } int ParmParse::queryktharr (const char* name, int k, std::vector& ref, int start_ix, int num_val) const { - return squeryarr(m_table, prefixedName(name),ref,start_ix,num_val,k); + return squeryarr(*m_table, prefixedName(name),ref,start_ix,num_val,k); } int ParmParse::queryarr (const char* name, std::vector& ref, int start_ix, int num_val) const { - return squeryarr(m_table, prefixedName(name),ref,start_ix,num_val, LAST); + return squeryarr(*m_table, prefixedName(name),ref,start_ix,num_val, LAST); } void @@ -1557,25 +1557,25 @@ ParmParse::addarr (const char* name, const std::vector& ref) void ParmParse::getkth (const char* name, int k, long long& ref, int ival) const { - sgetval(m_table, prefixedName(name),ref,ival,k); + sgetval(*m_table, prefixedName(name),ref,ival,k); } void ParmParse::get (const char* name, long long& ref, int ival) const { - sgetval(m_table, prefixedName(name),ref,ival, LAST); + sgetval(*m_table, prefixedName(name),ref,ival, LAST); } int ParmParse::querykth (const char* name, int k, long long& ref, int ival) const { - return squeryval(m_table, prefixedName(name),ref,ival,k); + return squeryval(*m_table, prefixedName(name),ref,ival,k); } int ParmParse::query (const char* name, long long& ref, int ival) const { - return squeryval(m_table, prefixedName(name),ref,ival, LAST); + return squeryval(*m_table, prefixedName(name),ref,ival, LAST); } void @@ -1588,28 +1588,28 @@ void ParmParse::getktharr (const char* name, int k, std::vector& ref, int start_ix, int num_val) const { - sgetarr(m_table, prefixedName(name),ref,start_ix,num_val,k); + sgetarr(*m_table, prefixedName(name),ref,start_ix,num_val,k); } void ParmParse::getarr (const char* name, std::vector& ref, int start_ix, int num_val) const { - sgetarr(m_table, prefixedName(name),ref,start_ix,num_val, LAST); + sgetarr(*m_table, prefixedName(name),ref,start_ix,num_val, LAST); } int ParmParse::queryktharr (const char* name, int k, std::vector& ref, int start_ix, int num_val) const { - return squeryarr(m_table, prefixedName(name),ref,start_ix,num_val,k); + return squeryarr(*m_table, prefixedName(name),ref,start_ix,num_val,k); } int ParmParse::queryarr (const char* name, std::vector& ref, int start_ix, int num_val) const { - return squeryarr(m_table, prefixedName(name),ref,start_ix,num_val, LAST); + return squeryarr(*m_table, prefixedName(name),ref,start_ix,num_val, LAST); } void @@ -1622,25 +1622,25 @@ ParmParse::addarr (const char* name, const std::vector& ref) void ParmParse::getkth (const char* name, int k, float& ref, int ival) const { - sgetval(m_table, prefixedName(name),ref,ival,k); + sgetval(*m_table, prefixedName(name),ref,ival,k); } void ParmParse::get (const char* name, float& ref, int ival) const { - sgetval(m_table, prefixedName(name),ref,ival, LAST); + sgetval(*m_table, prefixedName(name),ref,ival, LAST); } int ParmParse::querykth (const char* name, int k, float& ref, int ival) const { - return squeryval(m_table, prefixedName(name),ref,ival,k); + return squeryval(*m_table, prefixedName(name),ref,ival,k); } int ParmParse::query (const char* name, float& ref, int ival) const { - return squeryval(m_table, prefixedName(name),ref,ival, LAST); + return squeryval(*m_table, prefixedName(name),ref,ival, LAST); } void @@ -1653,28 +1653,28 @@ void ParmParse::getktharr (const char* name, int k, std::vector& ref, int start_ix, int num_val) const { - sgetarr(m_table, prefixedName(name),ref,start_ix,num_val,k); + sgetarr(*m_table, prefixedName(name),ref,start_ix,num_val,k); } void ParmParse::getarr (const char* name, std::vector& ref, int start_ix, int num_val) const { - sgetarr(m_table, prefixedName(name),ref,start_ix,num_val, LAST); + sgetarr(*m_table, prefixedName(name),ref,start_ix,num_val, LAST); } int ParmParse::queryktharr (const char* name, int k, std::vector& ref, int start_ix, int num_val) const { - return squeryarr(m_table, prefixedName(name),ref,start_ix, num_val,k); + return squeryarr(*m_table, prefixedName(name),ref,start_ix, num_val,k); } int ParmParse::queryarr (const char* name, std::vector& ref, int start_ix, int num_val) const { - return squeryarr(m_table, prefixedName(name),ref,start_ix,num_val, LAST); + return squeryarr(*m_table, prefixedName(name),ref,start_ix,num_val, LAST); } void @@ -1689,25 +1689,25 @@ ParmParse::addarr (const char* name, const std::vector& ref) void ParmParse::getkth (const char* name, int k, double& ref, int ival) const { - sgetval(m_table, prefixedName(name),ref,ival,k); + sgetval(*m_table, prefixedName(name),ref,ival,k); } void ParmParse::get (const char* name, double& ref, int ival) const { - sgetval(m_table, prefixedName(name),ref,ival, LAST); + sgetval(*m_table, prefixedName(name),ref,ival, LAST); } int ParmParse::querykth (const char* name, int k, double& ref, int ival) const { - return squeryval(m_table, prefixedName(name),ref,ival,k); + return squeryval(*m_table, prefixedName(name),ref,ival,k); } int ParmParse::query (const char* name, double& ref, int ival) const { - return squeryval(m_table, prefixedName(name),ref,ival, LAST); + return squeryval(*m_table, prefixedName(name),ref,ival, LAST); } void @@ -1720,28 +1720,28 @@ void ParmParse::getktharr (const char* name, int k, std::vector& ref, int start_ix, int num_val) const { - sgetarr(m_table, prefixedName(name),ref,start_ix,num_val,k); + sgetarr(*m_table, prefixedName(name),ref,start_ix,num_val,k); } void ParmParse::getarr (const char* name, std::vector& ref, int start_ix, int num_val) const { - sgetarr(m_table, prefixedName(name),ref,start_ix,num_val, LAST); + sgetarr(*m_table, prefixedName(name),ref,start_ix,num_val, LAST); } int ParmParse::queryktharr (const char* name, int k, std::vector& ref, int start_ix, int num_val) const { - return squeryarr(m_table, prefixedName(name),ref,start_ix, num_val,k); + return squeryarr(*m_table, prefixedName(name),ref,start_ix, num_val,k); } int ParmParse::queryarr (const char* name, std::vector& ref, int start_ix, int num_val) const { - return squeryarr(m_table, prefixedName(name),ref,start_ix,num_val, LAST); + return squeryarr(*m_table, prefixedName(name),ref,start_ix,num_val, LAST); } void @@ -1756,25 +1756,25 @@ ParmParse::addarr (const char* name, const std::vector& ref) void ParmParse::getkth (const char* name, int k, std::string& ref, int ival) const { - sgetval(m_table, prefixedName(name),ref,ival,k); + sgetval(*m_table, prefixedName(name),ref,ival,k); } void ParmParse::get (const char* name, std::string& ref, int ival) const { - sgetval(m_table, prefixedName(name),ref,ival, LAST); + sgetval(*m_table, prefixedName(name),ref,ival, LAST); } int ParmParse::querykth (const char* name, int k, std::string& ref, int ival) const { - return squeryval(m_table, prefixedName(name),ref,ival,k); + return squeryval(*m_table, prefixedName(name),ref,ival,k); } int ParmParse::query (const char* name, std::string& ref, int ival) const { - return squeryval(m_table, prefixedName(name),ref,ival, LAST); + return squeryval(*m_table, prefixedName(name),ref,ival, LAST); } void @@ -1787,28 +1787,28 @@ void ParmParse::getktharr (const char* name, int k, std::vector& ref, int start_ix, int num_val) const { - sgetarr(m_table, prefixedName(name),ref,start_ix,num_val,k); + sgetarr(*m_table, prefixedName(name),ref,start_ix,num_val,k); } void ParmParse::getarr (const char* name, std::vector& ref, int start_ix, int num_val) const { - sgetarr(m_table, prefixedName(name),ref,start_ix,num_val, LAST); + sgetarr(*m_table, prefixedName(name),ref,start_ix,num_val, LAST); } int ParmParse::queryktharr (const char* name, int k, std::vector& ref, int start_ix, int num_val) const { - return squeryarr(m_table, prefixedName(name),ref,start_ix, num_val,k); + return squeryarr(*m_table, prefixedName(name),ref,start_ix, num_val,k); } int ParmParse::queryarr (const char* name, std::vector& ref, int start_ix, int num_val) const { - return squeryarr(m_table, prefixedName(name),ref,start_ix,num_val, LAST); + return squeryarr(*m_table, prefixedName(name),ref,start_ix,num_val, LAST); } void @@ -1823,25 +1823,25 @@ ParmParse::addarr (const char* name, const std::vector& ref) void ParmParse::getkth (const char* name, int k, IntVect& ref, int ival) const { - sgetval(m_table, prefixedName(name),ref,ival,k); + sgetval(*m_table, prefixedName(name),ref,ival,k); } void ParmParse::get (const char* name, IntVect& ref, int ival) const { - sgetval(m_table, prefixedName(name),ref,ival, LAST); + sgetval(*m_table, prefixedName(name),ref,ival, LAST); } int ParmParse::querykth (const char* name, int k, IntVect& ref, int ival) const { - return squeryval(m_table, prefixedName(name),ref,ival,k); + return squeryval(*m_table, prefixedName(name),ref,ival,k); } int ParmParse::query (const char* name, IntVect& ref, int ival) const { - return squeryval(m_table, prefixedName(name),ref,ival, LAST); + return squeryval(*m_table, prefixedName(name),ref,ival, LAST); } void @@ -1854,28 +1854,28 @@ void ParmParse::getktharr (const char* name, int k, std::vector& ref, int start_ix, int num_val) const { - sgetarr(m_table, prefixedName(name),ref,start_ix,num_val,k); + sgetarr(*m_table, prefixedName(name),ref,start_ix,num_val,k); } void ParmParse::getarr (const char* name, std::vector& ref, int start_ix, int num_val) const { - sgetarr(m_table, prefixedName(name),ref,start_ix,num_val, LAST); + sgetarr(*m_table, prefixedName(name),ref,start_ix,num_val, LAST); } int ParmParse::queryktharr (const char* name, int k, std::vector& ref, int start_ix, int num_val) const { - return squeryarr(m_table, prefixedName(name),ref,start_ix, num_val,k); + return squeryarr(*m_table, prefixedName(name),ref,start_ix, num_val,k); } int ParmParse::queryarr (const char* name, std::vector& ref, int start_ix, int num_val) const { - return squeryarr(m_table, prefixedName(name),ref,start_ix,num_val, LAST); + return squeryarr(*m_table, prefixedName(name),ref,start_ix,num_val, LAST); } void @@ -1888,25 +1888,25 @@ ParmParse::addarr (const char* name, const std::vector& ref) void ParmParse::getkth (const char* name, int k, Box& ref, int ival) const { - sgetval(m_table, prefixedName(name),ref,ival,k); + sgetval(*m_table, prefixedName(name),ref,ival,k); } void ParmParse::get (const char* name, Box& ref, int ival) const { - sgetval(m_table, prefixedName(name),ref,ival, LAST); + sgetval(*m_table, prefixedName(name),ref,ival, LAST); } int ParmParse::querykth (const char* name, int k, Box& ref, int ival) const { - return squeryval(m_table, prefixedName(name),ref,ival,k); + return squeryval(*m_table, prefixedName(name),ref,ival,k); } int ParmParse::query (const char* name, Box& ref, int ival) const { - return squeryval(m_table, prefixedName(name),ref,ival, LAST); + return squeryval(*m_table, prefixedName(name),ref,ival, LAST); } void @@ -1919,28 +1919,28 @@ void ParmParse::getktharr (const char* name, int k, std::vector& ref, int start_ix, int num_val) const { - sgetarr(m_table, prefixedName(name),ref,start_ix,num_val,k); + sgetarr(*m_table, prefixedName(name),ref,start_ix,num_val,k); } void ParmParse::getarr (const char* name, std::vector& ref, int start_ix, int num_val) const { - sgetarr(m_table, prefixedName(name),ref,start_ix,num_val, LAST); + sgetarr(*m_table, prefixedName(name),ref,start_ix,num_val, LAST); } int ParmParse::queryktharr (const char* name, int k, std::vector& ref, int start_ix, int num_val) const { - return squeryarr(m_table, prefixedName(name),ref,start_ix, num_val,k); + return squeryarr(*m_table, prefixedName(name),ref,start_ix, num_val,k); } int ParmParse::queryarr (const char* name, std::vector& ref, int start_ix, int num_val) const { - return squeryarr(m_table, prefixedName(name),ref,start_ix,num_val, LAST); + return squeryarr(*m_table, prefixedName(name),ref,start_ix,num_val, LAST); } void @@ -1958,7 +1958,7 @@ int ParmParse::countname (const std::string& name) const { int cnt = 0; - for (auto const& li : m_table) + for (auto const& li : *m_table) { if ( ppfound(prefixedName(name), li, false) ) { @@ -1972,7 +1972,7 @@ int ParmParse::countRecords (const std::string& name) const { int cnt = 0; - for (auto const& li : m_table) + for (auto const& li : *m_table) { if ( ppfound(prefixedName(name), li, true) ) { @@ -1989,14 +1989,14 @@ ParmParse::countRecords (const std::string& name) const bool ParmParse::contains (const char* name) const { - for (auto const& li : m_table) + for (auto const& li : *m_table) { if ( ppfound(prefixedName(name), li, false)) { // // Found an entry; mark all occurrences of name as used. // - for (auto& lli : m_table) + for (auto& lli : *m_table) { if ( ppfound(prefixedName(name), lli, false) ) { @@ -2013,9 +2013,9 @@ int ParmParse::remove (const char* name) { int r = 0; - for (auto it = m_table.begin(); it != m_table.end(); ) { + for (auto it = m_table->begin(); it != m_table->end(); ) { if (ppfound(prefixedName(name), *it, false)) { - it = m_table.erase(it); + it = m_table->erase(it); ++r; } else { ++it; @@ -2027,7 +2027,7 @@ ParmParse::remove (const char* name) ParmParse::Record ParmParse::getRecord (const std::string& name, int n) const { - const PP_entry* pe = ppindex(m_table, n, prefixedName(name), true); + const PP_entry* pe = ppindex(*m_table, n, prefixedName(name), true); if ( pe == nullptr ) { amrex::ErrorStream() << "ParmParse::getRecord: record " << name << " not found" << std::endl; diff --git a/Src/Base/AMReX_Utility.H b/Src/Base/AMReX_Utility.H index 70a2a93f37d..10a29de440a 100644 --- a/Src/Base/AMReX_Utility.H +++ b/Src/Base/AMReX_Utility.H @@ -191,7 +191,7 @@ namespace amrex int tries, maxTries; bool abortOnRetryFailure = true; std::string fileName; - std::ostream &sros; + std::ostream *sros; std::ostream::pos_type spos; std::string suffix; diff --git a/Src/Base/AMReX_Utility.cpp b/Src/Base/AMReX_Utility.cpp index 16f2f20b554..476e7c32a00 100644 --- a/Src/Base/AMReX_Utility.cpp +++ b/Src/Base/AMReX_Utility.cpp @@ -603,7 +603,7 @@ int amrex::StreamRetry::nStreamErrors = 0; amrex::StreamRetry::StreamRetry(std::ostream &a_os, std::string a_suffix, int a_maxtries) - : tries(0), maxTries(a_maxtries), sros(a_os), spos(a_os.tellp()), suffix(std::move(a_suffix)) + : tries(0), maxTries(a_maxtries), sros(&a_os), spos(a_os.tellp()), suffix(std::move(a_suffix)) { } @@ -612,7 +612,7 @@ amrex::StreamRetry::StreamRetry (std::string filename, bool abortonretryfailure, : tries(0), maxTries(maxtries), abortOnRetryFailure(abortonretryfailure), fileName(std::move(filename)), - sros(amrex::ErrorStream()) // unused here, just to make the compiler happy + sros(&amrex::ErrorStream()) // unused here, just to make the compiler happy { nStreamErrors = 0; } @@ -623,41 +623,41 @@ bool amrex::StreamRetry::TryOutput() ++tries; return true; } else { - if(sros.fail()) { + if(sros->fail()) { ++nStreamErrors; int myProc(ParallelDescriptor::MyProc()); if(tries <= maxTries) { if (amrex::Verbose() > 1) { amrex::AllPrint() << "PROC: " << myProc << " :: STREAMRETRY_" << suffix << " # " << tries << " :: gbfe: " - << sros.good() << sros.bad() << sros.fail() << sros.eof() + << sros->good() << sros->bad() << sros->fail() << sros->eof() << " :: sec = " << ParallelDescriptor::second() - << " :: os.tellp() = " << sros.tellp() + << " :: os.tellp() = " << sros->tellp() << " :: rewind spos = " << spos << std::endl; } - sros.clear(); // clear the bad bits + sros->clear(); // clear the bad bits if (amrex::Verbose() > 1) { - amrex::AllPrint() << "After os.clear() : gbfe: " << sros.good() << sros.bad() - << sros.fail() << sros.eof() << std::endl; + amrex::AllPrint() << "After os.clear() : gbfe: " << sros->good() << sros->bad() + << sros->fail() << sros->eof() << std::endl; } - sros.seekp(spos, std::ios::beg); // reset stream position + sros->seekp(spos, std::ios::beg); // reset stream position ++tries; return true; } else { if (amrex::Verbose() > 1) { amrex::AllPrint() << "PROC: " << myProc << " :: STREAMFAILED_" << suffix << " # " << tries << " :: File may be corrupt. :: gbfe: " - << sros.good() << sros.bad() << sros.fail() << sros.eof() + << sros->good() << sros->bad() << sros->fail() << sros->eof() << " :: sec = " << ParallelDescriptor::second() - << " :: os.tellp() = " << sros.tellp() + << " :: os.tellp() = " << sros->tellp() << " :: rewind spos = " << spos << std::endl; } - sros.clear(); // clear the bad bits + sros->clear(); // clear the bad bits if (amrex::Verbose() > 1) { - amrex::AllPrint() << "After os.clear() : gbfe: " << sros.good() << sros.bad() - << sros.fail() << sros.eof() << std::endl; + amrex::AllPrint() << "After os.clear() : gbfe: " << sros->good() << sros->bad() + << sros->fail() << sros->eof() << std::endl; } return false; } diff --git a/Src/EB/AMReX_EB_chkpt_file.H b/Src/EB/AMReX_EB_chkpt_file.H index bb51c79a127..958f401041e 100644 --- a/Src/EB/AMReX_EB_chkpt_file.H +++ b/Src/EB/AMReX_EB_chkpt_file.H @@ -10,18 +10,18 @@ class ChkptFile private: std::string m_restart_file; - const std::string m_volfrac_name = "volfrac"; - const std::string m_centroid_name = "centroid"; - const std::string m_bndryarea_name = "bndryarea"; - const std::string m_bndrycent_name = "bndrycent"; - const std::string m_bndrynorm_name = "bndrynorm"; - const std::string m_levelset_name = "levelset"; - - const amrex::Vector m_areafrac_name + std::string m_volfrac_name = "volfrac"; + std::string m_centroid_name = "centroid"; + std::string m_bndryarea_name = "bndryarea"; + std::string m_bndrycent_name = "bndrycent"; + std::string m_bndrynorm_name = "bndrynorm"; + std::string m_levelset_name = "levelset"; + + amrex::Vector m_areafrac_name = {AMREX_D_DECL("areafrac_x", "areafrac_y", "areafrac_z")}; - const amrex::Vector m_facecent_name + amrex::Vector m_facecent_name = {AMREX_D_DECL("facecent_x", "facecent_y", "facecent_z")}; - const amrex::Vector m_edgecent_name + amrex::Vector m_edgecent_name = {AMREX_D_DECL("edgecent_x", "edgecent_y", "edgecent_z")}; void writeHeader (const BoxArray& cut_ba, const BoxArray& covered_ba, const Geometry& geom, diff --git a/Src/EB/AMReX_algoim_K.H b/Src/EB/AMReX_algoim_K.H index 09b7f1bd715..8e99c5c431a 100644 --- a/Src/EB/AMReX_algoim_K.H +++ b/Src/EB/AMReX_algoim_K.H @@ -253,12 +253,12 @@ struct Interval template struct ImplicitIntegral { - const Phi& phi; - F& f; - const GpuArray free; + const Phi* phi; + F* f; + GpuArray free; GpuArray,1 << (N - 1)> psi; int psiCount; - const BoundingBox xrange; + BoundingBox xrange; int e0 = -1; GpuArray xint; static constexpr int p = 4; @@ -281,13 +281,13 @@ struct ImplicitIntegral Real dphi_max = 0.0_rt; for (int dim = 0; dim < N; ++dim) { if (free[dim]) { - dphi_max += std::abs(phi.grad(dim)); + dphi_max += std::abs(phi->grad(dim)); } else { mid[dim] = xrange(psi[i].side(dim),dim); } } dphi_max *= 0.5*almostone; - const Real phi_0 = phi(mid); + const Real phi_0 = (*phi)(mid); bool uniform_sign = (phi_0 > dphi_max) || (phi_0 < -dphi_max); if (uniform_sign) { @@ -338,7 +338,7 @@ struct ImplicitIntegral ++k; } } - f.evalIntegrand(x, w); + f->evalIntegrand(x, w); for (int m = M-1; m >= 0; --m) { ++(i[m]); @@ -385,8 +385,8 @@ struct ImplicitIntegral int nroots = 0; x[e0] = x_min; - Real phi_lo = phi(x); - Real xroot = x[e0] - phi_lo / phi.grad(e0); + Real phi_lo = (*phi)(x); + Real xroot = x[e0] - phi_lo / phi->grad(e0); if (xroot > x_min && xroot < x_max) { roots[nroots++] = xroot; } @@ -398,10 +398,10 @@ struct ImplicitIntegral x[e0] = roots[i]; Real mag = 0._rt; for (int dim = 0; dim < N; ++dim) { - mag += phi.grad(dim)*phi.grad(dim); + mag += phi->grad(dim)*phi->grad(dim); } mag = std::sqrt(mag); - f.evalIntegrand(x, (mag/std::abs(phi.grad(e0)))*w); + f->evalIntegrand(x, (mag/std::abs(phi->grad(e0)))*w); } return; @@ -412,7 +412,7 @@ struct ImplicitIntegral Real x_max = xrange.max(e0); roots[0] = x_min; int nroots = 1; - if (phi.grad(e0) != Real(0.0)) { + if (phi->grad(e0) != Real(0.0)) { for (int i = 0; i < psiCount; ++i) { for (int dim = 0; dim < N; ++dim) { @@ -422,8 +422,8 @@ struct ImplicitIntegral } // x is now valid in all variables except e0 x[e0] = x_min; - Real phi_lo = phi(x); - Real xroot = x[e0] - phi_lo / phi.grad(e0); + Real phi_lo = (*phi)(x); + Real xroot = x[e0] - phi_lo / phi->grad(e0); if (xroot > x_min && xroot < x_max) { roots[nroots++] = xroot; } @@ -454,7 +454,7 @@ struct ImplicitIntegral x[dim] = xrange(psi[j].side(dim), dim); } } - bool new_ok = (phi(x) > 0.0) ? (psi[j].sign() >= 0) : (psi[j].sign() <= 0); + bool new_ok = ((*phi)(x) > 0.0) ? (psi[j].sign() >= 0) : (psi[j].sign() <= 0); okay = okay && new_ok; } if (!okay) { continue; } @@ -463,7 +463,7 @@ struct ImplicitIntegral { x[e0] = roots[i] + (roots[i+1] - roots[i]) * gauss_x[j]; Real gw = (roots[i+1] - roots[i]) * gauss_w[j]; - f.evalIntegrand(x, w * gw); + f->evalIntegrand(x, w * gw); } } } @@ -475,7 +475,7 @@ struct ImplicitIntegral ImplicitIntegral (const Phi& phi_, F& f_, const GpuArray& free_, const GpuArray,1 << (N-1)>& psi_, int psiCount_) noexcept - : phi(phi_), f(f_), free(free_), psi(psi_), psiCount(psiCount_), + : phi(&phi_), f(&f_), free(free_), psi(psi_), psiCount(psiCount_), xrange() { // For the one-dimensional base case, evaluate the @@ -495,7 +495,7 @@ struct ImplicitIntegral ImplicitIntegral (const Phi& phi_, F& f_, const GpuArray& free_, const GpuArray,1 << (N-1)>& psi_, int psiCount_) noexcept - : phi(phi_), f(f_), free(free_), psi(psi_), psiCount(psiCount_), + : phi(&phi_), f(&f_), free(free_), psi(psi_), psiCount(psiCount_), xrange() { // Establish interval bounds for prune() and remaining part of ctor. @@ -538,8 +538,8 @@ struct ImplicitIntegral { Real gmax = -1.; for (int dim = 0; dim < N; ++dim) { - if (free[dim] && std::abs(phi.grad(dim)) > gmax) { - gmax = std::abs(phi.grad(dim)); + if (free[dim] && std::abs(phi->grad(dim)) > gmax) { + gmax = std::abs(phi->grad(dim)); e0 = dim; } } @@ -560,7 +560,7 @@ struct ImplicitIntegral // w.z. We assume grad does not change. int bottomSign, topSign; - detail::determineSigns(phi.grad(e0) > 0.0, psi[i].sign(), + detail::determineSigns(phi->grad(e0) > 0.0, psi[i].sign(), bottomSign, topSign); // w.z. There are sides 0 and 1. newPsi[newPsiCount++] = PsiCode(psi[i], e0, 0, bottomSign); @@ -571,7 +571,7 @@ struct ImplicitIntegral GpuArray new_free = free; new_free[e0] = false; ImplicitIntegral,false> - (phi, *this, new_free, newPsi, newPsiCount); + (*phi, *this, new_free, newPsi, newPsiCount); } }; diff --git a/Src/Particle/AMReX_BinIterator.H b/Src/Particle/AMReX_BinIterator.H index 00f378e9508..e6898de5c27 100644 --- a/Src/Particle/AMReX_BinIterator.H +++ b/Src/Particle/AMReX_BinIterator.H @@ -85,7 +85,7 @@ struct BinIterator {} private: - const index_type m_i; + index_type m_i; const index_type * m_offsets_ptr; const index_type * m_permutation_ptr; const_pointer_type m_items; diff --git a/Src/Particle/AMReX_ParIter.H b/Src/Particle/AMReX_ParIter.H index a5208305d73..84ca403eff7 100644 --- a/Src/Particle/AMReX_ParIter.H +++ b/Src/Particle/AMReX_ParIter.H @@ -34,15 +34,16 @@ class ParIterBase_impl private: using PCType = ParticleContainer_impl; - using ContainerRef = typename std::conditional::type; - using ParticleTileRef = typename std::conditional - ::type; - using ParticleTilePtr = typename std::conditional - ::type; - using AoSRef = typename std::conditional - ::type; - using SoARef = typename std::conditional - ::type; + using ContainerRef = std::conditional_t; + using ContainerPtr = std::conditional_t; + using ParticleTileRef = std::conditional_t + ; + using ParticleTilePtr = std::conditional_t + ; + using AoSRef = std::conditional_t + ; + using SoARef = std::conditional_t + ; public: @@ -99,7 +100,7 @@ public: [[nodiscard]] std::pair GetPairIndex () const { return std::make_pair(this->index(), this->LocalTileIndex()); } - [[nodiscard]] const Geometry& Geom (int lev) const { return m_pc.Geom(lev); } + [[nodiscard]] const Geometry& Geom (int lev) const { return m_pc->Geom(lev); } protected: @@ -107,7 +108,7 @@ protected: int m_pariter_index; Vector m_valid_index; Vector m_particle_tiles; - ContainerRef m_pc; + ContainerPtr m_pc; }; template = 0; @@ -85,8 +85,8 @@ struct ParticleIDWrapper val = -id; } - m_idata |= (sign << 63); // put the sign in the leftmost bit - m_idata |= (val << 24); // put the val in the next 39 + (*m_idata) |= (sign << 63); // put the sign in the leftmost bit + (*m_idata) |= (val << 24); // put the val in the next 39 return *this; } @@ -95,8 +95,8 @@ struct ParticleIDWrapper { Long r = 0; - uint64_t sign = m_idata >> 63; // extract leftmost sign bit - uint64_t val = ((m_idata >> 24) & 0x7FFFFFFFFF); // extract next 39 id bits + uint64_t sign = (*m_idata) >> 63; // extract leftmost sign bit + uint64_t val = (((*m_idata) >> 24) & 0x7FFFFFFFFF); // extract next 39 id bits Long lval = static_cast(val); // bc we take - r = (sign) ? lval : -lval; @@ -109,10 +109,10 @@ struct ParticleIDWrapper * This is NOT identical to id = -id, but it is equally reversible via make_valid(). */ AMREX_GPU_HOST_DEVICE AMREX_FORCE_INLINE - void make_invalid () noexcept + void make_invalid () const noexcept { // RHS mask: 0111... - m_idata &= ~(uint64_t(1) << 63); + (*m_idata) &= ~(uint64_t(1) << 63); } /** Mark the particle as valid @@ -121,10 +121,10 @@ struct ParticleIDWrapper * This is NOT identical to id = -id, but it is equally reversible via make_invalid(). */ AMREX_GPU_HOST_DEVICE AMREX_FORCE_INLINE - void make_valid () noexcept + void make_valid () const noexcept { // RHS mask: 1000... - m_idata |= uint64_t(1) << 63; + (*m_idata) |= uint64_t(1) << 63; } /** Check the particle is valid, via the sign of the id. @@ -135,19 +135,19 @@ struct ParticleIDWrapper bool is_valid () const noexcept { // the leftmost bit is our id's valid sign - return m_idata >> 63; + return (*m_idata) >> 63; } }; struct ParticleCPUWrapper { - uint64_t& m_idata; + uint64_t* m_idata; ~ParticleCPUWrapper () noexcept = default; AMREX_GPU_HOST_DEVICE AMREX_FORCE_INLINE ParticleCPUWrapper (uint64_t& idata) noexcept - : m_idata(idata) + : m_idata(&idata) {} AMREX_GPU_HOST_DEVICE AMREX_FORCE_INLINE @@ -171,29 +171,29 @@ struct ParticleCPUWrapper ParticleCPUWrapper& operator= (const int cpu) noexcept { // zero out the first 24 bits, which are used to store the cpu number - m_idata &= (~ 0x00FFFFFF); + (*m_idata) &= (~ 0x00FFFFFF); AMREX_ASSERT(cpu >= 0); AMREX_ASSERT(cpu <= 16777215); // 2**24-1, the max representable number - m_idata |= cpu; + (*m_idata) |= cpu; return *this; } AMREX_GPU_HOST_DEVICE AMREX_FORCE_INLINE operator int () const noexcept { - return static_cast(m_idata & 0x00FFFFFF); + return static_cast((*m_idata) & 0x00FFFFFF); } }; struct ConstParticleIDWrapper { - const uint64_t& m_idata; + const uint64_t* m_idata; AMREX_GPU_HOST_DEVICE AMREX_FORCE_INLINE ConstParticleIDWrapper (const uint64_t& idata) noexcept - : m_idata(idata) + : m_idata(&idata) {} AMREX_GPU_HOST_DEVICE AMREX_FORCE_INLINE @@ -201,8 +201,8 @@ struct ConstParticleIDWrapper { Long r = 0; - uint64_t sign = m_idata >> 63; // extract leftmost sign bit - uint64_t val = ((m_idata >> 24) & 0x7FFFFFFFFF); // extract next 39 id bits + uint64_t sign = (*m_idata) >> 63; // extract leftmost sign bit + uint64_t val = (((*m_idata) >> 24) & 0x7FFFFFFFFF); // extract next 39 id bits Long lval = static_cast(val); // bc we take - r = (sign) ? lval : -lval; @@ -217,21 +217,21 @@ struct ConstParticleIDWrapper bool is_valid () const noexcept { // the leftmost bit is our id's valid sign - return m_idata >> 63; + return (*m_idata) >> 63; } }; struct ConstParticleCPUWrapper { - const uint64_t& m_idata; + const uint64_t* m_idata; AMREX_GPU_HOST_DEVICE AMREX_FORCE_INLINE ConstParticleCPUWrapper (const uint64_t& idata) noexcept - : m_idata(idata) + : m_idata(&idata) {} AMREX_GPU_HOST_DEVICE AMREX_FORCE_INLINE - operator int () const noexcept { return static_cast(m_idata & 0x00FFFFFF); } + operator int () const noexcept { return static_cast((*m_idata) & 0x00FFFFFF); } }; /** Set the idcpu value at once, based on a particle id and cpuid