Skip to content

Commit

Permalink
Clang-Tidy changes in Src/Amr (#3467)
Browse files Browse the repository at this point in the history
  • Loading branch information
WeiqunZhang authored Aug 3, 2023
1 parent 3af462c commit bee6554
Show file tree
Hide file tree
Showing 10 changed files with 199 additions and 132 deletions.
182 changes: 112 additions & 70 deletions Src/Amr/AMReX_Amr.cpp

Large diffs are not rendered by default.

80 changes: 48 additions & 32 deletions Src/Amr/AMReX_AmrLevel.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,7 @@ AmrLevel::AmrLevel (Amr& papa,
*m_factory);
}

if (parent->useFixedCoarseGrids()) constructAreaNotToTag();
if (parent->useFixedCoarseGrids()) { constructAreaNotToTag(); }

post_step_regrid = 0;

Expand Down Expand Up @@ -186,8 +186,9 @@ AmrLevel::writePlotFile (const std::string& dir,
//
os << thePlotFileType() << '\n';

if (n_data_items == 0)
if (n_data_items == 0) {
amrex::Error("Must specify at least one valid data item to plot");
}

os << n_data_items << '\n';

Expand Down Expand Up @@ -219,25 +220,31 @@ AmrLevel::writePlotFile (const std::string& dir,
os << parent->cumTime() << '\n';
int f_lev = parent->finestLevel();
os << f_lev << '\n';
for (i = 0; i < AMREX_SPACEDIM; i++)
for (i = 0; i < AMREX_SPACEDIM; i++) {
os << Geom().ProbLo(i) << ' ';
}
os << '\n';
for (i = 0; i < AMREX_SPACEDIM; i++)
for (i = 0; i < AMREX_SPACEDIM; i++) {
os << Geom().ProbHi(i) << ' ';
}
os << '\n';
for (i = 0; i < f_lev; i++)
for (i = 0; i < f_lev; i++) {
os << parent->refRatio(i)[0] << ' ';
}
os << '\n';
for (i = 0; i <= f_lev; i++)
for (i = 0; i <= f_lev; i++) {
os << parent->Geom(i).Domain() << ' ';
}
os << '\n';
for (i = 0; i <= f_lev; i++)
for (i = 0; i <= f_lev; i++) {
os << parent->levelSteps(i) << ' ';
}
os << '\n';
for (i = 0; i <= f_lev; i++)
{
for (int k = 0; k < AMREX_SPACEDIM; k++)
for (int k = 0; k < AMREX_SPACEDIM; k++) {
os << parent->Geom(i).CellSize()[k] << ' ';
}
os << '\n';
}
os << (int) Geom().Coord() << '\n';
Expand Down Expand Up @@ -281,8 +288,9 @@ AmrLevel::writePlotFile (const std::string& dir,
for (i = 0; i < grids.size(); ++i)
{
RealBox gridloc = RealBox(grids[i],geom.CellSize(),geom.ProbLo());
for (n = 0; n < AMREX_SPACEDIM; n++)
for (n = 0; n < AMREX_SPACEDIM; n++) {
os << gridloc.lo(n) << ' ' << gridloc.hi(n) << '\n';
}
}
//
// The full relative pathname of the MultiFabs at this level.
Expand Down Expand Up @@ -447,7 +455,7 @@ AmrLevel::restart (Amr& papa,

m_fillpatcher.resize(ndesc);

if (parent->useFixedCoarseGrids()) constructAreaNotToTag();
if (parent->useFixedCoarseGrids()) { constructAreaNotToTag(); }

post_step_regrid = 0;

Expand Down Expand Up @@ -483,8 +491,9 @@ AmrLevel::isStateVariable (const std::string& name, int& state_indx, int& n)

for (n = 0; n < desc.nComp(); n++)
{
if (desc.name(n) == name)
if (desc.name(n) == name) {
return true;
}
}
}
return false;
Expand Down Expand Up @@ -773,7 +782,7 @@ 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.
//
Expand Down Expand Up @@ -1179,7 +1188,7 @@ FixUpPhysCorners (FArrayBox& fab,
const Geometry& TheGeom = TheLevel.Geom();
const Box& ProbDomain = TheState.getDomain();

if (!HasPhysBndry(fab.box(),ProbDomain,TheGeom)) return;
if (!HasPhysBndry(fab.box(),ProbDomain,TheGeom)) { return; }

FArrayBox tmp;

Expand All @@ -1191,14 +1200,14 @@ FixUpPhysCorners (FArrayBox& fab,
{
const int lo = ProbDomain.smallEnd(dir) - fab.box().smallEnd(dir);
const int hi = fab.box().bigEnd(dir) - ProbDomain.bigEnd(dir);
if (lo > 0) GrownDomain.growLo(dir,lo);
if (hi > 0) GrownDomain.growHi(dir,hi);
if (lo > 0) { GrownDomain.growLo(dir,lo); }
if (hi > 0) { GrownDomain.growHi(dir,hi); }
}
}

for (int dir = 0; dir < AMREX_SPACEDIM; dir++)
{
if (!TheGeom.isPeriodic(dir)) continue;
if (!TheGeom.isPeriodic(dir)) { continue; }

Box lo_slab = fab.box();
Box hi_slab = fab.box();
Expand Down Expand Up @@ -1331,7 +1340,7 @@ FillPatchIteratorHelper::fill (FArrayBox& fab,
{
FArrayBox& dstfab = *CrseFabs[i];

if (ThePDomain.contains(dstfab.box())) continue;
if (ThePDomain.contains(dstfab.box())) { continue; }

Vector<IntVect> pshifts(27);

Expand Down Expand Up @@ -1469,8 +1478,9 @@ FillPatchIteratorHelper::fill (FArrayBox& fab,
Box src_dst = FinestCrseFabs[i]->box() & fab.box();
src_dst &= FineDomain;

if (src_dst.ok())
if (src_dst.ok()) {
fab.copy<RunOn::Host>(*FinestCrseFabs[i],src_dst,0,src_dst,dcomp,m_ncomp);
}

fab.shift(-iv);
}
Expand Down Expand Up @@ -1856,8 +1866,9 @@ AmrLevel::getBCArray (int State_Type,
{
bcr = state[State_Type].getBC(strt_comp+n,gridno);
const int* b_rec = bcr.vect();
for (int m = 0; m < 2*AMREX_SPACEDIM; m++)
for (int m = 0; m < 2*AMREX_SPACEDIM; m++) {
bc[2*AMREX_SPACEDIM*n + m] = b_rec[m];
}
}

return bc;
Expand All @@ -1884,12 +1895,13 @@ AmrLevel::setPlotVariables ()
{
pp.get("plot_vars", nm, i);

if (nm == "ALL")
if (nm == "ALL") {
amrex::Amr::fillStatePlotVarList();
else if (nm == "NONE")
} else if (nm == "NONE") {
amrex::Amr::clearStatePlotVarList();
else
} else {
amrex::Amr::addStatePlotVar(nm);
}
}
}
else
Expand All @@ -1910,12 +1922,13 @@ AmrLevel::setPlotVariables ()
{
pp.get("derive_plot_vars", nm, i);

if (nm == "ALL")
if (nm == "ALL") {
amrex::Amr::fillDerivePlotVarList();
else if (nm == "NONE")
} else if (nm == "NONE") {
amrex::Amr::clearDerivePlotVarList();
else
} else {
amrex::Amr::addDerivePlotVar(nm);
}
}
}
else
Expand All @@ -1942,12 +1955,13 @@ AmrLevel::setSmallPlotVariables ()
{
pp.get("small_plot_vars", nm, i);

if (nm == "ALL")
if (nm == "ALL") {
amrex::Amr::fillStateSmallPlotVarList();
else if (nm == "NONE")
} else if (nm == "NONE") {
amrex::Amr::clearStateSmallPlotVarList();
else
} else {
amrex::Amr::addStateSmallPlotVar(nm);
}
}
}
else
Expand All @@ -1968,12 +1982,13 @@ AmrLevel::setSmallPlotVariables ()
{
pp.get("derive_small_plot_vars", nm, i);

if (nm == "ALL")
if (nm == "ALL") {
amrex::Amr::fillDeriveSmallPlotVarList();
else if (nm == "NONE")
} else if (nm == "NONE") {
amrex::Amr::clearDeriveSmallPlotVarList();
else
} else {
amrex::Amr::addDeriveSmallPlotVar(nm);
}
}
}
else
Expand Down Expand Up @@ -2056,8 +2071,9 @@ void AmrLevel::setAreaNotToTag (BoxArray& ba) noexcept

void AmrLevel::constructAreaNotToTag ()
{
if (level == 0 || !parent->useFixedCoarseGrids() || parent->useFixedUpToLevel()>level)
if (level == 0 || !parent->useFixedCoarseGrids() || parent->useFixedUpToLevel()>level) {
return;
}

// We are restricting the tagging on the finest fixed level
if (parent->useFixedUpToLevel()==level)
Expand Down
2 changes: 1 addition & 1 deletion Src/Amr/AMReX_AuxBoundaryData.H
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ public:
BL_ASSERT(!m_empty); BL_ASSERT(m_initialized); return m_fabs.boxArray();
}

void setVal (Real r) { BL_ASSERT(m_initialized); if (!m_empty) m_fabs.setVal(r); }
void setVal (Real r) { BL_ASSERT(m_initialized); if (!m_empty) { m_fabs.setVal(r); } }

const DistributionMapping& DistributionMap () const noexcept
{
Expand Down
2 changes: 1 addition & 1 deletion Src/Amr/AMReX_AuxBoundaryData.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ AuxBoundaryData::copy (const AuxBoundaryData& src,
int dst_comp,
int num_comp)
{
if (m_empty || src.m_empty) return;
if (m_empty || src.m_empty) { return; }

BL_ASSERT(m_initialized);
BL_ASSERT(src_comp + num_comp <= src.m_fabs.nComp());
Expand Down
15 changes: 10 additions & 5 deletions Src/Amr/AMReX_Derive.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -328,8 +328,9 @@ const
std::string&
DeriveRec::variableName(int comp) const noexcept
{
if (comp < variable_names.size())
if (comp < variable_names.size()) {
return variable_names[comp];
}

return derive_name;
}
Expand Down Expand Up @@ -426,12 +427,14 @@ DeriveList::canDerive (const std::string& name) const
{
// Can be either a component name ...
for (int i = 0; i < li.numDerive(); i++) {
if (li.variableName(i) == name)
if (li.variableName(i) == name) {
return true;
}
}
// ... or a derive name
if (li.derive_name == name)
if (li.derive_name == name) {
return true;
}
}
return false;
}
Expand All @@ -443,12 +446,14 @@ DeriveList::get (const std::string& name) const
{
// Can be either a component name ...
for (int i = 0; i < li.numDerive(); i++) {
if (li.variableName(i) == name)
if (li.variableName(i) == name) {
return &(li);
}
}
// ... or a derive name
if (li.derive_name == name)
if (li.derive_name == name) {
return &(li);
}
}
return nullptr;
}
Expand Down
2 changes: 1 addition & 1 deletion Src/Amr/AMReX_Extrapolater.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ namespace amrex::Extrapolater
[=] AMREX_GPU_DEVICE (int i, int j, int k, int n) noexcept
{
if (!gbx.contains(i,j,k)) {
if (mask_arr(i,j,k) == crsebnd) data_arr(i,j,k,n) = 0.0;
if (mask_arr(i,j,k) == crsebnd) { data_arr(i,j,k,n) = 0.0; }
}
});
ParallelFor(amrex::grow(gbx,1), ncomp,
Expand Down
13 changes: 7 additions & 6 deletions Src/Amr/AMReX_StateData.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -442,7 +442,7 @@ StateData::FillBoundary (FArrayBox& dest,
BL_PROFILE("StateData::FillBoundary(dx)");
BL_ASSERT(dest.box().ixType() == desc->getType());

if (domain.contains(dest.box())) return;
if (domain.contains(dest.box())) { return; }

const Box& bx = dest.box();
const int* dlo = dest.loVect();
Expand Down Expand Up @@ -487,8 +487,9 @@ StateData::FillBoundary (FArrayBox& dest,

const int* bc = bcr.vect();

for (int k = 0; k < 2*AMREX_SPACEDIM; k++)
for (int k = 0; k < 2*AMREX_SPACEDIM; k++) {
bci[k] = bc[k];
}

bci += 2*AMREX_SPACEDIM;
}
Expand Down Expand Up @@ -531,7 +532,7 @@ StateData::FillBoundary (Box const& bx,
{
BL_PROFILE("StateData::FillBoundary(geom)");

if (domain.contains(convert(bx,domain.ixType()))) return;
if (domain.contains(convert(bx,domain.ixType()))) { return; }

Vector<BCRec> bcr(num_comp);

Expand Down Expand Up @@ -925,14 +926,14 @@ StateDataPhysBCFunct::operator() (MultiFab& mf, int dest_comp, int num_comp, Int
{
const int lo = domainlo[dir] - bx.smallEnd(dir);
const int hi = bx.bigEnd(dir) - domainhi[dir];
if (lo > 0) GrownDomain.growLo(dir,lo);
if (hi > 0) GrownDomain.growHi(dir,hi);
if (lo > 0) { GrownDomain.growLo(dir,lo); }
if (hi > 0) { GrownDomain.growHi(dir,hi); }
}
}

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;
Expand Down
Loading

0 comments on commit bee6554

Please sign in to comment.