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 ac6460f commit ef636cd
Show file tree
Hide file tree
Showing 100 changed files with 420 additions and 414 deletions.
3 changes: 3 additions & 0 deletions .clang-tidy
Original file line number Diff line number Diff line change
Expand Up @@ -31,10 +31,13 @@ Checks: >
performance-*,
portability-*,
readability-*,
-readability-else-after-return,
-readability-function-cognitive-complexity,
-readability-function-size,
-readability-identifier-length,
-readability-implicit-bool-conversion,
-readability-magic-numbers,
-readability-named-parameter,
-readability-simplify-boolean-expr,
mpi-*
'
Expand Down
4 changes: 2 additions & 2 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 @@ -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
2 changes: 1 addition & 1 deletion Src/Amr/AMReX_AmrLevel.cpp
Original file line number Diff line number Diff line change
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 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
4 changes: 2 additions & 2 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
2 changes: 1 addition & 1 deletion Src/Amr/AMReX_StateDescriptor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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
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
2 changes: 1 addition & 1 deletion Src/AmrCore/AMReX_AmrMesh.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -412,7 +412,7 @@ AmrMesh::GetLevel (Box const& domain) noexcept
{
Box ccdomain = amrex::enclosedCells(domain);
for (int lev = 0; lev < geom.size(); ++lev) {
if (geom[lev].Domain() == ccdomain) return lev;
if (geom[lev].Domain() == ccdomain) { return lev; }
}
return -1;
}
Expand Down
2 changes: 1 addition & 1 deletion Src/AmrCore/AMReX_Cluster.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -396,7 +396,7 @@ Cluster::new_chop ()
nlo += hist[dir][i-lo[dir]];
}

if (nlo <= 0 || nlo >= m_len) return chop();
if (nlo <= 0 || nlo >= m_len) { return chop(); }

Long nhi = m_len - nlo;

Expand Down
2 changes: 1 addition & 1 deletion Src/AmrCore/AMReX_FillPatchUtil.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ namespace amrex
BL_ASSERT(ngrow == fine[idim]->nGrowVect());
}

if (ngrow.max() == 0) return;
if (ngrow.max() == 0) { return; }

bool include_periodic = true;
bool include_physbndry = false;
Expand Down
8 changes: 4 additions & 4 deletions Src/AmrCore/AMReX_TagBox.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -375,7 +375,7 @@ TagBoxArray::mapPeriodicRemoveDuplicates (const Geometry& geom)
void
TagBoxArray::local_collate_cpu (Gpu::PinnedVector<IntVect>& v) const
{
if (this->local_size() == 0) return;
if (this->local_size() == 0) { return; }

Vector<int> count(this->local_size());
#ifdef AMREX_USE_OMP
Expand All @@ -398,7 +398,7 @@ TagBoxArray::local_collate_cpu (Gpu::PinnedVector<IntVect>& v) const

v.resize(offset.back());

if (v.empty()) return;
if (v.empty()) { return; }

#ifdef AMREX_USE_OMP
#pragma omp parallel
Expand All @@ -425,7 +425,7 @@ void
TagBoxArray::local_collate_gpu (Gpu::PinnedVector<IntVect>& v) const
{
const int nfabs = this->local_size();
if (nfabs == 0) return;
if (nfabs == 0) { return; }

constexpr int block_size = 128;
Vector<int> nblocks(nfabs);
Expand Down Expand Up @@ -496,7 +496,7 @@ TagBoxArray::local_collate_gpu (Gpu::PinnedVector<IntVect>& v) const
std::partial_sum(hv_ntags.begin(), hv_ntags.end(), hv_tags_offset.begin()+1);
int ntotaltags = hv_tags_offset.back();

if (ntotaltags == 0) return;
if (ntotaltags == 0) { return; }

Gpu::NonManagedDeviceVector<int> dv_tags_offset(ntotblocks);
int* dp_tags_offset = dv_tags_offset.data();
Expand Down
8 changes: 4 additions & 4 deletions Src/Base/AMReX_Algorithm.H
Original file line number Diff line number Diff line change
Expand Up @@ -110,8 +110,8 @@ namespace amrex
T flo = f(lo);
T fhi = f(hi);

if (flo == T(0)) return flo;
if (fhi == T(0)) return fhi;
if (flo == T(0)) { return flo; }
if (fhi == T(0)) { return fhi; }

AMREX_ASSERT_WITH_MESSAGE(flo * fhi <= T(0),
"Error - calling bisect but lo and hi don't bracket a root.");
Expand All @@ -121,10 +121,10 @@ namespace amrex
int n = 1;
while (n <= max_iter)
{
if (hi - lo < tol || almostEqual(lo,hi)) break;
if (hi - lo < tol || almostEqual(lo,hi)) { break; }
mi = (lo + hi) / T(2);
fmi = f(mi);
if (fmi == T(0)) break;
if (fmi == T(0)) { break; }
fmi*flo < T(0) ? hi = mi : lo = mi;
flo = f(lo);
fhi = f(hi);
Expand Down
2 changes: 1 addition & 1 deletion Src/Base/AMReX_Arena.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -265,7 +265,7 @@ namespace {
void
Arena::Initialize ()
{
if (initialized) return;
if (initialized) { return; }
initialized = true;

// see reason on allowed reuse of the default CPU BArena in Arena::Finalize
Expand Down
3 changes: 1 addition & 2 deletions Src/Base/AMReX_Array.H
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,7 @@ namespace amrex {
*/
AMREX_GPU_HOST_DEVICE AMREX_FORCE_INLINE
void fill ( const T& value ) noexcept
{ for (unsigned int i = 0; i < N; ++i) arr[i] = value; }
{ for (unsigned int i = 0; i < N; ++i) { arr[i] = value; } }

/**
* Returns the sum of all elements in the GpuArray object.
Expand Down Expand Up @@ -897,4 +897,3 @@ namespace amrex
}

#endif

4 changes: 2 additions & 2 deletions Src/Base/AMReX_BCUtil.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -35,8 +35,8 @@ struct dummy_gpu_fill_extdir

void FillDomainBoundary (MultiFab& phi, const Geometry& geom, const Vector<BCRec>& bc)
{
if (geom.isAllPeriodic()) return;
if (phi.nGrow() == 0) return;
if (geom.isAllPeriodic()) { return; }
if (phi.nGrow() == 0) { return; }

AMREX_ALWAYS_ASSERT(phi.ixType().cellCentered());

Expand Down
4 changes: 2 additions & 2 deletions Src/Base/AMReX_BaseFab.H
Original file line number Diff line number Diff line change
Expand Up @@ -1895,7 +1895,7 @@ BaseFab<T>::define ()
AMREX_ASSERT(this->dptr == nullptr);
AMREX_ASSERT(this->domain.numPts() > 0);
AMREX_ASSERT(this->nvar >= 0);
if (this->nvar == 0) return;
if (this->nvar == 0) { return; }
AMREX_ASSERT(std::numeric_limits<Long>::max()/this->nvar > this->domain.numPts());

this->truesize = this->nvar*this->domain.numPts();
Expand Down Expand Up @@ -2590,7 +2590,7 @@ BaseFab<T>::indexFromValue (Box const& subbox, int comp, T const& value) const n
{
AMREX_LOOP_3D(subbox, i, j, k,
{
if (a(i,j,k) == value) return IntVect(AMREX_D_DECL(i,j,k));
if (a(i,j,k) == value) { return IntVect(AMREX_D_DECL(i,j,k)); }
});
return IntVect::TheMinVector();
}
Expand Down
11 changes: 7 additions & 4 deletions Src/Base/AMReX_Box.H
Original file line number Diff line number Diff line change
Expand Up @@ -636,10 +636,11 @@ public:
AMREX_GPU_HOST_DEVICE
Box& grow (Orientation face, int n_cell = 1) noexcept {
int idir = face.coordDir();
if (face.isLow())
if (face.isLow()) {
smallend.shift(idir, -n_cell);
else
} else {
bigend.shift(idir,n_cell);
}
return *this;
}

Expand Down Expand Up @@ -800,9 +801,11 @@ Box::coarsen (const IntVect& ref_ratio) noexcept
IntVect off(0);
for (int dir = 0; dir < AMREX_SPACEDIM; dir++)
{
if (btype[dir])
if (bigend[dir]%ref_ratio[dir])
if (btype[dir]) {
if (bigend[dir]%ref_ratio[dir]) {
off.setVal(dir,1);
}
}
}
bigend.coarsen(ref_ratio);
bigend += off;
Expand Down
4 changes: 2 additions & 2 deletions Src/Base/AMReX_Box.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,7 @@ AllGatherBoxes (Vector<Box>& bxs, int n_extra_reserve)
count_tot += countvec[i];
}

if (count_tot == 0) return;
if (count_tot == 0) { return; }

if (count_tot > static_cast<Long>(std::numeric_limits<int>::max())) {
amrex::Abort("AllGatherBoxes: too many boxes");
Expand Down Expand Up @@ -158,7 +158,7 @@ AllGatherBoxes (Vector<Box>& bxs, int n_extra_reserve)

MPI_Bcast(&count_tot, 1, MPI_INT, root, comm);

if (count_tot == 0) return;
if (count_tot == 0) { return; }

if (count_tot > static_cast<Long>(std::numeric_limits<int>::max())) {
amrex::Abort("AllGatherBoxes: too many boxes");
Expand Down
Loading

0 comments on commit ef636cd

Please sign in to comment.