Skip to content

Commit

Permalink
wip
Browse files Browse the repository at this point in the history
  • Loading branch information
WeiqunZhang committed Aug 1, 2023
1 parent e3fc4a1 commit 16021b5
Show file tree
Hide file tree
Showing 135 changed files with 770 additions and 738 deletions.
7 changes: 5 additions & 2 deletions .clang-tidy
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ Checks: >
bugprone-*,
-bugprone-branch-clone,
-bugprone-easily-swappable-parameters,
-bugprone-exception-escape,
-bugprone-implicit-widening-of-multiplication-result,
clang-analyzer-*,
-clang-analyzer-optin.mpi.MPI-Checker,
Expand All @@ -20,15 +21,17 @@ Checks: >
-cppcoreguidelines-owning-memory,
-cppcoreguidelines-pro-*,
misc-*,
-misc-const-correctness,
-misc-non-private-member-variables-in-classes,
-misc-no-recursion,
modernize-*,
-modernize-avoid-c-arrays,
-modernize-macro-to-enum,
-modernize-return-braced-init-list,
-modernize-use-trailing-return-type,
performance-*,
portability-*,
readability-*,
-readability-braces-around-statements,
-readability-container-data-pointer,
-readability-else-after-return,
-readability-function-cognitive-complexity,
-readability-function-size,
Expand Down
12 changes: 6 additions & 6 deletions Src/Amr/AMReX_Amr.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,7 @@ Amr::UsingPrecreateDirectories () noexcept
void
Amr::Initialize ()
{
if (initialized) return;
if (initialized) { return; }
//
// Set all defaults here!!!
//
Expand Down Expand Up @@ -1259,7 +1259,7 @@ Amr::InitializeInit(Real strt_time,
{
BL_PROFILE("Amr::InitializeInit()");
BL_COMM_PROFILE_NAMETAG("Amr::InitializeInit TOP");
if (check_input) checkInput();
if (check_input) { checkInput(); }
//
// Generate internal values from user-supplied values.
//
Expand Down Expand Up @@ -2541,7 +2541,7 @@ Amr::regrid (int lbase,
{
BL_PROFILE("Amr::regrid()");

if (lbase > std::min(finest_level,max_level-1)) return;
if (lbase > std::min(finest_level,max_level-1)) { return; }

if (verbose > 0)
amrex::Print() << "Now regridding at level lbase = " << lbase << "\n";
Expand Down Expand Up @@ -3011,7 +3011,7 @@ Amr::bldFineLevels (Real strt_time)

grid_places(finest_level,strt_time,new_finest,new_grids);

if (new_finest <= finest_level) break;
if (new_finest <= finest_level) { break; }
//
// Create a new level and link with others.
//
Expand Down Expand Up @@ -3181,8 +3181,8 @@ Amr::initPltAndChk ()
//
// -1 ==> use ParallelDescriptor::NProcs().
//
if (plot_nfiles == -1) plot_nfiles = ParallelDescriptor::NProcs();
if (checkpoint_nfiles == -1) checkpoint_nfiles = ParallelDescriptor::NProcs();
if (plot_nfiles == -1) { plot_nfiles = ParallelDescriptor::NProcs(); }
if (checkpoint_nfiles == -1) { checkpoint_nfiles = ParallelDescriptor::NProcs(); }

check_file_root = "chk";
pp.queryAdd("check_file",check_file_root);
Expand Down
16 changes: 8 additions & 8 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 @@ -447,7 +447,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 @@ -773,7 +773,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 +1179,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 +1191,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 +1331,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
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
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
10 changes: 5 additions & 5 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 @@ -531,7 +531,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 +925,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
6 changes: 3 additions & 3 deletions Src/Amr/AMReX_StateDescriptor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ StateDescriptor::bf_thread_safety (const int* /*lo*/,const int* /*hi*/,
for (int i=0; i<2*AMREX_SPACEDIM*ng && !has_ext_dir; ++i) {
has_ext_dir = bc[i]==BCType::ext_dir;
}
if (has_ext_dir) thread_safe = false;
if (has_ext_dir) { thread_safe = false; }
}
return thread_safe;
}
Expand Down Expand Up @@ -417,7 +417,7 @@ StateDescriptor::setUpMaps (int& use_default_map,
// First, count number of interpolaters needed and allocate.
//
InterpBase* map = mapper_comp[start_comp];
if (!map) map = (InterpBase*) default_map;
if (!map) { map = (InterpBase*) default_map; }
nmaps = 1;
int icomp = start_comp+1;

Expand All @@ -441,7 +441,7 @@ StateDescriptor::setUpMaps (int& use_default_map,
icomp++;
}

if (use_default_map) return;
if (use_default_map) { return; }

maps = new InterpBase*[nmaps];
map_start_comp = new int[nmaps];
Expand Down
8 changes: 4 additions & 4 deletions Src/Amr/AMReX_extrapolater_2D_K.H
Original file line number Diff line number Diff line change
Expand Up @@ -28,21 +28,21 @@ amrex_first_order_extrap_cpu(amrex::Box const& bx,
{ // y-dir edges
int j = lo.y-1;
for (int i = lo.x-1; i <= hi.x+1; ++i) {
if (mask(i,j,k) == crsecell) data(i,j,k,n) = Real(0.0);
if (mask(i,j,k) == crsecell) { data(i,j,k,n) = Real(0.0); }
}
j = hi.y+1;
for (int i = lo.x-1; i <= hi.x+1; ++i) {
if (mask(i,j,k) == crsecell) data(i,j,k,n) = Real(0.0);
if (mask(i,j,k) == crsecell) { data(i,j,k,n) = Real(0.0); }
}
}
{ // x-dir edges
int i = lo.x-1;
for (int j = lo.y-1; j <= hi.y+1; ++j) {
if (mask(i,j,k) == crsecell) data(i,j,k,n) = Real(0.0);
if (mask(i,j,k) == crsecell) { data(i,j,k,n) = Real(0.0); }
}
i = hi.x+1;
for (int j = lo.y-1; j <= hi.y+1; ++j) {
if (mask(i,j,k) == crsecell) data(i,j,k,n) = Real(0.0);
if (mask(i,j,k) == crsecell) { data(i,j,k,n) = Real(0.0); }
}
}

Expand Down
12 changes: 6 additions & 6 deletions Src/Amr/AMReX_extrapolater_3D_K.H
Original file line number Diff line number Diff line change
Expand Up @@ -27,41 +27,41 @@ amrex_first_order_extrap_cpu(amrex::Box const& bx,
int k = lo.z-1;
for (int j = lo.y-1; j <= hi.y+1; ++j) {
for (int i = lo.x-1; i <= hi.x+1; ++i) {
if (mask(i,j,k) == crsecell) data(i,j,k,n) = Real(0.0);
if (mask(i,j,k) == crsecell) { data(i,j,k,n) = Real(0.0); }
}
}
k = hi.z+1;
for (int j = lo.y-1; j <= hi.y+1; ++j) {
for (int i = lo.x-1; i <= hi.x+1; ++i) {
if (mask(i,j,k) == crsecell) data(i,j,k,n) = Real(0.0);
if (mask(i,j,k) == crsecell) { data(i,j,k,n) = Real(0.0); }
}
}
}
{ // y-dir faces
int j = lo.y-1;
for (int k = lo.z-1; k <= hi.z+1; ++k) {
for (int i = lo.x-1; i <= hi.x+1; ++i) {
if (mask(i,j,k) == crsecell) data(i,j,k,n) = Real(0.0);
if (mask(i,j,k) == crsecell) { data(i,j,k,n) = Real(0.0); }
}
}
j = hi.y+1;
for (int k = lo.z-1; k <= hi.z+1; ++k) {
for (int i = lo.x-1; i <= hi.x+1; ++i) {
if (mask(i,j,k) == crsecell) data(i,j,k,n) = Real(0.0);
if (mask(i,j,k) == crsecell) { data(i,j,k,n) = Real(0.0); }
}
}
}
{ // x-dir faces
int i = lo.x-1;
for (int k = lo.z-1; k <= hi.z+1; ++k) {
for (int j = lo.y-1; j <= hi.y+1; ++j) {
if (mask(i,j,k) == crsecell) data(i,j,k,n) = Real(0.0);
if (mask(i,j,k) == crsecell) { data(i,j,k,n) = Real(0.0); }
}
}
i = hi.x+1;
for (int k = lo.z-1; k <= hi.z+1; ++k) {
for (int j = lo.y-1; j <= hi.y+1; ++j) {
if (mask(i,j,k) == crsecell) data(i,j,k,n) = Real(0.0);
if (mask(i,j,k) == crsecell) { data(i,j,k,n) = Real(0.0); }
}
}
}
Expand Down
2 changes: 1 addition & 1 deletion Src/AmrCore/AMReX_AmrCore.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ AmrCore::InitFromScratch (Real time)
void
AmrCore::regrid (int lbase, Real time, bool)
{
if (lbase >= max_level) return;
if (lbase >= max_level) { return; }

int new_finest;
Vector<BoxArray> new_grids(finest_level+2);
Expand Down
Loading

0 comments on commit 16021b5

Please sign in to comment.