Skip to content

Commit

Permalink
Clang-Tidy 17: cppcoreguidelines-avoid-const-or-ref-data-members
Browse files Browse the repository at this point in the history
  • Loading branch information
WeiqunZhang committed Mar 18, 2024
1 parent a5720c9 commit c1b7618
Show file tree
Hide file tree
Showing 16 changed files with 265 additions and 264 deletions.
8 changes: 4 additions & 4 deletions Src/Amr/AMReX_AmrLevel.H
Original file line number Diff line number Diff line change
Expand Up @@ -553,8 +553,8 @@ private:
//
// The data.
//
AmrLevel& m_amrlevel;
MultiFab& m_leveldata;
AmrLevel* m_amrlevel;
MultiFab* m_leveldata;
std::vector< std::pair<int,int> > m_range;
MultiFab m_fabs;
int m_ncomp;
Expand Down Expand Up @@ -591,8 +591,8 @@ private:
//
// The data.
//
AmrLevel& m_amrlevel;
MultiFab& m_leveldata;
AmrLevel* m_amrlevel;
MultiFab* m_leveldata;
MultiFabCopyDescriptor m_mfcd;
Vector< Vector<MultiFabId> > m_mfid; // [level][oldnew]
Interpolater* m_map = nullptr;
Expand Down
100 changes: 50 additions & 50 deletions Src/Amr/AMReX_AmrLevel.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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),
Expand All @@ -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);
Expand Down Expand Up @@ -756,24 +756,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<int>(m_leveldata.boxArray().size()); i < N; ++i)
for (int i = 0, N = static_cast<int>(m_leveldata->boxArray().size()); i < N; ++i)
{
//
// A couple typedefs we'll use in the next code segment.
Expand All @@ -782,20 +782,20 @@ FillPatchIteratorHelper::Initialize (int boxGrow,

using IntAAAFBIDMapValType = std::map<int,Vector<Vector<Vector<FillBoxId> > > >::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<Vector<Vector<FillBoxId> > >());

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<Vector<Box> >());

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<int,Box>::value_type(i,amrex::grow(m_leveldata.boxArray()[i],m_growsize)));
m_ba.insert(m_ba.end(),std::map<int,Box>::value_type(i,amrex::grow(m_leveldata->boxArray()[i],m_growsize)));
}

BoxList tempUnfillable(boxType);
Expand Down Expand Up @@ -862,7 +862,7 @@ FillPatchIteratorHelper::Initialize (int boxGrow,
Vector< Vector<Box> >& TheFineBoxes = m_fbox[bxidx];
Vector< Vector< Vector<FillBoxId> > >& 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();

Expand Down Expand Up @@ -892,7 +892,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);

Expand Down Expand Up @@ -999,15 +999,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<Real>::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<int>(m_range.size()); i++)
{
Expand All @@ -1021,8 +1021,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);
Expand All @@ -1034,7 +1034,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],
Expand All @@ -1049,7 +1049,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)}) {
Expand All @@ -1060,8 +1060,8 @@ FillPatchIterator::Initialize (int boxGrow,
}
}

auto* fph = new FillPatchIteratorHelper(m_amrlevel,
m_leveldata,
auto* fph = new FillPatchIteratorHelper(*m_amrlevel,
*m_leveldata,
boxGrow,
time,
idx,
Expand All @@ -1086,7 +1086,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,
Expand All @@ -1098,15 +1098,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<MultiFab*> smf;
Vector<Real> stime;
statedata.getData(smf,stime,time);

const Geometry& geom = m_amrlevel.geom;
const Geometry& geom = m_amrlevel->geom;

StateDataPhysBCFunct physbcf(statedata,scomp,geom);

Expand All @@ -1117,13 +1117,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;
Expand Down Expand Up @@ -1268,17 +1268,17 @@ FillPatchIteratorHelper::fill (FArrayBox& fab,
BL_ASSERT(fab.box() == m_ba[idx]);
BL_ASSERT(fab.nComp() >= dcomp + m_ncomp);

Vector< Vector<std::unique_ptr<FArrayBox> > > cfab(m_amrlevel.level+1);
Vector< Vector<std::unique_ptr<FArrayBox> > > cfab(m_amrlevel->level+1);
Vector< Vector<Box> >& TheCrseBoxes = m_cbox[idx];
Vector< Vector<Box> >& TheFineBoxes = m_fbox[idx];
Vector< Vector< Vector<FillBoxId> > >& 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<Box>& CrseBoxes = TheCrseBoxes[l];
Expand Down Expand Up @@ -1323,7 +1323,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];
Expand Down Expand Up @@ -1452,10 +1452,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.
//
Expand Down Expand Up @@ -1495,7 +1495,7 @@ FillPatchIteratorHelper::fill (FArrayBox& fab,
//
if (! FineState.getDomain().contains(fab.box()))
{
m_amrlevel.setPhysBoundaryValues(fab,
m_amrlevel->setPhysBoundaryValues(fab,
m_index,
m_time,
dcomp,
Expand All @@ -1506,7 +1506,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
}
}
Expand Down
2 changes: 1 addition & 1 deletion Src/Amr/AMReX_StateData.H
Original file line number Diff line number Diff line change
Expand Up @@ -470,7 +470,7 @@ public:
private:
StateData* statedata;
int src_comp;
const Geometry& geom;
const Geometry* geom;

};

Expand Down
Loading

0 comments on commit c1b7618

Please sign in to comment.