diff --git a/.clang-tidy b/.clang-tidy index 81892813369..4d954067db6 100644 --- a/.clang-tidy +++ b/.clang-tidy @@ -10,7 +10,6 @@ Checks: > clang-diagnostic-*, cppcoreguidelines-*, -cppcoreguidelines-avoid-c-arrays, - -cppcoreguidelines-avoid-goto, -cppcoreguidelines-avoid-magic-numbers, -cppcoreguidelines-avoid-non-const-global-variables, -cppcoreguidelines-init-variables, @@ -20,16 +19,21 @@ Checks: > -cppcoreguidelines-non-private-member-variables-in-classes, -cppcoreguidelines-owning-memory, -cppcoreguidelines-pro-*, - misc-misplaced-const, + google-build-explicit-make-pair, + google-build-namespaces, + google-global-names-in-headers, + 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, diff --git a/Src/Base/AMReX.H b/Src/Base/AMReX.H index a0eba4a5c0d..c539a1d8e75 100644 --- a/Src/Base/AMReX.H +++ b/Src/Base/AMReX.H @@ -117,7 +117,7 @@ namespace amrex #if defined(NDEBUG) amrex::ignore_unused(msg); #else - if (msg) AMREX_DEVICE_PRINTF("Error %s\n", msg); + if (msg) { AMREX_DEVICE_PRINTF("Error %s\n", msg); } AMREX_DEVICE_ASSERT(0); #endif #else @@ -136,7 +136,7 @@ namespace amrex #if defined(NDEBUG) amrex::ignore_unused(msg); #else - if (msg) AMREX_DEVICE_PRINTF("Warning %s\n", msg); + if (msg) { AMREX_DEVICE_PRINTF("Warning %s\n", msg); } #endif #else Warning_host(msg); @@ -152,7 +152,7 @@ namespace amrex #if defined(NDEBUG) amrex::ignore_unused(msg); #else - if (msg) AMREX_DEVICE_PRINTF("Abort %s\n", msg); + if (msg) { AMREX_DEVICE_PRINTF("Abort %s\n", msg); } AMREX_DEVICE_ASSERT(0); #endif #else diff --git a/Src/Base/AMReX.cpp b/Src/Base/AMReX.cpp index 6bb199f21b6..b43add7c9d1 100644 --- a/Src/Base/AMReX.cpp +++ b/Src/Base/AMReX.cpp @@ -364,7 +364,7 @@ amrex::Initialize (int& argc, char**& argv, bool build_parm_parse, system::exename += argv[0]; for (int i = 0; i < argc; ++i) { - if (i != 0) command_line.append(" "); + if (i != 0) { command_line.append(" "); } command_line.append(argv[i]); command_arguments.emplace_back(argv[i]); } @@ -412,7 +412,7 @@ amrex::Initialize (int& argc, char**& argv, bool build_parm_parse, // the rest get ingored. int ppargc = 1; for (; ppargc < argc; ++ppargc) { - if (std::strcmp(argv[ppargc], "--") == 0) break; + if (std::strcmp(argv[ppargc], "--") == 0) { break; } } if (ppargc > 1) { @@ -549,9 +549,9 @@ amrex::Initialize (int& argc, char**& argv, bool build_parm_parse, #if defined(__linux__) curr_fpe_excepts = 0; - if (invalid) curr_fpe_excepts |= FE_INVALID; - if (divbyzero) curr_fpe_excepts |= FE_DIVBYZERO; - if (overflow) curr_fpe_excepts |= FE_OVERFLOW; + if (invalid) { curr_fpe_excepts |= FE_INVALID; } + if (divbyzero) { curr_fpe_excepts |= FE_DIVBYZERO; } + if (overflow) { curr_fpe_excepts |= FE_OVERFLOW; } prev_fpe_excepts = fegetexcept(); if (curr_fpe_excepts != 0) { feenableexcept(curr_fpe_excepts); // trap floating point exceptions @@ -561,9 +561,9 @@ amrex::Initialize (int& argc, char**& argv, bool build_parm_parse, #elif defined(__APPLE__) && defined(__x86_64__) prev_fpe_mask = _MM_GET_EXCEPTION_MASK(); curr_fpe_excepts = 0u; - if (invalid) curr_fpe_excepts |= _MM_MASK_INVALID; - if (divbyzero) curr_fpe_excepts |= _MM_MASK_DIV_ZERO; - if (overflow) curr_fpe_excepts |= _MM_MASK_OVERFLOW; + if (invalid) { curr_fpe_excepts |= _MM_MASK_INVALID; } + if (divbyzero) { curr_fpe_excepts |= _MM_MASK_DIV_ZERO; } + if (overflow) { curr_fpe_excepts |= _MM_MASK_OVERFLOW; } if (curr_fpe_excepts != 0u) { _MM_SET_EXCEPTION_MASK(prev_fpe_mask & ~curr_fpe_excepts); prev_handler_sigfpe = std::signal(SIGFPE, BLBackTrace::handler); @@ -582,9 +582,9 @@ amrex::Initialize (int& argc, char**& argv, bool build_parm_parse, fenv_t env; fegetenv(&env); - if (invalid) env.__fpcr |= __fpcr_trap_invalid; - if (divbyzero) env.__fpcr |= __fpcr_trap_divbyzero; - if (overflow) env.__fpcr |= __fpcr_trap_overflow; + if (invalid) { env.__fpcr |= __fpcr_trap_invalid; } + if (divbyzero) { env.__fpcr |= __fpcr_trap_divbyzero; } + if (overflow) { env.__fpcr |= __fpcr_trap_overflow; } fesetenv(&env); // SIGILL ref: https://developer.apple.com/forums/thread/689159 #endif @@ -708,7 +708,7 @@ amrex::Finalize (amrex::AMReX* pamrex) AMReX::erase(pamrex); #ifdef AMREX_USE_HYPRE - if (init_hypre) HYPRE_Finalize(); + if (init_hypre) { HYPRE_Finalize(); } #endif BL_TINY_PROFILE_FINALIZE(); @@ -781,12 +781,12 @@ amrex::Finalize (amrex::AMReX* pamrex) #ifndef BL_AMRPROF if (system::signal_handling) { - if (prev_handler_sigsegv != SIG_ERR) std::signal(SIGSEGV, prev_handler_sigsegv); // NOLINT(performance-no-int-to-ptr) - if (prev_handler_sigterm != SIG_ERR) std::signal(SIGTERM, prev_handler_sigterm); // NOLINT(performance-no-int-to-ptr) - if (prev_handler_sigint != SIG_ERR) std::signal(SIGINT , prev_handler_sigint); // NOLINT(performance-no-int-to-ptr) - if (prev_handler_sigabrt != SIG_ERR) std::signal(SIGABRT, prev_handler_sigabrt); // NOLINT(performance-no-int-to-ptr) - if (prev_handler_sigfpe != SIG_ERR) std::signal(SIGFPE , prev_handler_sigfpe); // NOLINT(performance-no-int-to-ptr) - if (prev_handler_sigill != SIG_ERR) std::signal(SIGILL , prev_handler_sigill); // NOLINT(performance-no-int-to-ptr) + if (prev_handler_sigsegv != SIG_ERR) { std::signal(SIGSEGV, prev_handler_sigsegv); } // NOLINT(performance-no-int-to-ptr) + if (prev_handler_sigterm != SIG_ERR) { std::signal(SIGTERM, prev_handler_sigterm); } // NOLINT(performance-no-int-to-ptr) + if (prev_handler_sigint != SIG_ERR) { std::signal(SIGINT , prev_handler_sigint); } // NOLINT(performance-no-int-to-ptr) + if (prev_handler_sigabrt != SIG_ERR) { std::signal(SIGABRT, prev_handler_sigabrt); } // NOLINT(performance-no-int-to-ptr) + if (prev_handler_sigfpe != SIG_ERR) { std::signal(SIGFPE , prev_handler_sigfpe); } // NOLINT(performance-no-int-to-ptr) + if (prev_handler_sigill != SIG_ERR) { std::signal(SIGILL , prev_handler_sigill); } // NOLINT(performance-no-int-to-ptr) #if defined(__linux__) #if !defined(__PGI) || (__PGIC__ >= 16) if (curr_fpe_excepts != 0) { diff --git a/Src/Base/AMReX_Algorithm.H b/Src/Base/AMReX_Algorithm.H index 510796a861b..b418f3cc1c0 100644 --- a/Src/Base/AMReX_Algorithm.H +++ b/Src/Base/AMReX_Algorithm.H @@ -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."); @@ -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); diff --git a/Src/Base/AMReX_Arena.cpp b/Src/Base/AMReX_Arena.cpp index d60561e7887..ce4ece3b643 100644 --- a/Src/Base/AMReX_Arena.cpp +++ b/Src/Base/AMReX_Arena.cpp @@ -141,7 +141,7 @@ Arena::allocate_system (std::size_t nbytes) // NOLINT(readability-make-member-fu #pragma GCC diagnostic push #pragma GCC diagnostic ignored "-Wmaybe-uninitialized" #endif - if (p && (nbytes > 0) && arena_info.device_use_hostalloc) mlock(p, nbytes); + if (p && (nbytes > 0) && arena_info.device_use_hostalloc) { mlock(p, nbytes); } #if defined(__GNUC__) && !defined(__clang__) #pragma GCC diagnostic pop #endif @@ -201,13 +201,13 @@ Arena::allocate_system (std::size_t nbytes) // NOLINT(readability-make-member-fu #pragma GCC diagnostic push #pragma GCC diagnostic ignored "-Wmaybe-uninitialized" #endif - if (p && (nbytes > 0) && arena_info.device_use_hostalloc) mlock(p, nbytes); + if (p && (nbytes > 0) && arena_info.device_use_hostalloc) { mlock(p, nbytes); } #if defined(__GNUC__) && !defined(__clang__) #pragma GCC diagnostic pop #endif #endif #endif - if (p == nullptr) amrex::Abort("Sorry, malloc failed"); + if (p == nullptr) { amrex::Abort("Sorry, malloc failed"); } return p; } @@ -217,7 +217,7 @@ Arena::deallocate_system (void* p, std::size_t nbytes) // NOLINT(readability-mak #ifdef AMREX_USE_GPU if (arena_info.use_cpu_memory) { - if (p && arena_info.device_use_hostalloc) AMREX_MUNLOCK(p, nbytes); + if (p && arena_info.device_use_hostalloc) { AMREX_MUNLOCK(p, nbytes); } std::free(p); } else if (arena_info.device_use_hostalloc) @@ -235,7 +235,7 @@ Arena::deallocate_system (void* p, std::size_t nbytes) // NOLINT(readability-mak sycl::free(p,Gpu::Device::syclContext())); } #else - if (p && arena_info.device_use_hostalloc) AMREX_MUNLOCK(p, nbytes); + if (p && arena_info.device_use_hostalloc) { AMREX_MUNLOCK(p, nbytes); } std::free(p); #endif } @@ -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 diff --git a/Src/Base/AMReX_Array.H b/Src/Base/AMReX_Array.H index c9a3eb63a56..3d853329ebc 100644 --- a/Src/Base/AMReX_Array.H +++ b/Src/Base/AMReX_Array.H @@ -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. @@ -853,7 +853,7 @@ namespace amrex template std::array GetArrOfPtrs (std::array& a) noexcept { - return {{AMREX_D_DECL(&a[0], &a[1], &a[2])}}; + return {{AMREX_D_DECL(a.data(), a.data()+1, a.data()+2)}}; } template @@ -865,13 +865,13 @@ namespace amrex template std::array GetArrOfConstPtrs (const std::array& a) noexcept { - return {{AMREX_D_DECL(&a[0], &a[1], &a[2])}}; + return {{AMREX_D_DECL(a.data(), a.data()+1, a.data()+2)}}; } template std::array GetArrOfConstPtrs (const std::array& a) noexcept { - return {{AMREX_D_DECL(a[0], a[1], a[2])}}; + return {{AMREX_D_DECL(a.data(), a.data()+1, a.data()+2)}}; } template @@ -897,4 +897,3 @@ namespace amrex } #endif - diff --git a/Src/Base/AMReX_AsyncOut.cpp b/Src/Base/AMReX_AsyncOut.cpp index 2ee6fec4637..b235baa6580 100644 --- a/Src/Base/AMReX_AsyncOut.cpp +++ b/Src/Base/AMReX_AsyncOut.cpp @@ -62,7 +62,7 @@ void Finalize () } #ifdef AMREX_USE_MPI - if (s_comm != MPI_COMM_NULL) MPI_Comm_free(&s_comm); + if (s_comm != MPI_COMM_NULL) { MPI_Comm_free(&s_comm); } s_comm = MPI_COMM_NULL; #endif } diff --git a/Src/Base/AMReX_BCUtil.cpp b/Src/Base/AMReX_BCUtil.cpp index ff17bd4e244..c0a645ba05c 100644 --- a/Src/Base/AMReX_BCUtil.cpp +++ b/Src/Base/AMReX_BCUtil.cpp @@ -35,8 +35,8 @@ struct dummy_gpu_fill_extdir void FillDomainBoundary (MultiFab& phi, const Geometry& geom, const Vector& 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()); diff --git a/Src/Base/AMReX_BaseFab.H b/Src/Base/AMReX_BaseFab.H index 960f1078e18..99132038397 100644 --- a/Src/Base/AMReX_BaseFab.H +++ b/Src/Base/AMReX_BaseFab.H @@ -1769,8 +1769,9 @@ BaseFab::getVal (T* data, AMREX_ASSERT(!(this->dptr == nullptr)); AMREX_ASSERT(n >= 0 && n + numcomp <= this->nvar); - for (int k = 0; k < numcomp; k++) + for (int k = 0; k < numcomp; k++) { data[k] = this->dptr[loc+(n+k)*sz]; + } } template @@ -1895,7 +1896,7 @@ BaseFab::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::max()/this->nvar > this->domain.numPts()); this->truesize = this->nvar*this->domain.numPts(); @@ -1923,7 +1924,7 @@ template BaseFab::BaseFab (const Box& bx, int n, bool alloc, bool shared, Arena* ar) : DataAllocator{ar}, domain(bx), nvar(n), shared_memory(shared) { - if (!this->shared_memory && alloc) define(); + if (!this->shared_memory && alloc) { define(); } } template @@ -2054,16 +2055,18 @@ BaseFab::resize (const Box& b, int n, Arena* ar) } else if (this->dptr == nullptr || !this->ptr_owner) { - if (this->shared_memory) + if (this->shared_memory) { amrex::Abort("BaseFab::resize: BaseFab in shared memory cannot increase size"); + } this->dptr = nullptr; define(); } else if (this->nvar*this->domain.numPts() > this->truesize) { - if (this->shared_memory) + if (this->shared_memory) { amrex::Abort("BaseFab::resize: BaseFab in shared memory cannot increase size"); + } clear(); @@ -2590,7 +2593,7 @@ BaseFab::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(); } diff --git a/Src/Base/AMReX_BlockMutex.cpp b/Src/Base/AMReX_BlockMutex.cpp index d07d89fd76a..8ce63a15133 100644 --- a/Src/Base/AMReX_BlockMutex.cpp +++ b/Src/Base/AMReX_BlockMutex.cpp @@ -13,7 +13,7 @@ void BlockMutex::init_states (state_t* state, int N) noexcept { [=] AMREX_GPU_DEVICE () noexcept { int i = threadIdx.x + blockIdx.x*blockDim.x; - if (i < N) state[i] = FreeState(); + if (i < N) { state[i] = FreeState(); } }); #endif } diff --git a/Src/Base/AMReX_Box.H b/Src/Base/AMReX_Box.H index 025c4b90c45..0a32d637d4f 100644 --- a/Src/Base/AMReX_Box.H +++ b/Src/Base/AMReX_Box.H @@ -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; } @@ -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; diff --git a/Src/Base/AMReX_Box.cpp b/Src/Base/AMReX_Box.cpp index 0b2560749b5..b0db9caa994 100644 --- a/Src/Base/AMReX_Box.cpp +++ b/Src/Base/AMReX_Box.cpp @@ -24,8 +24,9 @@ operator<< (std::ostream& os, << b.type() << ')'; - if (os.fail()) + if (os.fail()) { amrex::Error("operator<<(ostream&,Box&) failed"); + } return os; } @@ -77,8 +78,9 @@ operator>> (std::istream& is, b = Box(lo,hi,typ); - if (is.fail()) + if (is.fail()) { amrex::Error("operator>>(istream&,Box&) failed"); + } return is; } @@ -88,7 +90,7 @@ BoxCommHelper::BoxCommHelper (const Box& bx, int* p_) { if (p == nullptr) { v.resize(3*AMREX_SPACEDIM); - p = &v[0]; + p = v.data(); } AMREX_D_EXPR(p[0] = bx.smallend[0], @@ -123,7 +125,7 @@ AllGatherBoxes (Vector& bxs, int n_extra_reserve) count_tot += countvec[i]; } - if (count_tot == 0) return; + if (count_tot == 0) { return; } if (count_tot > static_cast(std::numeric_limits::max())) { amrex::Abort("AllGatherBoxes: too many boxes"); @@ -158,7 +160,7 @@ AllGatherBoxes (Vector& 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(std::numeric_limits::max())) { amrex::Abort("AllGatherBoxes: too many boxes"); diff --git a/Src/Base/AMReX_BoxArray.cpp b/Src/Base/AMReX_BoxArray.cpp index 8dfbd2b6379..9413f5ae5c1 100644 --- a/Src/Base/AMReX_BoxArray.cpp +++ b/Src/Base/AMReX_BoxArray.cpp @@ -496,8 +496,9 @@ BoxArray::writeOn (std::ostream& os) const os << ')'; - if (os.fail()) + if (os.fail()) { amrex::Error("BoxArray::writeOn(ostream&) failed"); + } return os; } @@ -518,9 +519,9 @@ BoxArray::operator!= (const BoxArray& rhs) const noexcept bool BoxArray::operator== (const Vector& bv) const noexcept { - if (size() != bv.size()) return false; + if (size() != bv.size()) { return false; } for (int i = 0; i < static_cast(size()); ++i) { - if (this->operator[](i) != bv[i]) return false; + if (this->operator[](i) != bv[i]) { return false; } } return true; } @@ -601,11 +602,11 @@ bool BoxArray::coarsenable (const IntVect& refinement_ratio, const IntVect& min_width) const { const Long sz = size(); - if(size() == 0) return false; + if(size() == 0) { return false; } const Box& first = (*this)[0]; bool res = first.coarsenable(refinement_ratio,min_width); - if (res == false) return false; + if (res == false) { return false; } auto const& bxs = this->m_ref->m_abox; if (m_bat.is_null()) { @@ -873,17 +874,17 @@ BoxArray::ok () const auto const& bxs = this->m_ref->m_abox; if (m_bat.is_null()) { for (int i = 0; i < N; ++i) { - if (! bxs[i].ok()) return false; + if (! bxs[i].ok()) { return false; } } } else if (m_bat.is_simple()) { IndexType t = ixType(); IntVect cr = crseRatio(); for (int i = 0; i < N; ++i) { - if (! amrex::convert(amrex::coarsen(bxs[i],cr),t).ok()) return false; + if (! amrex::convert(amrex::coarsen(bxs[i],cr),t).ok()) { return false; } } } else { for (int i = 0; i < N; ++i) { - if (! m_bat.m_op.m_bndryReg(bxs[i]).ok()) return false; + if (! m_bat.m_op.m_bndryReg(bxs[i]).ok()) { return false; } } } } @@ -900,19 +901,19 @@ BoxArray::isDisjoint () const if (m_bat.is_null()) { for (int i = 0; i < N; ++i) { intersections(bxs[i],isects); - if ( isects.size() > 1 ) return false; + if ( isects.size() > 1 ) { return false; } } } else if (m_bat.is_simple()) { IndexType t = ixType(); IntVect cr = crseRatio(); for (int i = 0; i < N; ++i) { intersections(amrex::convert(amrex::coarsen(bxs[i],cr),t), isects); - if ( isects.size() > 1 ) return false; + if ( isects.size() > 1 ) { return false; } } } else { for (int i = 0; i < N; ++i) { intersections(m_bat.m_op.m_bndryReg(bxs[i]), isects); - if ( isects.size() > 1 ) return false; + if ( isects.size() > 1 ) { return false; } } } @@ -996,9 +997,9 @@ BoxArray::contains (const Box& b, bool assume_disjoint_ba, const IntVect& ng) co bool BoxArray::contains (const BoxArray& ba, bool assume_disjoint_ba, const IntVect& ng) const { - if (size() == 0) return false; + if (size() == 0) { return false; } - if (!minimalBox().grow(ng).contains(ba.minimalBox())) return false; + if (!minimalBox().grow(ng).contains(ba.minimalBox())) { return false; } for (int i = 0, N = static_cast(ba.size()); i < N; ++i) { if (!contains(ba[i],assume_disjoint_ba, ng)) { @@ -1200,7 +1201,7 @@ BoxArray::intersections (const Box& bx, Box cbx(sm,bg); cbx.normalize(); - if (!cbx.intersects(m_ref->bbox)) return; + if (!cbx.intersects(m_ref->bbox)) { return; } auto TheEnd = BoxHashMap.cend(); @@ -1221,7 +1222,7 @@ BoxArray::intersections (const Box& bx, if (isect.ok()) { isects.emplace_back(index,isect); - if (first_only) return; + if (first_only) { return; } } } } else if (m_bat.is_simple()) { @@ -1235,7 +1236,7 @@ BoxArray::intersections (const Box& bx, if (isect.ok()) { isects.emplace_back(index,isect); - if (first_only) return; + if (first_only) { return; } } } } else { @@ -1247,7 +1248,7 @@ BoxArray::intersections (const Box& bx, if (isect.ok()) { isects.emplace_back(index,isect); - if (first_only) return; + if (first_only) { return; } } } } @@ -1271,7 +1272,7 @@ BoxArray::complementIn (BoxList& bl, const Box& bx) const bl.set(bx.ixType()); bl.push_back(bx); - if (empty()) return; + if (empty()) { return; } BARef::HashType& BoxHashMap = getHashMap(); @@ -1293,7 +1294,7 @@ BoxArray::complementIn (BoxList& bl, const Box& bx) const Box cbx(sm,bg); cbx.normalize(); - if (!cbx.intersects(m_ref->bbox)) return; + if (!cbx.intersects(m_ref->bbox)) { return; } auto TheEnd = BoxHashMap.cend(); @@ -1408,7 +1409,7 @@ BoxArray::removeOverlap (bool simplify) for (auto const& is: isects) { - if (is.first == i) continue; + if (is.first == i) { continue; } Box& bx = m_ref->m_abox[is.first]; @@ -1481,7 +1482,7 @@ BoxArray::getHashMap () const { BARef::HashType& BoxHashMap = m_ref->hash; - if (m_ref->HasHashMap()) return BoxHashMap; + if (m_ref->HasHashMap()) { return BoxHashMap; } #ifdef AMREX_USE_OMP #pragma omp critical(intersections_lock) @@ -1589,13 +1590,15 @@ operator<< (std::ostream& os, << 0 << ")\n "; - for (int i = 0, N = static_cast(ba.size()); i < N; ++i) + for (int i = 0, N = static_cast(ba.size()); i < N; ++i) { os << ba[i] << ' '; + } os << ")\n"; - if (os.fail()) + if (os.fail()) { amrex::Error("operator<<(ostream& os,const BoxArray&) failed"); + } return os; } @@ -1669,7 +1672,7 @@ intersect (const BoxArray& ba, BoxArray intersect (const BoxArray& lhs, const BoxArray& rhs) { - if (lhs.empty() || rhs.empty()) return BoxArray(); + if (lhs.empty() || rhs.empty()) { return BoxArray(); } BoxList bl(lhs[0].ixType()); for (int i = 0, Nl = static_cast(lhs.size()); i < Nl; ++i) { diff --git a/Src/Base/AMReX_BoxDomain.cpp b/Src/Base/AMReX_BoxDomain.cpp index 892c847ca27..4213f629544 100644 --- a/Src/Base/AMReX_BoxDomain.cpp +++ b/Src/Base/AMReX_BoxDomain.cpp @@ -231,8 +231,9 @@ operator<< (std::ostream& os, const BoxDomain& bd) { os << "(BoxDomain " << bd.boxList() << ")" << std::flush; - if (os.fail()) + if (os.fail()) { amrex::Error("operator<<(ostream&,BoxDomain&) failed"); + } return os; } diff --git a/Src/Base/AMReX_BoxIterator.H b/Src/Base/AMReX_BoxIterator.H index c11d55c0ce4..bf05a9e817f 100644 --- a/Src/Base/AMReX_BoxIterator.H +++ b/Src/Base/AMReX_BoxIterator.H @@ -111,7 +111,7 @@ namespace amrex inline void BoxIterator::begin () noexcept { - if (m_boxLo <= m_boxHi) m_current = m_boxLo; + if (m_boxLo <= m_boxHi) { m_current = m_boxLo; } } inline diff --git a/Src/Base/AMReX_BoxList.cpp b/Src/Base/AMReX_BoxList.cpp index 584b707b4d8..4459b24dba9 100644 --- a/Src/Base/AMReX_BoxList.cpp +++ b/Src/Base/AMReX_BoxList.cpp @@ -251,9 +251,9 @@ BoxList::isDisjoint () const } bool -BoxList::contains (const BoxList& bl) const +BoxList::contains (const BoxList& bl) const { - if (isEmpty() || bl.isEmpty()) return false; + if (isEmpty() || bl.isEmpty()) { return false; } BL_ASSERT(ixType() == bl.ixType()); diff --git a/Src/Base/AMReX_DistributionMapping.cpp b/Src/Base/AMReX_DistributionMapping.cpp index 7ee39e310d7..9350f9203d1 100644 --- a/Src/Base/AMReX_DistributionMapping.cpp +++ b/Src/Base/AMReX_DistributionMapping.cpp @@ -106,7 +106,7 @@ DistributionMapping::operator!= (const DistributionMapping& rhs) const noexcept void DistributionMapping::Initialize () { - if (initialized) return; + if (initialized) { return; } // // Set defaults here!!! // @@ -692,7 +692,7 @@ top: ; max_weight = static_cast(bl_top->weight()); efficiency = sum_weight / (static_cast(nprocs)*max_weight); - goto top; + goto top; // NOLINT } } } @@ -856,13 +856,13 @@ DistributionMapping::KnapSackProcessorMap (const std::vector& wgts, { RoundRobinProcessorMap(static_cast(wgts.size()),nprocs, sort); - if (efficiency) *efficiency = 1; + if (efficiency) { *efficiency = 1; } } else { Real eff = 0; KnapSackDoIt(wgts, nprocs, eff, do_full_knapsack, nmax, sort); - if (efficiency) *efficiency = eff; + if (efficiency) { *efficiency = eff; } } } @@ -1017,7 +1017,7 @@ DistributionMapping::KnapSackProcessorMap (const DistributionMapping& olddm, max_weight = static_cast(bl_top->weight()); new_efficiency = avg_weight / max_weight; - goto top; + goto top; // NOLINT } } } @@ -1335,7 +1335,7 @@ DistributionMapping::SFCProcessorMapDoIt (const BoxArray& boxes, LIpairV.emplace_back(wgt,i); } - if (sort) Sort(LIpairV, true); + if (sort) { Sort(LIpairV, true); } if (flag_verbose_mapper) { for (const auto &p : LIpairV) { @@ -1441,11 +1441,11 @@ DistributionMapping::SFCProcessorMapDoIt (const BoxArray& boxes, for (int i = 0; i < nteams; ++i) { const Long W = LIpairV[i].first; - if (W > max_wgt) max_wgt = W; + if (W > max_wgt) { max_wgt = W; } sum_wgt += W; } Real efficiency = static_cast(sum_wgt)/static_cast(nteams*max_wgt); - if (eff) *eff = efficiency; + if (eff) { *eff = efficiency; } if (verbose) { @@ -1871,7 +1871,7 @@ DistributionMapping::makeSFC (const LayoutData& rcost_local, } // Broadcast vector from which to construct new distribution mapping - ParallelDescriptor::Bcast(&pmap[0], pmap.size(), root); + ParallelDescriptor::Bcast(pmap.data(), pmap.size(), root); if (ParallelDescriptor::MyProc() != root) { r = DistributionMapping(pmap); @@ -1968,8 +1968,9 @@ operator<< (std::ostream& os, os << ')' << '\n'; - if (os.fail()) + if (os.fail()) { amrex::Error("operator<<(ostream &, DistributionMapping &) failed"); + } return os; } diff --git a/Src/Base/AMReX_FACopyDescriptor.H b/Src/Base/AMReX_FACopyDescriptor.H index 263fb9ece48..5194ca7f876 100644 --- a/Src/Base/AMReX_FACopyDescriptor.H +++ b/Src/Base/AMReX_FACopyDescriptor.H @@ -94,8 +94,9 @@ FabCopyDescriptor::FabCopyDescriptor () template FabCopyDescriptor::~FabCopyDescriptor () { - if (cacheDataAllocated) + if (cacheDataAllocated) { delete localFabSource; + } } /** @@ -435,7 +436,7 @@ FabArrayCopyDescriptor::CollectData () { dataAvailable = true; - if (ParallelDescriptor::NProcs() == 1) return; + if (ParallelDescriptor::NProcs() == 1) { return; } #ifdef BL_USE_MPI using value_type = typename FAB::value_type; @@ -524,9 +525,11 @@ FabArrayCopyDescriptor::CollectData () } BL_ASSERT(SndsArray[MyProc] == 0); - for (int i = 0; i < NProcs; i++) - if (SndsArray[i] > 0) + for (int i = 0; i < NProcs; i++) { + if (SndsArray[i] > 0) { Snds[i] = SndsArray[i]; + } + } } // There are two rounds of send and recv. @@ -538,7 +541,7 @@ FabArrayCopyDescriptor::CollectData () const auto N_snds = static_cast(Snds.size()); const auto N_rcvs = static_cast(Rcvs.size()); - if ( N_snds == 0 && N_rcvs == 0 ) return; + if ( N_snds == 0 && N_rcvs == 0 ) { return; } const int Nints = 4 + 3*AMREX_SPACEDIM; // # of ints in a meta-data diff --git a/Src/Base/AMReX_FArrayBox.cpp b/Src/Base/AMReX_FArrayBox.cpp index 2074ef8d663..6efd90f97e9 100644 --- a/Src/Base/AMReX_FArrayBox.cpp +++ b/Src/Base/AMReX_FArrayBox.cpp @@ -123,7 +123,7 @@ FArrayBox::FArrayBox (const Box& b, int ncomp, Arena* ar) FArrayBox::FArrayBox (const Box& b, int n, bool alloc, bool shared, Arena* ar) : BaseFab(b,n,alloc,shared,ar) { - if (alloc) initVal(); + if (alloc) { initVal(); } } FArrayBox::FArrayBox (const FArrayBox& rhs, MakeType make_type, int scomp, int ncomp) @@ -180,7 +180,7 @@ FArrayBox::initVal () noexcept p[i] = x; }); #ifdef AMREX_USE_GPU - if (runon == RunOn::Gpu) Gpu::streamSynchronize(); + if (runon == RunOn::Gpu) { Gpu::streamSynchronize(); } #else amrex::ignore_unused(runon); #endif @@ -346,7 +346,7 @@ FArrayBox::get_initval () void FArrayBox::Initialize () { - if (initialized) return; + if (initialized) { return; } initialized = true; BL_ASSERT(fabio == nullptr); @@ -419,14 +419,13 @@ FArrayBox::Initialize () if (pp.query("ordering", ord)) { - if (ord == "NORMAL_ORDER") + if (ord == "NORMAL_ORDER") { FArrayBox::setOrdering(FABio::FAB_NORMAL_ORDER); - else if (ord == "REVERSE_ORDER") + } else if (ord == "REVERSE_ORDER") { FArrayBox::setOrdering(FABio::FAB_REVERSE_ORDER); - else if (ord == "REVERSE_ORDER_2") + } else if (ord == "REVERSE_ORDER_2") { FArrayBox::setOrdering(FABio::FAB_REVERSE_ORDER_2); - else - { + } else { amrex::ErrorStream() << "FArrayBox::init(): Bad FABio::Ordering = " << ord; amrex::Abort(); } @@ -472,11 +471,11 @@ FABio::read_header (std::istream& is, char c; is >> c; - if(c != 'F') amrex::Error("FABio::read_header(): expected \'F\'"); + if(c != 'F') { amrex::Error("FABio::read_header(): expected \'F\'"); } is >> c; - if(c != 'A') amrex::Error("FABio::read_header(): expected \'A\'"); + if(c != 'A') { amrex::Error("FABio::read_header(): expected \'A\'"); } is >> c; - if(c != 'B') amrex::Error("FABio::read_header(): expected \'B\'"); + if(c != 'B') { amrex::Error("FABio::read_header(): expected \'B\'"); } is >> c; if(c == ':') { // ---- The "old" FAB format. @@ -551,11 +550,11 @@ FABio::read_header (std::istream& is, char c; is >> c; - if(c != 'F') amrex::Error("FABio::read_header(): expected \'F\'"); + if(c != 'F') { amrex::Error("FABio::read_header(): expected \'F\'"); } is >> c; - if(c != 'A') amrex::Error("FABio::read_header(): expected \'A\'"); + if(c != 'A') { amrex::Error("FABio::read_header(): expected \'A\'"); } is >> c; - if(c != 'B') amrex::Error("FABio::read_header(): expected \'B\'"); + if(c != 'B') { amrex::Error("FABio::read_header(): expected \'B\'"); } is >> c; if(c == ':') { // ---- The "old" FAB format. diff --git a/Src/Base/AMReX_FBI.H b/Src/Base/AMReX_FBI.H index 4c7ba5ec4f0..e20f8bb4b79 100644 --- a/Src/Base/AMReX_FBI.H +++ b/Src/Base/AMReX_FBI.H @@ -212,7 +212,7 @@ FabArray::FB_local_copy_cpu (const FB& TheFB, int scomp, int ncomp) { auto const& LocTags = *(TheFB.m_LocTags); auto N_locs = static_cast(LocTags.size()); - if (N_locs == 0) return; + if (N_locs == 0) { return; } bool is_thread_safe = TheFB.m_threadsafe_loc; if (is_thread_safe) { @@ -273,7 +273,7 @@ FabArray::FB_local_copy_gpu (const FB& TheFB, int scomp, int ncomp) { auto const& LocTags = *(TheFB.m_LocTags); int N_locs = LocTags.size(); - if (N_locs == 0) return; + if (N_locs == 0) { return; } bool is_thread_safe = TheFB.m_threadsafe_loc; using TagType = Array4CopyTag; @@ -334,7 +334,7 @@ FabArray::CMD_local_setVal_gpu (typename FabArray::value_type x, { auto const& LocTags = *(thecmd.m_LocTags); int N_locs = LocTags.size(); - if (N_locs == 0) return; + if (N_locs == 0) { return; } bool is_thread_safe = thecmd.m_threadsafe_loc; using TagType = Array4BoxTag; @@ -374,7 +374,7 @@ FabArray::CMD_remote_setVal_gpu (typename FabArray::value_type x, } } - if (rcv_setval_tags.empty()) return; + if (rcv_setval_tags.empty()) { return; } AMREX_ALWAYS_ASSERT(amrex::IsStoreAtomic::value || is_thread_safe); @@ -561,7 +561,7 @@ FabArray::FB_pack_send_buffer_cuda_graph (const FB& TheFB, int scomp, int n Vector::CopyComTagsContainer const*> const& send_cctc) { const int N_snds = send_data.size(); - if (N_snds == 0) return; + if (N_snds == 0) { return; } if ( !(TheFB.m_copyToBuffer.ready()) ) { @@ -648,7 +648,7 @@ FabArray::FB_unpack_recv_buffer_cuda_graph (const FB& TheFB, int dcomp, int bool /*is_thread_safe*/) { const int N_rcvs = recv_cctc.size(); - if (N_rcvs == 0) return; + if (N_rcvs == 0) { return; } int launches = 0; LayoutData > recv_copy_tags(boxArray(),DistributionMap()); @@ -735,7 +735,7 @@ FabArray::pack_send_buffer_gpu (FabArray const& src, int scomp, int nc amrex::ignore_unused(send_size); const int N_snds = send_data.size(); - if (N_snds == 0) return; + if (N_snds == 0) { return; } char* pbuffer = send_data[0]; std::size_t szbuffer = 0; @@ -796,7 +796,7 @@ FabArray::unpack_recv_buffer_gpu (FabArray& dst, int dcomp, int ncomp, amrex::ignore_unused(recv_size); const int N_rcvs = recv_cctc.size(); - if (N_rcvs == 0) return; + if (N_rcvs == 0) { return; } char* pbuffer = recv_data[0]; #if 0 @@ -905,7 +905,7 @@ FabArray::pack_send_buffer_cpu (FabArray const& src, int scomp, int nc amrex::ignore_unused(send_size); auto const N_snds = static_cast(send_data.size()); - if (N_snds == 0) return; + if (N_snds == 0) { return; } #ifdef AMREX_USE_OMP #pragma omp parallel for @@ -945,7 +945,7 @@ FabArray::unpack_recv_buffer_cpu (FabArray& dst, int dcomp, int ncomp, amrex::ignore_unused(recv_size); auto const N_rcvs = static_cast(recv_cctc.size()); - if (N_rcvs == 0) return; + if (N_rcvs == 0) { return; } if (is_thread_safe) { diff --git a/Src/Base/AMReX_FabArray.H b/Src/Base/AMReX_FabArray.H index 2df4cf53ba2..59bb6b73807 100644 --- a/Src/Base/AMReX_FabArray.H +++ b/Src/Base/AMReX_FabArray.H @@ -1255,7 +1255,7 @@ protected: ~ShMem () { // NOLINT #if defined(BL_USE_MPI3) - if (win != MPI_WIN_NULL) MPI_Win_free(&win); + if (win != MPI_WIN_NULL) { MPI_Win_free(&win); } #endif #ifdef BL_USE_TEAM if (alloc) { @@ -1937,7 +1937,7 @@ template bool FabArray::ok () const { - if (!define_function_called) return false; + if (!define_function_called) { return false; } int isok = 1; @@ -3242,7 +3242,7 @@ FabArray::SumBoundary_nowait (int scomp, int ncomp, IntVect const& src_ngho { BL_PROFILE("FabArray::SumBoundary_nowait()"); - if ( n_grow == IntVect::TheZeroVector() && boxArray().ixType().cellCentered()) return; + if ( n_grow == IntVect::TheZeroVector() && boxArray().ixType().cellCentered()) { return; } AMREX_ASSERT(src_nghost <= n_grow); @@ -3262,7 +3262,7 @@ FabArray::SumBoundary_finish () BL_PROFILE("FabArray::SumBoundary_finish()"); // If pcd doesn't exist, ParallelCopy was all local and operation was fully completed in "SumBoundary_nowait". - if ( (n_grow == IntVect::TheZeroVector() && boxArray().ixType().cellCentered()) || !(this->pcd) ) return; + if ( (n_grow == IntVect::TheZeroVector() && boxArray().ixType().cellCentered()) || !(this->pcd) ) { return; } auto* tmp = const_cast*> (this->pcd->src); this->ParallelCopy_finish(); diff --git a/Src/Base/AMReX_FabArrayBase.H b/Src/Base/AMReX_FabArrayBase.H index a4c1407d36c..29d3d63b29e 100644 --- a/Src/Base/AMReX_FabArrayBase.H +++ b/Src/Base/AMReX_FabArrayBase.H @@ -409,7 +409,7 @@ public: RegionTag (RegionTag && rhs) noexcept : tagged(rhs.tagged) { rhs.tagged = false; } RegionTag& operator= (RegionTag const&) = delete; RegionTag& operator= (RegionTag &&) = delete; - ~RegionTag () { if (tagged) popRegionTag(); } + ~RegionTag () { if (tagged) { popRegionTag(); } } private: bool tagged = false; }; diff --git a/Src/Base/AMReX_FabArrayBase.cpp b/Src/Base/AMReX_FabArrayBase.cpp index e7b8e1977ae..8dd8275f66a 100644 --- a/Src/Base/AMReX_FabArrayBase.cpp +++ b/Src/Base/AMReX_FabArrayBase.cpp @@ -94,7 +94,7 @@ namespace void FabArrayBase::Initialize () { - if (initialized) return; + if (initialized) { return; } initialized = true; // @@ -108,12 +108,12 @@ FabArrayBase::Initialize () if (pp.queryarr("mfiter_tile_size", tilesize, 0, AMREX_SPACEDIM)) { - for (int i=0; i(sizeof(FabArrayBase::FB)); - if (m_LocTags) + if (m_LocTags) { cnt += amrex::bytesOf(*m_LocTags); + } - if (m_SndTags) + if (m_SndTags) { cnt += FabArrayBase::bytesOfMapOfCopyComTagContainers(*m_SndTags); + } - if (m_RcvTags) + if (m_RcvTags) { cnt += FabArrayBase::bytesOfMapOfCopyComTagContainers(*m_RcvTags); + } return cnt; } @@ -515,8 +521,9 @@ FabArrayBase::flushCPC (bool no_assertion) const std::pair o_er_it = m_TheCPCache.equal_range(otherkey); for (auto oit = o_er_it.first; oit != o_er_it.second; ++oit) { - if (it->second == oit->second) + if (it->second == oit->second) { others.push_back(oit); + } } } @@ -898,7 +905,7 @@ FabArrayBase::FB::define_epo (const FabArrayBase& fa) Box bxsnd = amrex::grow(ba[ksnd],ng); bxsnd &= pdomain; // source must be inside the periodic domain. - if (!bxsnd.ok()) continue; + if (!bxsnd.ok()) { continue; } for (auto const& pit : pshifts) { @@ -953,7 +960,7 @@ FabArrayBase::FB::define_epo (const FabArrayBase& fa) const Box& vbx = ba[krcv]; const Box& bxrcv = amrex::grow(vbx, ng); - if (pdomain.contains(bxrcv)) continue; + if (pdomain.contains(bxrcv)) { continue; } for (auto const& pit : pshifts) { @@ -1837,7 +1844,7 @@ FabArrayBase::FPinfo::FPinfo (const FabArrayBase& srcfa, amrex::AllGatherBoxes(bl.data()); } - if (bl.isEmpty()) return; + if (bl.isEmpty()) { return; } Long ncells_total = 0L; Long ncells_max = 0L; @@ -2010,8 +2017,9 @@ FabArrayBase::TheFPinfo (const FabArrayBase& srcfa, m_FPinfo_stats.recordUse(); m_TheFillPatchCache.insert(er_it.second, FPinfoCache::value_type(dstkey,new_fpc)); - if (srckey != dstkey) + if (srckey != dstkey) { m_TheFillPatchCache.insert( FPinfoCache::value_type(srckey,new_fpc)); + } return *new_fpc; } @@ -2040,8 +2048,9 @@ FabArrayBase::flushFPinfo (bool no_assertion) const for (auto oit = o_er_it.first; oit != o_er_it.second; ++oit) { - if (it->second == oit->second) + if (it->second == oit->second) { others.push_back(oit); + } } } diff --git a/Src/Base/AMReX_FabArrayCommI.H b/Src/Base/AMReX_FabArrayCommI.H index d79df73c7b6..ea877266f9a 100644 --- a/Src/Base/AMReX_FabArrayCommI.H +++ b/Src/Base/AMReX_FabArrayCommI.H @@ -34,7 +34,7 @@ FabArray::FBEP_nowait (int scomp, int ncomp, const IntVect& nghost, // There can only be local work to do. // int N_locs = (*TheFB.m_LocTags).size(); - if (N_locs == 0) return; + if (N_locs == 0) { return; } #ifdef AMREX_USE_GPU if (Gpu::inLaunchRegion()) { @@ -647,7 +647,7 @@ FabArray::PrepareSendBuffers (const MapOfCopyComTagContainers& SndTags, send_reqs.clear(); send_cctc.clear(); const auto N_snds = SndTags.size(); - if (N_snds == 0) return; + if (N_snds == 0) { return; } send_data.reserve(N_snds); send_size.reserve(N_snds); send_rank.reserve(N_snds); @@ -843,7 +843,7 @@ template void fbv_copy (Vector const& tags) { const int N = tags.size(); - if (N == 0) return; + if (N == 0) { return; } #ifdef AMREX_USE_GPU if (Gpu::inLaunchRegion()) { ParallelFor(tags, 1, @@ -941,7 +941,7 @@ FillBoundary (Vector const& mf, Vector const& scomp, int SeqNum = ParallelDescriptor::SeqNum(); MPI_Comm comm = ParallelContext::CommunicatorSub(); - if (N_locs == 0 && N_rcvs == 0 && N_snds == 0) return; // No work to do + if (N_locs == 0 && N_rcvs == 0 && N_snds == 0) { return; } // No work to do char* the_recv_data = nullptr; Vector recv_from; diff --git a/Src/Base/AMReX_FabArrayUtility.H b/Src/Base/AMReX_FabArrayUtility.H index 04c4fc47b28..f4aa73f2791 100644 --- a/Src/Base/AMReX_FabArrayUtility.H +++ b/Src/Base/AMReX_FabArrayUtility.H @@ -1313,7 +1313,7 @@ OverrideSync_nowait (FabArray & fa, FabArray const& msk, const Period BL_PROFILE("OverrideSync_nowait()"); AMREX_ASSERT_WITH_MESSAGE(!fa.os_temp, "OverrideSync_nowait() called when already in progress."); - if (fa.ixType().cellCentered()) return; + if (fa.ixType().cellCentered()) { return; } const int ncomp = fa.nComp(); @@ -1324,7 +1324,7 @@ OverrideSync_nowait (FabArray & fa, FabArray const& msk, const Period ParallelFor(fa, IntVect(0), ncomp, [=] AMREX_GPU_DEVICE (int box_no, int i, int j, int k, int n) noexcept { - if (!ifabarr[box_no](i,j,k)) fabarr[box_no](i,j,k,n) = 0; + if (!ifabarr[box_no](i,j,k)) { fabarr[box_no](i,j,k,n) = 0; } }); if (!Gpu::inNoSyncRegion()) { Gpu::streamSynchronize(); @@ -1342,7 +1342,7 @@ OverrideSync_nowait (FabArray & fa, FabArray const& msk, const Period auto const ifab = msk.array(mfi); AMREX_HOST_DEVICE_PARALLEL_FOR_4D( bx, ncomp, i, j, k, n, { - if (!ifab(i,j,k)) fab(i,j,k,n) = 0; + if (!ifab(i,j,k)) { fab(i,j,k,n) = 0; } }); } } @@ -1359,7 +1359,7 @@ OverrideSync_finish (FabArray & fa) { BL_PROFILE("OverrideSync_finish()"); - if (fa.ixType().cellCentered()) return; + if (fa.ixType().cellCentered()) { return; } fa.os_temp->ParallelCopy_finish(); amrex::Copy(fa, *(fa.os_temp), 0, 0, fa.nComp(), 0); @@ -1485,7 +1485,9 @@ indexFromValue (FabArray const& mf, int comp, IntVect const& nghost, auto const& fab = mf.const_array(mfi); AMREX_LOOP_3D(bx, i, j, k, { - if (fab(i,j,k,comp) == value) priv_loc = IntVect(AMREX_D_DECL(i,j,k)); + if (fab(i,j,k,comp) == value) { + priv_loc = IntVect(AMREX_D_DECL(i,j,k)); + } }); } @@ -1504,7 +1506,7 @@ indexFromValue (FabArray const& mf, int comp, IntVect const& nghost, f = true; } - if (old == false) loc = priv_loc; + if (old == false) { loc = priv_loc; } } } } diff --git a/Src/Base/AMReX_FabConv.cpp b/Src/Base/AMReX_FabConv.cpp index 6e015c083af..522216aadd1 100644 --- a/Src/Base/AMReX_FabConv.cpp +++ b/Src/Base/AMReX_FabConv.cpp @@ -68,20 +68,23 @@ operator>> (std::istream& is, { char c; is >> c; - if (c != '(') + if (c != '(') { amrex::Error("operator>>(istream&,RealDescriptor&): expected a \'(\'"); + } int numbytes; is >> numbytes; id.numbytes = numbytes; is >> c; - if (c != ',') + if (c != ',') { amrex::Error("operator>>(istream&,RealDescriptor&): expected a \',\'"); + } int ord; is >> ord; id.ord = (IntDescriptor::Ordering) ord; is >> c; - if (c != ')') + if (c != ')') { amrex::Error("operator>>(istream&,RealDescriptor&): expected a \')\'"); + } return is; } @@ -247,10 +250,9 @@ ONES_COMP_NEG (Long& n, int nb, Long incr) { - if (nb == 8*sizeof(Long)) + if (nb == 8*sizeof(Long)) { n = ~n + incr; - else - { + } else { const Long MSK = (1LL << nb) - 1LL; n = (~n + incr) & MSK; } @@ -272,10 +274,11 @@ _pd_get_bit (char const* base, n -= nbytes; offs = offs % 8; - if (ord == nullptr) + if (ord == nullptr) { base += (n + nbytes); - else + } else { base += (n + (ord[nbytes] - 1)); + } int mask = (1 << (7 - offs)); @@ -315,10 +318,9 @@ _pd_extract_field (char const* in, in += n; unsigned char bpb = 8 - offs; - if (ord == nullptr) + if (ord == nullptr) { ind = offy++; - else - { + } else { if (offy >= nby) { offy -= nby; @@ -331,19 +333,17 @@ _pd_extract_field (char const* in, unsigned char mask = (1 << bpb) - 1; bit_field = ((bit_field << bpb) | (tgt & mask)); nbi -= bpb; - if (nbi < 0) + if (nbi < 0) { bit_field = bit_field >> (-nbi); - else - { + } else { for (; nbi > 0; nbi -= bpb) { // // ind = (ord == nullptr) ? offy++ : (ord[offy++] - 1); // - if (ord == nullptr) + if (ord == nullptr) { ind = offy++; - else - { + } else { if (offy >= nby) { offy -= nby; @@ -427,10 +427,11 @@ _pd_insert_field (Long in_long, if (mi < offs) { dm = BitsMax - (8 - offs); - if (nb == BitsMax) + if (nb == BitsMax) { longmask = ~((1LL << dm) - 1LL); - else + } else { longmask = ((1LL << nb) - 1LL) ^ ((1LL << dm) - 1LL); + } unsigned char fb = ((in_long&longmask)>>dm)&((1LL<<(nb-dm))-1LL); *(out++) |= fb; // NOLINT @@ -499,9 +500,9 @@ _pd_reorder (char* arr, for (int j; nitems > 0; nitems--) { arr--; - for (j = 0; j < nbytes; local[j] = arr[ord[j]], j++); + for (j = 0; j < nbytes; local[j] = arr[ord[j]], j++) {;} arr++; - for (j = 0; j < nbytes; *(arr++) = local[j++]); + for (j = 0; j < nbytes; *(arr++) = local[j++]) {;} } } @@ -529,8 +530,9 @@ permute_real_word_order (void* out, for (; nitems > 0; nitems--, pin += REALSIZE, pout += REALSIZE) { - for (int i = 0; i < REALSIZE; i++) + for (int i = 0; i < REALSIZE; i++) { pout[outord[i]] = pin[inord[i]]; + } } } @@ -673,17 +675,20 @@ PD_fconvert (void* out, { ONES_COMP_NEG(expn, nbi_exp, 1L); } - else + else { expn += (expn < hexpn); + } } - if (expn != 0) + if (expn != 0) { expn += DeltaBias; + } if ((0 <= expn) && (expn < expn_max)) { _pd_insert_field(expn, nbo_exp, lout, bo_exp, l_order, l_bytes); - if (sign) + if (sign) { _pd_set_bit(lout, bo_sign); + } indxin = bi_mant; inrem = int(infor[2]); @@ -722,8 +727,9 @@ PD_fconvert (void* out, // // Do complement for negative ones complement data. // - if (onescmp && sign) + if (onescmp && sign) { ONES_COMP_NEG(mant, nbits, 0L); + } _pd_insert_field(mant, nbits, lout, indxout, l_order, l_bytes); @@ -740,8 +746,9 @@ PD_fconvert (void* out, { _pd_insert_field(expn_max, nbo_exp, lout, bo_exp, l_order, l_bytes); - if (_pd_get_bit(lin, bi_sign, inbytes, inord)) + if (_pd_get_bit(lin, bi_sign, inbytes, inord)) { _pd_set_bit(lout, bo_sign); + } } bi_sign += nbi; bi_exp += nbi; @@ -763,11 +770,14 @@ PD_fconvert (void* out, rout = (unsigned char *) out; for (i = 0L; i < nitems; i++, rout += outbytes) { - for (j = 0; j < outbytes; j++) - if ((j == indxout) ? (rout[j] != mask) : rout[j]) + for (j = 0; j < outbytes; j++) { + if ((j == indxout) ? (rout[j] != mask) : rout[j]) { break; - if (j == outbytes) + } + } + if (j == outbytes) { rout[indxout] = 0; + } } } // @@ -888,18 +898,21 @@ operator>> (std::istream& is, { char c; is >> c; - if (c != '(') + if (c != '(') { amrex::Error("operator>>(istream&,RealDescriptor&): expected a \'(\'"); + } Vector fmt; getarray(is, fmt); is >> c; - if (c != ',') + if (c != ',') { amrex::Error("operator>>(istream&,RealDescriptor&): expected a \',\'"); + } Vector ord; getarray(is, ord); is >> c; - if (c != ')') + if (c != ')') { amrex::Error("operator>>(istream&,RealDescriptor&): expected a \')\'"); + } rd = RealDescriptor(fmt.dataPtr(),ord.dataPtr(),static_cast(ord.size())); return is; } diff --git a/Src/Base/AMReX_Geometry.cpp b/Src/Base/AMReX_Geometry.cpp index ac30aba62c7..ace1eefa663 100644 --- a/Src/Base/AMReX_Geometry.cpp +++ b/Src/Base/AMReX_Geometry.cpp @@ -48,7 +48,7 @@ operator>> (std::istream& is, Geometry::Geometry () noexcept { - if (!AMReX::empty()) *this = DefaultGeometry(); + if (!AMReX::empty()) { *this = DefaultGeometry(); } } Geometry::Geometry (const Box& dom, const RealBox* rb, int coord, @@ -111,7 +111,7 @@ Geometry::Setup (const RealBox* rb, int coord, int const* isper) noexcept { Geometry* gg = AMReX::top()->getDefaultGeometry(); - if (gg->ok) return; + if (gg->ok) { return; } AMREX_ASSERT(!OpenMP::in_parallel()); @@ -146,8 +146,9 @@ Geometry::Setup (const RealBox* rb, int coord, int const* isper) noexcept if (read_prob_extent) { - for (int i = 0; i < AMREX_SPACEDIM; i++) + for (int i = 0; i < AMREX_SPACEDIM; i++) { prob_hi[i] = prob_lo[i] + prob_extent[i]; + } } gg->prob_domain.setLo(prob_lo); @@ -395,10 +396,12 @@ Geometry::periodicShift (const Box& target, int ri,rj,rk; for (ri = nist; ri <= niend; ri++) { - if (ri != 0 && !is_periodic[0]) + if (ri != 0 && !is_periodic[0]) { continue; - if (ri != 0 && is_periodic[0]) + } + if (ri != 0 && is_periodic[0]) { locsrc.shift(0,ri*domain.length(0)); + } for (rj = njst; rj <= njend; rj++) { @@ -438,8 +441,9 @@ Geometry::periodicShift (const Box& target, locsrc.shift(2,rk*domain.length(2)); } - if (ri == 0 && rj == 0 && rk == 0) + if (ri == 0 && rj == 0 && rk == 0) { continue; + } // // If losrc intersects target, then add to "out". // @@ -467,8 +471,9 @@ Geometry::periodicShift (const Box& target, locsrc.shift(1,-rj*domain.length(1)); } } - if (ri != 0 && is_periodic[0]) + if (ri != 0 && is_periodic[0]) { locsrc.shift(0,-ri*domain.length(0)); + } } } diff --git a/Src/Base/AMReX_GpuAsyncArray.H b/Src/Base/AMReX_GpuAsyncArray.H index 2258057e079..eda18a81dab 100644 --- a/Src/Base/AMReX_GpuAsyncArray.H +++ b/Src/Base/AMReX_GpuAsyncArray.H @@ -31,7 +31,7 @@ public: AsyncArray (T const* h_p, const std::size_t n) { - if (n == 0) return; + if (n == 0) { return; } h_data = static_cast(The_Pinned_Arena()->alloc(n*sizeof(T))); std::memcpy(h_data, h_p, n*sizeof(T)); #ifdef AMREX_USE_GPU @@ -46,7 +46,7 @@ public: template ::value && std::is_trivial::value,int>::type = 0> explicit AsyncArray (const std::size_t n) { - if (n == 0) return; + if (n == 0) { return; } #ifdef AMREX_USE_GPU if (Gpu::inLaunchRegion()) { @@ -120,7 +120,7 @@ public: void copyToHost (T* h_p, std::size_t n) const { - if (n == 0) return; + if (n == 0) { return; } #ifdef AMREX_USE_GPU if (d_data) { diff --git a/Src/Base/AMReX_GpuBuffer.H b/Src/Base/AMReX_GpuBuffer.H index 245a55910be..a52dc04785b 100644 --- a/Src/Base/AMReX_GpuBuffer.H +++ b/Src/Base/AMReX_GpuBuffer.H @@ -20,7 +20,7 @@ public: Buffer (std::initializer_list init) : m_size(init.size()) { - if (m_size == 0) return; + if (m_size == 0) { return; } #ifdef AMREX_USE_GPU h_data = static_cast(The_Pinned_Arena()->alloc(m_size*sizeof(T))); #else @@ -39,7 +39,7 @@ public: Buffer (T const* h_p, const std::size_t n) : m_size(n) { - if (m_size == 0) return; + if (m_size == 0) { return; } #ifdef AMREX_USE_GPU h_data = static_cast(The_Pinned_Arena()->alloc(m_size*sizeof(T))); #else @@ -73,8 +73,8 @@ public: void clear () { #ifdef AMREX_USE_GPU - if (d_data) The_Arena()->free(d_data); - if (h_data) The_Pinned_Arena()->free(h_data); + if (d_data) { The_Arena()->free(d_data); } + if (h_data) { The_Pinned_Arena()->free(h_data); } #else std::free(h_data); #endif diff --git a/Src/Base/AMReX_GpuComplex.H b/Src/Base/AMReX_GpuComplex.H index 5c9deab3995..4cf0d6e69c8 100644 --- a/Src/Base/AMReX_GpuComplex.H +++ b/Src/Base/AMReX_GpuComplex.H @@ -355,8 +355,7 @@ T abs (const GpuComplex& a_z) noexcept T y = a_z.imag(); const T s = amrex::max(std::abs(x), std::abs(y)); - if (s == T()) - return s; + if (s == T()) { return s; } x /= s; y /= s; return s * std::sqrt(x * x + y * y); @@ -414,8 +413,9 @@ template AMREX_GPU_HOST_DEVICE AMREX_FORCE_INLINE GpuComplex pow (const GpuComplex& a_z, const T& a_y) noexcept { - if (a_z.imag() == T() && a_z.real() > T()) + if (a_z.imag() == T() && a_z.real() > T()) { return std::pow(a_z.real(), a_y); + } GpuComplex t = amrex::log(a_z); return amrex::polar(std::exp(a_y * t.real()), a_y * t.imag()); @@ -432,8 +432,9 @@ namespace detail while (a_n >>= 1) { a_z *= a_z; - if (a_n % 2) + if (a_n % 2) { y *= a_z; + } } return y; diff --git a/Src/Base/AMReX_GpuContainers.H b/Src/Base/AMReX_GpuContainers.H index cb7b97acaf3..05399b2e047 100644 --- a/Src/Base/AMReX_GpuContainers.H +++ b/Src/Base/AMReX_GpuContainers.H @@ -129,7 +129,7 @@ namespace amrex::Gpu { "Can only copy trivially copyable types"); auto size = std::distance(begin, end); - if (size == 0) return; + if (size == 0) { return; } #ifdef AMREX_USE_GPU htod_memcpy(&(*result), &(*begin), size*sizeof(value_type)); #else @@ -166,7 +166,7 @@ namespace amrex::Gpu { "Can only copy trivially copyable types"); auto size = std::distance(begin, end); - if (size == 0) return; + if (size == 0) { return; } #ifdef AMREX_USE_GPU dtoh_memcpy(&(*result), &(*begin), size*sizeof(value_type)); #else @@ -203,7 +203,7 @@ namespace amrex::Gpu { "Can only copy trivially copyable types"); auto size = std::distance(begin, end); - if (size == 0) return; + if (size == 0) { return; } #ifdef AMREX_USE_GPU dtod_memcpy(&(*result), &(*begin), size*sizeof(value_type)); #else @@ -241,7 +241,7 @@ namespace amrex::Gpu { "Can only copy trivially copyable types"); auto size = std::distance(begin, end); - if (size == 0) return; + if (size == 0) { return; } #ifdef AMREX_USE_GPU htod_memcpy_async(&(*result), &(*begin), size*sizeof(value_type)); #else @@ -279,7 +279,7 @@ namespace amrex::Gpu { "Can only copy trivially copyable types"); auto size = std::distance(begin, end); - if (size == 0) return; + if (size == 0) { return; } #ifdef AMREX_USE_GPU dtoh_memcpy_async(&(*result), &(*begin), size*sizeof(value_type)); #else @@ -317,7 +317,7 @@ namespace amrex::Gpu { "Can only copy trivially copyable types"); auto size = std::distance(begin, end); - if (size == 0) return; + if (size == 0) { return; } #ifdef AMREX_USE_GPU dtod_memcpy_async(&(*result), &(*begin), size*sizeof(value_type)); #else @@ -339,7 +339,7 @@ namespace amrex::Gpu { "Can only copy trivially copyable types"); auto size = std::distance(begin, end); - if (size == 0) return; + if (size == 0) { return; } #ifdef AMREX_USE_GPU // Currently only implemented for CUDA. @@ -370,7 +370,7 @@ namespace amrex::Gpu { "Can only copy trivially copyable types"); auto size = std::distance(begin, end); - if (size == 0) return; + if (size == 0) { return; } #ifdef AMREX_USE_GPU // Currently only implemented for CUDA. @@ -411,7 +411,7 @@ namespace amrex::Gpu { void fillAsync (IT first, IT last, F&& f) noexcept { auto N = static_cast(std::distance(first, last)); - if (N <= 0) return; + if (N <= 0) { return; } auto p = &(*first); #ifndef AMREX_USE_GPU for (Long i = 0; i < N; ++i) { diff --git a/Src/Base/AMReX_GpuDevice.H b/Src/Base/AMReX_GpuDevice.H index 371bff773ca..20514aa367e 100644 --- a/Src/Base/AMReX_GpuDevice.H +++ b/Src/Base/AMReX_GpuDevice.H @@ -252,7 +252,7 @@ streamSynchronizeAll () noexcept inline void htod_memcpy_async (void* p_d, const void* p_h, const std::size_t sz) noexcept { - if (sz == 0) return; + if (sz == 0) { return; } #ifdef AMREX_USE_SYCL auto& q = Device::streamQueue(); q.submit([&] (sycl::handler& h) { h.memcpy(p_d, p_h, sz); }); @@ -266,7 +266,7 @@ htod_memcpy_async (void* p_d, const void* p_h, const std::size_t sz) noexcept inline void dtoh_memcpy_async (void* p_h, const void* p_d, const std::size_t sz) noexcept { - if (sz == 0) return; + if (sz == 0) { return; } #ifdef AMREX_USE_SYCL auto& q = Device::streamQueue(); q.submit([&] (sycl::handler& h) { h.memcpy(p_h, p_d, sz); }); @@ -280,7 +280,7 @@ dtoh_memcpy_async (void* p_h, const void* p_d, const std::size_t sz) noexcept inline void dtod_memcpy_async (void* p_d_dst, const void* p_d_src, const std::size_t sz) noexcept { - if (sz == 0) return; + if (sz == 0) { return; } #ifdef AMREX_USE_SYCL auto& q = Device::streamQueue(); q.submit([&] (sycl::handler& h) { h.memcpy(p_d_dst, p_d_src, sz); }); @@ -294,7 +294,7 @@ dtod_memcpy_async (void* p_d_dst, const void* p_d_src, const std::size_t sz) noe inline void htod_memcpy (void* p_d, const void* p_h, const std::size_t sz) noexcept { - if (sz == 0) return; + if (sz == 0) { return; } htod_memcpy_async(p_d, p_h, sz); Gpu::streamSynchronize(); } @@ -302,7 +302,7 @@ htod_memcpy (void* p_d, const void* p_h, const std::size_t sz) noexcept inline void dtoh_memcpy (void* p_h, const void* p_d, const std::size_t sz) noexcept { - if (sz == 0) return; + if (sz == 0) { return; } dtoh_memcpy_async(p_h, p_d, sz); Gpu::streamSynchronize(); } @@ -310,7 +310,7 @@ dtoh_memcpy (void* p_h, const void* p_d, const std::size_t sz) noexcept inline void dtod_memcpy (void* p_d_dst, const void* p_d_src, const std::size_t sz) noexcept { - if (sz == 0) return; + if (sz == 0) { return; } dtod_memcpy_async(p_d_dst, p_d_src, sz); Gpu::streamSynchronize(); } diff --git a/Src/Base/AMReX_GpuDevice.cpp b/Src/Base/AMReX_GpuDevice.cpp index a07acc591a2..df3625d13ce 100644 --- a/Src/Base/AMReX_GpuDevice.cpp +++ b/Src/Base/AMReX_GpuDevice.cpp @@ -473,7 +473,7 @@ Device::initialize_gpu () #endif } auto found = std::find(sgss.begin(), sgss.end(), static_cast(warp_size)); - if (found == sgss.end()) amrex::Abort("Incorrect subgroup size"); + if (found == sgss.end()) { amrex::Abort("Incorrect subgroup size"); } } #endif diff --git a/Src/Base/AMReX_GpuLaunchFunctsG.H b/Src/Base/AMReX_GpuLaunchFunctsG.H index 6c958f2070d..aea0c030152 100644 --- a/Src/Base/AMReX_GpuLaunchFunctsG.H +++ b/Src/Base/AMReX_GpuLaunchFunctsG.H @@ -114,7 +114,7 @@ void launch (int nblocks, gpuStream_t stream, L&& f) noexcept template void launch (T const& n, L&& f) noexcept { - if (amrex::isEmpty(n)) return; + if (amrex::isEmpty(n)) { return; } const auto ec = Gpu::makeExecutionConfig(n); int nthreads_per_block = ec.numThreads.x; int nthreads_total = nthreads_per_block * ec.numBlocks.x; @@ -190,7 +190,7 @@ namespace detail { template ::value> > void ParallelFor (Gpu::KernelInfo const& info, T n, L&& f) noexcept { - if (amrex::isEmpty(n)) return; + if (amrex::isEmpty(n)) { return; } const auto ec = Gpu::makeExecutionConfig(n); int nthreads_per_block = ec.numThreads.x; int nthreads_total = nthreads_per_block * ec.numBlocks.x; @@ -238,7 +238,7 @@ void ParallelFor (Gpu::KernelInfo const& info, T n, L&& f) noexcept template void ParallelFor (Gpu::KernelInfo const& info, Box const& box, L&& f) noexcept { - if (amrex::isEmpty(box)) return; + if (amrex::isEmpty(box)) { return; } int ncells = box.numPts(); const auto lo = amrex::lbound(box); const auto len = amrex::length(box); @@ -303,7 +303,7 @@ void ParallelFor (Gpu::KernelInfo const& info, Box const& box, L&& f) noexcept template ::value> > void ParallelFor (Gpu::KernelInfo const& info, Box const& box, T ncomp, L&& f) noexcept { - if (amrex::isEmpty(box)) return; + if (amrex::isEmpty(box)) { return; } int ncells = box.numPts(); const auto lo = amrex::lbound(box); const auto len = amrex::length(box); @@ -369,7 +369,7 @@ void ParallelFor (Gpu::KernelInfo const& info, Box const& box, T ncomp, L&& f) n template ::value> > void ParallelForRNG (T n, L&& f) noexcept { - if (amrex::isEmpty(n)) return; + if (amrex::isEmpty(n)) { return; } const auto ec = Gpu::ExecutionConfig(n); int nthreads_per_block = ec.numThreads.x; int nthreads_total = nthreads_per_block * amrex::min(ec.numBlocks.x,Gpu::Device::maxBlocksPerLaunch()); @@ -402,7 +402,7 @@ void ParallelForRNG (T n, L&& f) noexcept template void ParallelForRNG (Box const& box, L&& f) noexcept { - if (amrex::isEmpty(box)) return; + if (amrex::isEmpty(box)) { return; } int ncells = box.numPts(); const auto lo = amrex::lbound(box); const auto len = amrex::length(box); @@ -447,7 +447,7 @@ void ParallelForRNG (Box const& box, L&& f) noexcept template ::value> > void ParallelForRNG (Box const& box, T ncomp, L&& f) noexcept { - if (amrex::isEmpty(box)) return; + if (amrex::isEmpty(box)) { return; } int ncells = box.numPts(); const auto lo = amrex::lbound(box); const auto len = amrex::length(box); @@ -494,7 +494,7 @@ void ParallelForRNG (Box const& box, T ncomp, L&& f) noexcept template void ParallelFor (Gpu::KernelInfo const& /*info*/, Box const& box1, Box const& box2, L1&& f1, L2&& f2) noexcept { - if (amrex::isEmpty(box1) && amrex::isEmpty(box2)) return; + if (amrex::isEmpty(box1) && amrex::isEmpty(box2)) { return; } int ncells1 = box1.numPts(); int ncells2 = box2.numPts(); int ncells = amrex::max(ncells1, ncells2); @@ -551,7 +551,7 @@ void ParallelFor (Gpu::KernelInfo const& /*info*/, Box const& box1, Box const& box2, Box const& box3, L1&& f1, L2&& f2, L3&& f3) noexcept { - if (amrex::isEmpty(box1) && amrex::isEmpty(box2) && amrex::isEmpty(box3)) return; + if (amrex::isEmpty(box1) && amrex::isEmpty(box2) && amrex::isEmpty(box3)) { return; } int ncells1 = box1.numPts(); int ncells2 = box2.numPts(); int ncells3 = box3.numPts(); @@ -624,7 +624,7 @@ void ParallelFor (Gpu::KernelInfo const& /*info*/, Box const& box1, T1 ncomp1, L1&& f1, Box const& box2, T2 ncomp2, L2&& f2) noexcept { - if (amrex::isEmpty(box1) && amrex::isEmpty(box2)) return; + if (amrex::isEmpty(box1) && amrex::isEmpty(box2)) { return; } int ncells1 = box1.numPts(); int ncells2 = box2.numPts(); int ncells = amrex::max(ncells1, ncells2); @@ -689,7 +689,7 @@ void ParallelFor (Gpu::KernelInfo const& /*info*/, Box const& box2, T2 ncomp2, L2&& f2, Box const& box3, T3 ncomp3, L3&& f3) noexcept { - if (amrex::isEmpty(box1) && amrex::isEmpty(box2) && amrex::isEmpty(box3)) return; + if (amrex::isEmpty(box1) && amrex::isEmpty(box2) && amrex::isEmpty(box3)) { return; } int ncells1 = box1.numPts(); int ncells2 = box2.numPts(); int ncells3 = box3.numPts(); @@ -808,7 +808,7 @@ void launch (int nblocks, int nthreads_per_block, gpuStream_t stream, L&& f) noe template void launch (T const& n, L&& f) noexcept { - if (amrex::isEmpty(n)) return; + if (amrex::isEmpty(n)) { return; } const auto ec = Gpu::makeExecutionConfig(n); AMREX_LAUNCH_KERNEL(MT, ec.numBlocks, ec.numThreads, 0, Gpu::gpuStream(), [=] AMREX_GPU_DEVICE () noexcept { @@ -873,7 +873,7 @@ template ::value> ParallelFor (Gpu::KernelInfo const&, T n, L&& f) noexcept { - if (amrex::isEmpty(n)) return; + if (amrex::isEmpty(n)) { return; } const auto ec = Gpu::makeExecutionConfig(n); AMREX_LAUNCH_KERNEL(MT, ec.numBlocks, ec.numThreads, 0, Gpu::gpuStream(), [=] AMREX_GPU_DEVICE () noexcept { @@ -889,7 +889,7 @@ template std::enable_if_t::value> ParallelFor (Gpu::KernelInfo const&, Box const& box, L&& f) noexcept { - if (amrex::isEmpty(box)) return; + if (amrex::isEmpty(box)) { return; } int ncells = box.numPts(); const auto lo = amrex::lbound(box); const auto len = amrex::length(box); @@ -917,7 +917,7 @@ template ::value> ParallelFor (Gpu::KernelInfo const&, Box const& box, T ncomp, L&& f) noexcept { - if (amrex::isEmpty(box)) return; + if (amrex::isEmpty(box)) { return; } int ncells = box.numPts(); const auto lo = amrex::lbound(box); const auto len = amrex::length(box); @@ -944,7 +944,7 @@ template ::value> ParallelForRNG (T n, L&& f) noexcept { - if (amrex::isEmpty(n)) return; + if (amrex::isEmpty(n)) { return; } randState_t* rand_state = getRandState(); const auto ec = Gpu::ExecutionConfig(n); AMREX_LAUNCH_KERNEL(AMREX_GPU_MAX_THREADS, @@ -965,7 +965,7 @@ template std::enable_if_t::value> ParallelForRNG (Box const& box, L&& f) noexcept { - if (amrex::isEmpty(box)) return; + if (amrex::isEmpty(box)) { return; } randState_t* rand_state = getRandState(); int ncells = box.numPts(); const auto lo = amrex::lbound(box); @@ -997,7 +997,7 @@ template ::value> ParallelForRNG (Box const& box, T ncomp, L&& f) noexcept { - if (amrex::isEmpty(box)) return; + if (amrex::isEmpty(box)) { return; } randState_t* rand_state = getRandState(); int ncells = box.numPts(); const auto lo = amrex::lbound(box); @@ -1032,7 +1032,7 @@ std::enable_if_t::value && MaybeDeviceRunnable::valu ParallelFor (Gpu::KernelInfo const&, Box const& box1, Box const& box2, L1&& f1, L2&& f2) noexcept { - if (amrex::isEmpty(box1) && amrex::isEmpty(box2)) return; + if (amrex::isEmpty(box1) && amrex::isEmpty(box2)) { return; } int ncells1 = box1.numPts(); int ncells2 = box2.numPts(); int ncells = amrex::max(ncells1, ncells2); @@ -1078,7 +1078,7 @@ ParallelFor (Gpu::KernelInfo const&, Box const& box1, Box const& box2, Box const& box3, L1&& f1, L2&& f2, L3&& f3) noexcept { - if (amrex::isEmpty(box1) && amrex::isEmpty(box2) && amrex::isEmpty(box3)) return; + if (amrex::isEmpty(box1) && amrex::isEmpty(box2) && amrex::isEmpty(box3)) { return; } int ncells1 = box1.numPts(); int ncells2 = box2.numPts(); int ncells3 = box3.numPts(); @@ -1140,7 +1140,7 @@ ParallelFor (Gpu::KernelInfo const&, Box const& box1, T1 ncomp1, L1&& f1, Box const& box2, T2 ncomp2, L2&& f2) noexcept { - if (amrex::isEmpty(box1) && amrex::isEmpty(box2)) return; + if (amrex::isEmpty(box1) && amrex::isEmpty(box2)) { return; } int ncells1 = box1.numPts(); int ncells2 = box2.numPts(); int ncells = amrex::max(ncells1, ncells2); @@ -1194,7 +1194,7 @@ ParallelFor (Gpu::KernelInfo const&, Box const& box2, T2 ncomp2, L2&& f2, Box const& box3, T3 ncomp3, L3&& f3) noexcept { - if (amrex::isEmpty(box1) && amrex::isEmpty(box2) && amrex::isEmpty(box3)) return; + if (amrex::isEmpty(box1) && amrex::isEmpty(box2) && amrex::isEmpty(box3)) { return; } int ncells1 = box1.numPts(); int ncells2 = box2.numPts(); int ncells3 = box3.numPts(); diff --git a/Src/Base/AMReX_GpuMemory.H b/Src/Base/AMReX_GpuMemory.H index 88005b82596..1ffee387015 100644 --- a/Src/Base/AMReX_GpuMemory.H +++ b/Src/Base/AMReX_GpuMemory.H @@ -22,7 +22,7 @@ struct Managed { void operator delete (void *ptr) { - if (ptr) The_Managed_Arena()->free(ptr); + if (ptr) { The_Managed_Arena()->free(ptr); } } #endif @@ -39,7 +39,7 @@ struct Pinned { void operator delete (void *ptr) { - if (ptr) The_Pinned_Arena()->free(ptr); + if (ptr) { The_Pinned_Arena()->free(ptr); } } #endif diff --git a/Src/Base/AMReX_IArrayBox.cpp b/Src/Base/AMReX_IArrayBox.cpp index 6f751cf610c..40b2762729d 100644 --- a/Src/Base/AMReX_IArrayBox.cpp +++ b/Src/Base/AMReX_IArrayBox.cpp @@ -31,7 +31,7 @@ namespace void IArrayBox::Initialize () { - if (initialized) return; + if (initialized) { return; } // ParmParse pp("iab"); ifabio = std::make_unique(); diff --git a/Src/Base/AMReX_IndexType.cpp b/Src/Base/AMReX_IndexType.cpp index 00ba0a0b10f..e96052a4d14 100644 --- a/Src/Base/AMReX_IndexType.cpp +++ b/Src/Base/AMReX_IndexType.cpp @@ -15,8 +15,9 @@ operator<< (std::ostream& os, << ',' << (it.test(1)?'N':'C'), << ',' << (it.test(2)?'N':'C')) << ')' << std::flush; - if (os.fail()) + if (os.fail()) { amrex::Error("operator<<(ostream&,IndexType&) failed"); + } return os; } @@ -41,8 +42,9 @@ operator>> (std::istream& is, BL_ASSERT(t1 == 'C' || t1 == 'N'); t1=='N'?it.set(1):it.unset(1); , BL_ASSERT(t2 == 'C' || t2 == 'N'); t2=='N'?it.set(2):it.unset(2)); - if (is.fail()) + if (is.fail()) { amrex::Error("operator>>(ostream&,IndexType&) failed"); + } return is; } diff --git a/Src/Base/AMReX_IntConv.H b/Src/Base/AMReX_IntConv.H index 0a108fffe13..f792f4b8eab 100644 --- a/Src/Base/AMReX_IntConv.H +++ b/Src/Base/AMReX_IntConv.H @@ -27,7 +27,7 @@ namespace amrex { bool swapEndian = (id.order() != amrex::FPC::NativeIntDescriptor().order()); for (std::size_t j = 0; j < size; ++j) { value = static_cast(data[j]); - if (swapEndian) value = swapBytes(value); + if (swapEndian) { value = swapBytes(value); } os.write((char*) &value, sizeof(To)); } } @@ -40,7 +40,7 @@ namespace amrex { bool swapEndian = (id.order() != amrex::FPC::NativeIntDescriptor().order()); for (std::size_t j = 0; j < size; ++j) { is.read((char*) &value, sizeof(From)); - if (swapEndian) value = swapBytes(value); + if (swapEndian) { value = swapBytes(value); } data[j] = static_cast(value); } } diff --git a/Src/Base/AMReX_IntVect.cpp b/Src/Base/AMReX_IntVect.cpp index 3d0bf0b6eb5..5e68f633d19 100644 --- a/Src/Base/AMReX_IntVect.cpp +++ b/Src/Base/AMReX_IntVect.cpp @@ -61,8 +61,9 @@ operator>> (std::istream& is, IntVect& iv) amrex::Error("operator>>(istream&,IntVect&): expected \'(\'"); } - if (is.fail()) + if (is.fail()) { amrex::Error("operator>>(istream&,IntVect&) failed"); + } return is; } diff --git a/Src/Base/AMReX_LayoutData.H b/Src/Base/AMReX_LayoutData.H index 57b8194d0b3..aaa1db98135 100644 --- a/Src/Base/AMReX_LayoutData.H +++ b/Src/Base/AMReX_LayoutData.H @@ -31,14 +31,14 @@ namespace amrex m_data.resize(local_size()); } - ~LayoutData () { if (m_need_to_clear_bd) clearThisBD(); } + ~LayoutData () { if (m_need_to_clear_bd) { clearThisBD(); } } LayoutData (const LayoutData& rhs) noexcept : FabArrayBase(rhs), m_data(rhs.m_data), m_need_to_clear_bd(rhs.m_need_to_clear_bd) { - if (m_need_to_clear_bd) addThisBD(); + if (m_need_to_clear_bd) { addThisBD(); } } LayoutData (LayoutData&& rhs) noexcept @@ -54,13 +54,13 @@ namespace amrex if (&rhs != this) { m_data.clear(); - if (m_need_to_clear_bd) clearThisBD(); + if (m_need_to_clear_bd) { clearThisBD(); } FabArrayBase::operator=(rhs); m_data = rhs.m_data; m_need_to_clear_bd = rhs.m_need_to_clear_bd; - if (m_need_to_clear_bd) addThisBD(); + if (m_need_to_clear_bd) { addThisBD(); } } return *this; } @@ -70,7 +70,7 @@ namespace amrex if (&rhs != this) { m_data.clear(); - if (m_need_to_clear_bd) clearThisBD(); + if (m_need_to_clear_bd) { clearThisBD(); } FabArrayBase::operator=(static_cast(rhs)); m_data = std::move(rhs.m_data); diff --git a/Src/Base/AMReX_Lazy.cpp b/Src/Base/AMReX_Lazy.cpp index 7e4d6e5bd7a..9f2fae500bd 100644 --- a/Src/Base/AMReX_Lazy.cpp +++ b/Src/Base/AMReX_Lazy.cpp @@ -9,8 +9,9 @@ namespace amrex::Lazy #ifdef BL_USE_MPI reduction_queue.push_back(f); const int max_queue_size = 64; - if (reduction_queue.size() >= max_queue_size) + if (reduction_queue.size() >= max_queue_size) { EvalReduction(); + } #else f(); #endif @@ -22,8 +23,9 @@ namespace amrex::Lazy static int count = 0; ++count; if (count == 1) { - for (auto&& f : reduction_queue) + for (auto&& f : reduction_queue) { f(); + } reduction_queue.clear(); count = 0; } diff --git a/Src/Base/AMReX_MFIter.cpp b/Src/Base/AMReX_MFIter.cpp index 5ae34d30a81..b05d0bbb2af 100644 --- a/Src/Base/AMReX_MFIter.cpp +++ b/Src/Base/AMReX_MFIter.cpp @@ -216,7 +216,7 @@ void MFIter::Finalize () { // avoid double finalize - if (finalized) return; + if (finalized) { return; } finalized = true; // mark as invalid @@ -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; d const& mf, int icomp, int ncomp) const { const auto N_snds = static_cast(m_SndTags.size()); - if (N_snds == 0) return; + if (N_snds == 0) { return; } // Prepare buffer @@ -108,7 +108,7 @@ void Copier::recv (FabArray& mf, int icomp, int ncomp) const { const auto N_rcvs = static_cast(m_RcvTags.size()); - if (N_rcvs == 0) return; + if (N_rcvs == 0) { return; } // Prepare buffer diff --git a/Src/Base/AMReX_Machine.cpp b/Src/Base/AMReX_Machine.cpp index e8e3c955962..bcb420b3f67 100644 --- a/Src/Base/AMReX_Machine.cpp +++ b/Src/Base/AMReX_Machine.cpp @@ -98,7 +98,7 @@ std::string to_str (const Array & a) oss << "("; bool first = true; for (auto const& item : a) { - if (!first) oss << ","; + if (!first) { oss << ","; } oss << item; first = false; } @@ -113,7 +113,7 @@ std::string to_str (const Vector & v) oss << "("; bool first = true; for (auto const& item : v) { - if (!first) oss << ","; + if (!first) { oss << ","; } oss << item; first = false; } @@ -382,8 +382,9 @@ class Machine Print() << "Got node ID from SLURM_TOPOLOGY_ADDR: " << result << std::endl; } } else { - if (cluster_name == "escori") + if (cluster_name == "escori") { tag = "cgpu"; + } auto mpi_proc_name = get_mpi_processor_name(); Print() << "MPI_Get_processor_name: " << mpi_proc_name << std::endl; pos = mpi_proc_name.find(tag); diff --git a/Src/Base/AMReX_Math.H b/Src/Base/AMReX_Math.H index 7713bab56f8..769b9bf50f4 100644 --- a/Src/Base/AMReX_Math.H +++ b/Src/Base/AMReX_Math.H @@ -188,19 +188,20 @@ template (x); - else if constexpr (Power == 0) + } else if constexpr (Power == 0) { //note: 0^0 is implementation-defined, but most compilers return 1 return T(1); - else if constexpr (Power == 1) + } else if constexpr (Power == 1) { return x; - else if constexpr (Power == 2) + } else if constexpr (Power == 2) { return x*x; - else if constexpr (Power%2 == 0) + } else if constexpr (Power%2 == 0) { return powi<2>(powi(x)); - else + } else { return x*powi(x); + } } } diff --git a/Src/Base/AMReX_MemPool.cpp b/Src/Base/AMReX_MemPool.cpp index 7c31e0412a7..e1e26ce7b6d 100644 --- a/Src/Base/AMReX_MemPool.cpp +++ b/Src/Base/AMReX_MemPool.cpp @@ -109,7 +109,7 @@ void amrex_mempool_get_stats (int& mp_min, int& mp_max, int& mp_tot) // min, max void amrex_real_array_init (Real* p, size_t nelems) { - if (init_snan) amrex_array_init_snan(p, nelems); + if (init_snan) { amrex_array_init_snan(p, nelems); } } void amrex_array_init_snan (Real* p, size_t nelems) diff --git a/Src/Base/AMReX_MemProfiler.cpp b/Src/Base/AMReX_MemProfiler.cpp index 223a5dad1ba..a6326ec9412 100644 --- a/Src/Base/AMReX_MemProfiler.cpp +++ b/Src/Base/AMReX_MemProfiler.cpp @@ -159,7 +159,7 @@ MemProfiler::report_ (const std::string& prefix, const std::string& memory_log_n } } ifs.ignore(std::numeric_limits::max(), '\n'); - if (nfound == npstat) break; + if (nfound == npstat) { break; } } } @@ -201,23 +201,23 @@ MemProfiler::report_ (const std::string& prefix, const std::string& memory_log_n #endif const int IOProc = ParallelDescriptor::IOProcessorNumber(); - ParallelDescriptor::ReduceLongMin(&cur_min[0], cur_min.size(), IOProc); - ParallelDescriptor::ReduceLongMax(&cur_max[0], cur_max.size(), IOProc); - ParallelDescriptor::ReduceLongMin(&hwm_min[0], hwm_min.size(), IOProc); - ParallelDescriptor::ReduceLongMax(&hwm_max[0], hwm_max.size(), IOProc); - ParallelDescriptor::ReduceLongMin(&mymin[0], N, IOProc); - ParallelDescriptor::ReduceLongMax(&mymax[0], N, IOProc); - - ParallelDescriptor::ReduceIntMin (&num_builds_min[0], num_builds_min.size(), IOProc); - ParallelDescriptor::ReduceIntMax (&num_builds_max[0], num_builds_max.size(), IOProc); - ParallelDescriptor::ReduceIntMin (&hwm_builds_min[0], hwm_builds_min.size(), IOProc); - ParallelDescriptor::ReduceIntMax (&hwm_builds_max[0], hwm_builds_max.size(), IOProc); + ParallelDescriptor::ReduceLongMin(cur_min.data(), cur_min.size(), IOProc); + ParallelDescriptor::ReduceLongMax(cur_max.data(), cur_max.size(), IOProc); + ParallelDescriptor::ReduceLongMin(hwm_min.data(), hwm_min.size(), IOProc); + ParallelDescriptor::ReduceLongMax(hwm_max.data(), hwm_max.size(), IOProc); + ParallelDescriptor::ReduceLongMin(mymin.data(), N, IOProc); + ParallelDescriptor::ReduceLongMax(mymax.data(), N, IOProc); + + ParallelDescriptor::ReduceIntMin (num_builds_min.data(), num_builds_min.size(), IOProc); + ParallelDescriptor::ReduceIntMax (num_builds_max.data(), num_builds_max.size(), IOProc); + ParallelDescriptor::ReduceIntMin (hwm_builds_min.data(), hwm_builds_min.size(), IOProc); + ParallelDescriptor::ReduceIntMax (hwm_builds_max.data(), hwm_builds_max.size(), IOProc); if (ParallelDescriptor::IOProcessor()) { std::ofstream memlog(memory_log_name.c_str(), std::ofstream::out|std::ofstream::app); - if (!memlog.good()) return; + if (!memlog.good()) { return; } static int width_name = 0; if (width_name == 0) { diff --git a/Src/Base/AMReX_MultiFab.cpp b/Src/Base/AMReX_MultiFab.cpp index a77d01d6375..15f9490b1c2 100644 --- a/Src/Base/AMReX_MultiFab.cpp +++ b/Src/Base/AMReX_MultiFab.cpp @@ -452,7 +452,7 @@ MultiFab::negate (const Box& region, int nghost) void MultiFab::Initialize () { - if (initialized) return; + if (initialized) { return; } initialized = true; amrex::ExecOnFinalize(MultiFab::Finalize); @@ -506,7 +506,7 @@ MultiFab::MultiFab (const BoxArray& bxs, : FabArray(bxs,dm,ncomp,ngrow,info,factory) { - if (SharedMemory() && info.alloc) initVal(); // else already done in FArrayBox + if (SharedMemory() && info.alloc) { initVal(); } // else already done in FArrayBox #ifdef AMREX_MEM_PROFILING ++num_multifabs; num_multifabs_hwm = std::max(num_multifabs_hwm, num_multifabs); @@ -555,7 +555,7 @@ MultiFab::define (const BoxArray& bxs, const FabFactory& factory) { define(bxs, dm, nvar, IntVect(ngrow), info, factory); - if (SharedMemory() && info.alloc) initVal(); // else already done in FArrayBox + if (SharedMemory() && info.alloc) { initVal(); } // else already done in FArrayBox } void @@ -567,7 +567,7 @@ MultiFab::define (const BoxArray& bxs, const FabFactory& factory) { this->FabArray::define(bxs,dm,nvar,ngrow,info,factory); - if (SharedMemory() && info.alloc) initVal(); // else already done in FArrayBox + if (SharedMemory() && info.alloc) { initVal(); } // else already done in FArrayBox } void @@ -1112,8 +1112,9 @@ MultiFab::norm1 (int comp, const Periodicity& period, bool ignore_covered ) cons MultiFab::Copy(tmpmf, *this, comp, 0, 1, 0); #ifdef AMREX_USE_EB - if ( this -> hasEBFabFactory() && ignore_covered ) + if ( this -> hasEBFabFactory() && ignore_covered ) { EB_set_covered( tmpmf, Real(0.0) ); + } #endif auto mask = OverlapMask(period); @@ -1173,8 +1174,9 @@ MultiFab::norm1 (const Vector& comps, int ngrow, bool local) const nm1.push_back(this->norm1(comp, ngrow, true)); } - if (!local) + if (!local) { ParallelAllReduce::Sum(nm1.dataPtr(), n, ParallelContext::CommunicatorSub()); + } return nm1; } @@ -1193,8 +1195,9 @@ MultiFab::sum_unique (int comp, BL_PROFILE("MultiFab::sum_unique()"); // no duplicatly distributed points if cell centered - if (ixType().cellCentered()) + if (ixType().cellCentered()) { return this->sum(comp, local); + } // Owner is the grid with the lowest grid number containing the data std::unique_ptr owner_mask = OwnerMask(period); @@ -1411,7 +1414,7 @@ MultiFab::AverageSync (const Periodicity& period) { BL_PROFILE("MultiFab::AverageSync()"); - if (ixType().cellCentered()) return; + if (ixType().cellCentered()) { return; } auto wgt = this->OverlapMask(period); wgt->invert(1.0, 0, 1); this->WeightedSync(*wgt, period); @@ -1422,7 +1425,7 @@ MultiFab::WeightedSync (const MultiFab& wgt, const Periodicity& period) { BL_PROFILE("MultiFab::WeightedSync()"); - if (ixType().cellCentered()) return; + if (ixType().cellCentered()) { return; } const int ncomp = nComp(); for (int comp = 0; comp < ncomp; ++comp) diff --git a/Src/Base/AMReX_MultiFabUtil.H b/Src/Base/AMReX_MultiFabUtil.H index 8c499874a83..3e0d6bf7d9f 100644 --- a/Src/Base/AMReX_MultiFabUtil.H +++ b/Src/Base/AMReX_MultiFabUtil.H @@ -844,7 +844,7 @@ void average_down_faces (const FabArray& fine, FabArray& crse, const auto type = fine.ixType(); int dir; for (dir = 0; dir < AMREX_SPACEDIM; ++dir) { - if (type.nodeCentered(dir)) break; + if (type.nodeCentered(dir)) { break; } } auto tmptype = type; tmptype.unset(dir); diff --git a/Src/Base/AMReX_MultiFabUtil.cpp b/Src/Base/AMReX_MultiFabUtil.cpp index e3cbae4bb05..201561150e8 100644 --- a/Src/Base/AMReX_MultiFabUtil.cpp +++ b/Src/Base/AMReX_MultiFabUtil.cpp @@ -45,7 +45,7 @@ namespace { boxes.push_back(is.second); slice_to_full_ba_map.push_back(is.first); } - BoxArray slice_ba(&boxes[0], static_cast(boxes.size())); + BoxArray slice_ba(boxes.data(), static_cast(boxes.size())); DistributionMapping slice_dmap(std::move(procs)); return std::make_unique(slice_ba, slice_dmap, ncomp, 0, @@ -470,7 +470,7 @@ namespace amrex const auto type = fine.ixType(); int dir; for (dir = 0; dir < AMREX_SPACEDIM; ++dir) { - if (type.cellCentered(dir)) break; + if (type.cellCentered(dir)) { break; } } auto tmptype = type; tmptype.set(dir); diff --git a/Src/Base/AMReX_MultiFabUtilI.H b/Src/Base/AMReX_MultiFabUtilI.H index 9696a2d888a..cb7e8892ee1 100644 --- a/Src/Base/AMReX_MultiFabUtilI.H +++ b/Src/Base/AMReX_MultiFabUtilI.H @@ -94,8 +94,8 @@ namespace amrex::MFUtil { int nc = mf_in.nComp(); mf_out.define(ba, dm, nc, ng); - if (regrid_ghost) SymmetricGhost::copy(mf_out, mf_in, nc, ng); - else AsymmetricGhost::copy(mf_out, mf_in, nc, ng); + if (regrid_ghost) { SymmetricGhost::copy(mf_out, mf_in, nc, ng); } + else { AsymmetricGhost::copy(mf_out, mf_in, nc, ng); } } @@ -112,8 +112,8 @@ namespace amrex::MFUtil { int nc = mf_in.nComp(); mf_out.define(ba, dm, nc, ng, MFInfo(), eb_factory); - if (regrid_ghost) SymmetricGhost::copy(mf_out, mf_in, nc, ng); - else AsymmetricGhost::copy(mf_out, mf_in, nc, ng); + if (regrid_ghost) { SymmetricGhost::copy(mf_out, mf_in, nc, ng); } + else { AsymmetricGhost::copy(mf_out, mf_in, nc, ng); } } } diff --git a/Src/Base/AMReX_NonLocalBC.cpp b/Src/Base/AMReX_NonLocalBC.cpp index 109a77d1e54..ebd78f7b3d1 100644 --- a/Src/Base/AMReX_NonLocalBC.cpp +++ b/Src/Base/AMReX_NonLocalBC.cpp @@ -51,7 +51,7 @@ void PrepareCommBuffers(CommData& comm, comm.stats.clear(); const auto N_comms = static_cast(cctc.size()); - if (N_comms == 0) return; + if (N_comms == 0) { return; } // reserve for upcominf push_backs comm.data.reserve(N_comms); comm.size.reserve(N_comms); diff --git a/Src/Base/AMReX_NonLocalBCImpl.H b/Src/Base/AMReX_NonLocalBCImpl.H index ab2a0dfb978..60798f85a34 100644 --- a/Src/Base/AMReX_NonLocalBCImpl.H +++ b/Src/Base/AMReX_NonLocalBCImpl.H @@ -188,7 +188,7 @@ std::enable_if_t() && IsCallableR() && IsFabPro local_copy_cpu (FabArray& dest, const FabArray& src, int dcomp, int scomp, int ncomp, FabArrayBase::CopyComTagsContainer const& local_tags, DTOS const& dtos, Proj const& proj) noexcept { const auto N_locs = static_cast(local_tags.size()); - if (N_locs == 0) return; + if (N_locs == 0) { return; } #ifdef AMREX_USE_OMP #pragma omp parallel for #endif @@ -218,7 +218,7 @@ unpack_recv_buffer_cpu (FabArray& mf, int dcomp, int ncomp, Vector c amrex::ignore_unused(recv_size); const auto N_rcvs = static_cast(recv_cctc.size()); - if (N_rcvs == 0) return; + if (N_rcvs == 0) { return; } using T = typename FAB::value_type; #ifdef AMREX_USE_OMP @@ -256,7 +256,7 @@ std::enable_if_t() && IsCallableR() && IsFabPro local_copy_gpu (FabArray& dest, const FabArray& src, int dcomp, int scomp, int ncomp, FabArrayBase::CopyComTagsContainer const& local_tags, DTOS const& dtos, Proj const& proj) noexcept { int N_locs = local_tags.size(); - if (N_locs == 0) return; + if (N_locs == 0) { return; } using T = typename FAB::value_type; Vector > loc_copy_tags; @@ -284,7 +284,7 @@ unpack_recv_buffer_gpu (FabArray& mf, int scomp, int ncomp, amrex::ignore_unused(recv_size); const int N_rcvs = recv_cctc.size(); - if (N_rcvs == 0) return; + if (N_rcvs == 0) { return; } char* pbuffer = recv_data[0]; #if 0 @@ -484,7 +484,7 @@ void Comm_finish (FabArray& mf, int scomp, int ncomp, FabArrayBase::CommMetaData const& cmd, CommHandler handler, DTOS const& dtos, Proj const& proj) { - if (ParallelContext::NProcsSub() == 1) return; + if (ParallelContext::NProcsSub() == 1) { return; } const auto N_rcvs = static_cast(cmd.m_RcvTags->size()); if (N_rcvs > 0) @@ -535,7 +535,7 @@ Rotate90 (FabArray& mf, int scomp, int ncomp, IntVect const& nghost, Box co AMREX_ASSERT(scomp < mf.nComp() && scomp+ncomp <= mf.nComp()); AMREX_ASSERT(nghost.allLE(mf.nGrowVect()) && nghost[0] == nghost[1]); - if (nghost[0] <= 0) return; + if (nghost[0] <= 0) { return; } const FabArrayBase::RB90& TheRB90 = mf.getRB90(nghost, domain); @@ -585,7 +585,7 @@ Rotate180 (FabArray& mf, int scomp, int ncomp, IntVect const& nghost, Box c AMREX_ASSERT(scomp < mf.nComp() && scomp+ncomp <= mf.nComp()); AMREX_ASSERT(nghost.allLE(mf.nGrowVect())); - if (nghost[0] <= 0) return; + if (nghost[0] <= 0) { return; } const FabArrayBase::RB180& TheRB180 = mf.getRB180(nghost, domain); @@ -620,7 +620,7 @@ FillPolar (FabArray& mf, int scomp, int ncomp, IntVect const& nghost, Box c AMREX_ASSERT(scomp < mf.nComp() && scomp+ncomp <= mf.nComp()); AMREX_ASSERT(nghost.allLE(mf.nGrowVect())); - if (nghost[0] <= 0) return; + if (nghost[0] <= 0) { return; } const FabArrayBase::PolarB& ThePolarB = mf.getPolarB(nghost, domain); @@ -727,10 +727,10 @@ get_src_dst_boxes (DTOS const& dtos, Box const& dstbox, Box const& domain) r.reserve(AMREX_D_TERM(nboxes[0],*nboxes[1],*nboxes[2])); #if (AMREX_SPACEDIM == 3) - for (int kbox = 0; kbox < nboxes[2]; ++kbox) + for (int kbox = 0; kbox < nboxes[2]; ++kbox) { #endif #if (AMREX_SPACEDIM >=2 ) - for (int jbox = 0; jbox < nboxes[1]; ++jbox) + for (int jbox = 0; jbox < nboxes[1]; ++jbox) { #endif for (int ibox = 0; ibox < nboxes[0]; ++ibox) { @@ -750,9 +750,9 @@ get_src_dst_boxes (DTOS const& dtos, Box const& dstbox, Box const& domain) dst_ends[1][div[1]].second, dst_ends[2][div[2]].second)), dtype)); - } + AMREX_D_TERM(},},}) - return r; // NOLINT(readability-misleading-indentation,-warnings-as-errors) + return r; } template diff --git a/Src/Base/AMReX_Orientation.cpp b/Src/Base/AMReX_Orientation.cpp index f51c36ddaff..ed4226da5a4 100644 --- a/Src/Base/AMReX_Orientation.cpp +++ b/Src/Base/AMReX_Orientation.cpp @@ -11,8 +11,9 @@ operator<< (std::ostream& os, const Orientation& o) { os << '('<< int(o) << ')' ; - if (os.fail()) + if (os.fail()) { amrex::Error("operator<<(ostream&,Orientation&) failed"); + } return os; } @@ -38,8 +39,9 @@ operator>> (std::istream& is, amrex::Error("operator>>(istream&,Orientation&): expected \'(\'"); } - if (is.fail()) + if (is.fail()) { amrex::Error("operator>>(ostream&,Orientation&) failed"); + } return is; } diff --git a/Src/Base/AMReX_PArena.cpp b/Src/Base/AMReX_PArena.cpp index a7c7ee1f4bb..82781a7be65 100644 --- a/Src/Base/AMReX_PArena.cpp +++ b/Src/Base/AMReX_PArena.cpp @@ -67,7 +67,7 @@ PArena::alloc (std::size_t nbytes) void PArena::free (void* p) { - if (p == nullptr) return; + if (p == nullptr) { return; } #if defined(AMREX_USE_GPU) diff --git a/Src/Base/AMReX_PCI.H b/Src/Base/AMReX_PCI.H index 7897adcbed8..6ccbe4078fc 100644 --- a/Src/Base/AMReX_PCI.H +++ b/Src/Base/AMReX_PCI.H @@ -7,7 +7,7 @@ FabArray::PC_local_cpu (const CPC& thecpc, FabArray const& src, int scomp, int dcomp, int ncomp, CpOp op) { auto const N_locs = static_cast(thecpc.m_LocTags->size()); - if (N_locs == 0) return; + if (N_locs == 0) { return; } bool is_thread_safe = thecpc.m_threadsafe_loc; if (is_thread_safe) @@ -89,7 +89,7 @@ FabArray::PC_local_gpu (const CPC& thecpc, FabArray const& src, int scomp, int dcomp, int ncomp, CpOp op) { int N_locs = thecpc.m_LocTags->size(); - if (N_locs == 0) return; + if (N_locs == 0) { return; } bool is_thread_safe = thecpc.m_threadsafe_loc; using TagType = Array4CopyTag; diff --git a/Src/Base/AMReX_ParallelContext.cpp b/Src/Base/AMReX_ParallelContext.cpp index 3654527f139..8faf56ca311 100644 --- a/Src/Base/AMReX_ParallelContext.cpp +++ b/Src/Base/AMReX_ParallelContext.cpp @@ -65,11 +65,11 @@ Frame::local_to_global_rank (int* global, const int* local, int n) } else { - for (int i = 0; i < n; ++i) global[i] = local[i]; + for (int i = 0; i < n; ++i) { global[i] = local[i]; } } #else amrex::ignore_unused(local); - for (int i = 0; i < n; ++i) global[i] = 0; + for (int i = 0; i < n; ++i) { global[i] = 0; } #endif } @@ -91,11 +91,11 @@ Frame::global_to_local_rank (int* local, const int* global, int n) } else { - for (int i = 0; i < n; ++i) local[i] = global[i]; + for (int i = 0; i < n; ++i) { local[i] = global[i]; } } #else amrex::ignore_unused(global); - for (int i = 0; i < n; ++i) local[i] = 0; + for (int i = 0; i < n; ++i) { local[i] = 0; } #endif } diff --git a/Src/Base/AMReX_ParallelDescriptor.H b/Src/Base/AMReX_ParallelDescriptor.H index 2e5a35a0ef8..46ca0f99fc3 100644 --- a/Src/Base/AMReX_ParallelDescriptor.H +++ b/Src/Base/AMReX_ParallelDescriptor.H @@ -177,7 +177,7 @@ while ( false ) #if defined(BL_USE_MPI3) if (m_size > 1) { MPI_Comm_free(&m_team_comm); - if (m_rankInTeam==0) MPI_Comm_free(&m_lead_comm); + if (m_rankInTeam==0) { MPI_Comm_free(&m_lead_comm); } } #endif } @@ -355,8 +355,8 @@ while ( false ) { int rb, re; { - if (rit < 0) rit = ParallelDescriptor::MyRankInTeam(); - if (nworkers == 0) nworkers = ParallelDescriptor::TeamSize(); + if (rit < 0) { rit = ParallelDescriptor::MyRankInTeam(); } + if (nworkers == 0) { nworkers = ParallelDescriptor::TeamSize(); } BL_ASSERT(rit(std::numeric_limits::max())); @@ -948,7 +947,7 @@ ParallelDescriptor::Gather (const T& t, int root) BL_COMM_PROFILE(BLProfiler::GatherTi, BLProfiler::BeforeCall(), root, BLProfiler::NoTag()); std::vector resl; - if ( root == MyProc() ) resl.resize(NProcs()); + if ( root == MyProc() ) { resl.resize(NProcs()); } BL_MPI_REQUIRE( MPI_Gather(const_cast(&t), 1, Mpi_typemap::type(), @@ -971,7 +970,7 @@ ParallelDescriptor::Gatherv (const T* send, int sc, BL_COMM_PROFILE(BLProfiler::Gatherv, BLProfiler::BeforeCall(), root, BLProfiler::NoTag()); MPI_Gatherv(send, sc, ParallelDescriptor::Mpi_typemap::type(), - recv, &rc[0], &disp[0], ParallelDescriptor::Mpi_typemap::type(), + recv, rc.data(), disp.data(), ParallelDescriptor::Mpi_typemap::type(), root, Communicator()); BL_COMM_PROFILE(BLProfiler::Gatherv, std::accumulate(rc.begin(),rc.end(),0)*sizeof(T), root, BLProfiler::NoTag()); @@ -1028,7 +1027,7 @@ ParallelDescriptor::GatherLayoutDataToVector (const LayoutData& sendbuf, } Vector disp(nprocs); - if (!disp.empty()) disp[0] = 0; + if (!disp.empty()) { disp[0] = 0; } std::partial_sum(recvcount.begin(), recvcount.end()-1, disp.begin()+1); Vector new_index_to_T(sendbuf.size()); diff --git a/Src/Base/AMReX_ParallelDescriptor.cpp b/Src/Base/AMReX_ParallelDescriptor.cpp index 5074876974f..4e959504158 100644 --- a/Src/Base/AMReX_ParallelDescriptor.cpp +++ b/Src/Base/AMReX_ParallelDescriptor.cpp @@ -263,22 +263,22 @@ Message::test () int Message::tag () const { - if ( !m_finished ) amrex::Error("Message::tag: Not Finished!"); + if ( !m_finished ) { amrex::Error("Message::tag: Not Finished!"); } return m_stat.MPI_TAG; } int Message::pid () const { - if ( !m_finished ) amrex::Error("Message::pid: Not Finished!"); + if ( !m_finished ) { amrex::Error("Message::pid: Not Finished!"); } return m_stat.MPI_SOURCE; } size_t Message::count () const { - if ( m_type == MPI_DATATYPE_NULL ) amrex::Error("Message::count: Bad Type!"); - if ( !m_finished ) amrex::Error("Message::count: Not Finished!"); + if ( m_type == MPI_DATATYPE_NULL ) { amrex::Error("Message::count: Bad Type!"); } + if ( !m_finished ) { amrex::Error("Message::count: Not Finished!"); } int cnt; BL_MPI_REQUIRE( MPI_Get_count(&m_stat, m_type, &cnt) ); return cnt; @@ -394,7 +394,7 @@ StartParallel (int* argc, char*** argv, MPI_Comm a_mpi_comm) #ifdef BL_USE_MPI3 int mpi_version, mpi_subversion; BL_MPI_REQUIRE( MPI_Get_version(&mpi_version, &mpi_subversion) ); - if (mpi_version < 3) amrex::Abort("MPI 3 is needed because USE_MPI3=TRUE"); + if (mpi_version < 3) { amrex::Abort("MPI 3 is needed because USE_MPI3=TRUE"); } #endif // Wait until all other processes are properly started. @@ -471,8 +471,7 @@ Barrier (const MPI_Comm &comm, const std::string &message) #ifdef BL_LAZY int r; MPI_Comm_compare(comm, Communicator(), &r); - if (r == MPI_IDENT) - Lazy::EvalReduction(); + if (r == MPI_IDENT) { Lazy::EvalReduction(); } #endif BL_PROFILE_S("ParallelDescriptor::Barrier(comm)"); @@ -604,8 +603,9 @@ ReduceBoolAnd (bool& r, int cpu) detail::DoReduce(&src,MPI_SUM,1,cpu); - if (ParallelDescriptor::MyProc() == cpu) + if (ParallelDescriptor::MyProc() == cpu) { r = (src == ParallelDescriptor::NProcs()) ? true : false; + } } void @@ -625,8 +625,9 @@ ReduceBoolOr (bool& r, int cpu) detail::DoReduce(&src,MPI_SUM,1,cpu); - if (ParallelDescriptor::MyProc() == cpu) + if (ParallelDescriptor::MyProc() == cpu) { r = (src == 0) ? false : true; + } } void @@ -1128,8 +1129,7 @@ Bcast(void *buf, int count, MPI_Datatype datatype, int root, MPI_Comm comm) #ifdef BL_LAZY int r; MPI_Comm_compare(comm, Communicator(), &r); - if (r == MPI_IDENT) - Lazy::EvalReduction(); + if (r == MPI_IDENT) { Lazy::EvalReduction(); } #endif BL_PROFILE_S("ParallelDescriptor::Bcast(viMiM)"); @@ -1165,8 +1165,9 @@ Gather (Real const* sendbuf, int nsend, Real* recvbuf, int root) BL_ASSERT(!(sendbuf == nullptr)); BL_ASSERT(!(recvbuf == nullptr)); - for (int i = 0; i < nsend; ++i) + for (int i = 0; i < nsend; ++i) { recvbuf[i] = sendbuf[i]; + } } void @@ -1568,7 +1569,7 @@ StartTeams () for (int i = 0; i < lead_ranks.size(); ++i) { lead_ranks[i] = i * team_size; } - BL_MPI_REQUIRE( MPI_Group_incl(grp, lead_ranks.size(), &lead_ranks[0], &lead_grp) ); + BL_MPI_REQUIRE( MPI_Group_incl(grp, lead_ranks.size(), lead_ranks.data(), &lead_grp) ); BL_MPI_REQUIRE( MPI_Comm_create(ParallelDescriptor::Communicator(), lead_grp, &m_Team.m_lead_comm) ); @@ -1591,14 +1592,15 @@ mpi_level_to_string (int mtlev) { amrex::ignore_unused(mtlev); #ifdef AMREX_USE_MPI - if (mtlev == MPI_THREAD_SINGLE) + if (mtlev == MPI_THREAD_SINGLE) { return std::string("MPI_THREAD_SINGLE"); - if (mtlev == MPI_THREAD_FUNNELED) + } else if (mtlev == MPI_THREAD_FUNNELED) { return std::string("MPI_THREAD_FUNNELED"); - if (mtlev == MPI_THREAD_SERIALIZED) + } else if (mtlev == MPI_THREAD_SERIALIZED) { return std::string("MPI_THREAD_SERIALIZED"); - if (mtlev == MPI_THREAD_MULTIPLE) + } else if (mtlev == MPI_THREAD_MULTIPLE) { return std::string("MPI_THREAD_MULTIPLE"); + } #endif return std::string("UNKNOWN"); } diff --git a/Src/Base/AMReX_ParmParse.cpp b/Src/Base/AMReX_ParmParse.cpp index 8fb37dab408..49a6db4afa9 100644 --- a/Src/Base/AMReX_ParmParse.cpp +++ b/Src/Base/AMReX_ParmParse.cpp @@ -85,7 +85,7 @@ ParmParse::PP_entry::~PP_entry () ParmParse::PP_entry& ParmParse::PP_entry::operator= (const PP_entry& pe) { - if ( &pe == this ) return *this; + if ( &pe == this ) { return *this; } m_name = pe.m_name; m_vals = pe.m_vals; m_table = nullptr; @@ -105,7 +105,7 @@ ParmParse::PP_entry::print () const { for ( int i = 0; i < n; i++) { t << m_vals[i]; - if ( i < n-1 ) t << " "; + if ( i < n-1 ) { t << " "; } } return t.str(); } @@ -118,7 +118,7 @@ operator<< (std::ostream& os, const ParmParse::PP_entry& pp) for ( int i = 0; i < n; i++ ) { os << pp.m_vals[i]; - if ( i < n-1 ) os << ", "; + if ( i < n-1 ) { os << ", "; } } os << "]"; @@ -147,10 +147,10 @@ isT (const std::string& str, T& val) { std::istringstream s(str); s >> val; - if ( s.fail() ) return false; + if ( s.fail() ) { return false; } std::string left; std::getline(s, left); - if ( !left.empty() ) return false; + if ( !left.empty() ) { return false; } return true; } @@ -264,7 +264,7 @@ eat_garbage (const char*& str) int num_linefeeds = 0; for (;;) { - if ( *str == 0 ) break; // NOLINT + if ( *str == 0 ) { break; } // NOLINT else if ( *str == '#' ) { while ( *str && *str != '\n' ) @@ -656,8 +656,9 @@ addDefn (std::string& def, tab.emplace_back(def,val); } val.clear(); - if ( def != ParmParse::FileKeyword ) + if ( def != ParmParse::FileKeyword ) { def = std::string(); + } } void @@ -915,7 +916,7 @@ squeryarr (const ParmParse::Table& table, num_val = static_cast(def->m_vals.size()); } - if ( num_val == 0 ) return true; + if ( num_val == 0 ) { return true; } int stop_ix = start_ix + num_val - 1; if ( static_cast(ref.size()) <= stop_ix ) @@ -1183,7 +1184,7 @@ unused_table_entries_q (const ParmParse::Table& table, const std::string& prefix } else { - if (unused_table_entries_q(*li.m_table, prefix)) return true; + if (unused_table_entries_q(*li.m_table, prefix)) { return true; } } } else if ( !li.m_queried ) @@ -1248,11 +1249,11 @@ ParmParse::QueryUnusedInputs () { if ( ParallelDescriptor::IOProcessor() && unused_table_entries_q(g_table)) { - finalize_verbose = amrex::system::verbose; - if (finalize_verbose) amrex::OutStream() << "Unused ParmParse Variables:\n"; - finalize_table(" [TOP]", g_table); - if (finalize_verbose) amrex::OutStream() << std::endl; - return true; + finalize_verbose = amrex::system::verbose; + if (finalize_verbose) { amrex::OutStream() << "Unused ParmParse Variables:\n"; } + finalize_table(" [TOP]", g_table); + if (finalize_verbose) { amrex::OutStream() << std::endl; } + return true; } return false; } @@ -1314,14 +1315,16 @@ ParmParse::Finalize () { if ( ParallelDescriptor::IOProcessor() && unused_table_entries_q(g_table)) { - finalize_verbose = amrex::system::verbose; - if (finalize_verbose) amrex::OutStream() << "Unused ParmParse Variables:\n"; - finalize_table(" [TOP]", g_table); - if (finalize_verbose) amrex::OutStream() << std::endl; - // - // First loop through and delete all queried entries. - // - if (amrex::system::abort_on_unused_inputs) amrex::Abort("ERROR: unused ParmParse variables."); + finalize_verbose = amrex::system::verbose; + if (finalize_verbose) { amrex::OutStream() << "Unused ParmParse Variables:\n"; } + finalize_table(" [TOP]", g_table); + if (finalize_verbose) { amrex::OutStream() << std::endl; } + // + // First loop through and delete all queried entries. + // + if (amrex::system::abort_on_unused_inputs) { + amrex::Abort("ERROR: unused ParmParse variables."); + } } g_table.clear(); diff --git a/Src/Base/AMReX_PhysBCFunct.H b/Src/Base/AMReX_PhysBCFunct.H index 211b6a5b777..0589d30a217 100644 --- a/Src/Base/AMReX_PhysBCFunct.H +++ b/Src/Base/AMReX_PhysBCFunct.H @@ -140,7 +140,7 @@ public: void operator() (MultiFab& mf, int icomp, int ncomp, IntVect const& nghost, Real time, int bccomp) { - if (m_geom.isAllPeriodic()) return; + if (m_geom.isAllPeriodic()) { return; } BL_PROFILE("PhysBCFunct::()"); @@ -234,7 +234,7 @@ GpuBndryFuncFab::nddoit (Box const& bx, FArrayBox& dest, } } - if (gdomain.contains(bx)) return; + if (gdomain.contains(bx)) { return; } Array4 const& fab = dest.array(); const auto geomdata = geom.data(); @@ -359,7 +359,7 @@ GpuBndryFuncFab::ccfcdoit (Box const& bx, FArrayBox& dest, } } - if (gdomain.contains(bx)) return; + if (gdomain.contains(bx)) { return; } Array4 const& fab = dest.array(); const auto geomdata = geom.data(); @@ -383,7 +383,7 @@ GpuBndryFuncFab::ccfcdoit (Box const& bx, FArrayBox& dest, Vector face_boxes; for (const Box& b : dom_face_boxes) { Box tmp = b & bx; - if (tmp.ok()) face_boxes.push_back(tmp); + if (tmp.ok()) { face_boxes.push_back(tmp); } } const int n_face_boxes = face_boxes.size(); if (n_face_boxes == 1) { @@ -443,7 +443,7 @@ GpuBndryFuncFab::ccfcdoit (Box const& bx, FArrayBox& dest, Vector edge_boxes; for (const Box& b : dom_edge_boxes) { Box tmp = b & bx; - if (tmp.ok()) edge_boxes.push_back(tmp); + if (tmp.ok()) { edge_boxes.push_back(tmp); } } const int n_edge_boxes = edge_boxes.size(); if (n_edge_boxes == 1) { @@ -491,7 +491,7 @@ GpuBndryFuncFab::ccfcdoit (Box const& bx, FArrayBox& dest, Vector corner_boxes; for (const Box& b : dom_corner_boxes) { Box tmp = b & bx; - if (tmp.ok()) corner_boxes.push_back(tmp); + if (tmp.ok()) { corner_boxes.push_back(tmp); } } const int n_corner_boxes = corner_boxes.size(); if (n_corner_boxes == 1) { diff --git a/Src/Base/AMReX_PlotFileUtil.cpp b/Src/Base/AMReX_PlotFileUtil.cpp index cee9ee9b735..df8ff405a10 100644 --- a/Src/Base/AMReX_PlotFileUtil.cpp +++ b/Src/Base/AMReX_PlotFileUtil.cpp @@ -202,7 +202,7 @@ WriteMultiLevelPlotfile (const std::string& plotfilename, int nlevels, HeaderFile.open(HeaderFileName.c_str(), std::ofstream::out | std::ofstream::trunc | std::ofstream::binary); - if( ! HeaderFile.good()) FileOpenFailed(HeaderFileName); + if( ! HeaderFile.good()) { FileOpenFailed(HeaderFileName); } WriteGenericPlotfileHeader(HeaderFile, nlevels, boxArrays, varnames, geom, time, level_steps, ref_ratio, versionName, levelPrefix, mfPrefix); diff --git a/Src/Base/AMReX_Random.cpp b/Src/Base/AMReX_Random.cpp index 135c5391ebf..c32c3164f0e 100644 --- a/Src/Base/AMReX_Random.cpp +++ b/Src/Base/AMReX_Random.cpp @@ -136,8 +136,9 @@ void RestoreRandomState (std::istream& is, int nthreads_old, int nstep_old) { int N = std::min(nthreads, nthreads_old); - for (int i = 0; i < N; i++) + for (int i = 0; i < N; i++) { is >> generators[i]; + } if (nthreads > nthreads_old) { const int NProcs = ParallelDescriptor::NProcs(); const int MyProc = ParallelDescriptor::MyProc(); diff --git a/Src/Base/AMReX_RealBox.H b/Src/Base/AMReX_RealBox.H index ddbc96b1b90..6f429c8262b 100644 --- a/Src/Base/AMReX_RealBox.H +++ b/Src/Base/AMReX_RealBox.H @@ -92,7 +92,7 @@ public: //! it's volume is considered to be zero. [[nodiscard]] AMREX_GPU_HOST_DEVICE Real volume () const noexcept { - if (ok()) return AMREX_D_TERM(length(0), *length(1), *length(2)); + if (ok()) { return AMREX_D_TERM(length(0), *length(1), *length(2)); } return 0.0; } diff --git a/Src/Base/AMReX_RealBox.cpp b/Src/Base/AMReX_RealBox.cpp index c411f558ec0..bf4713be289 100644 --- a/Src/Base/AMReX_RealBox.cpp +++ b/Src/Base/AMReX_RealBox.cpp @@ -32,8 +32,9 @@ std::ostream& operator << (std::ostream &os, const RealBox& b) { os << "(RealBox "; - for (int i = 0; i < AMREX_SPACEDIM; i++) + for (int i = 0; i < AMREX_SPACEDIM; i++) { os << b.lo(i) << ' ' << b.hi(i) << ' '; + } os << ')'; return os; } @@ -68,8 +69,9 @@ operator >> (std::istream &is, RealBox& b) hi[i] = static_cast(dhitemp); } #else - for (int i = 0; i < AMREX_SPACEDIM; i++) + for (int i = 0; i < AMREX_SPACEDIM; i++) { is >> lo[i] >> hi[i]; + } #endif is.ignore(BL_IGNORE_MAX, ')'); diff --git a/Src/Base/AMReX_RealVect.cpp b/Src/Base/AMReX_RealVect.cpp index 68adc5ba95d..94d8655f9ac 100644 --- a/Src/Base/AMReX_RealVect.cpp +++ b/Src/Base/AMReX_RealVect.cpp @@ -34,8 +34,9 @@ namespace amrex amrex::Error("operator>>(istream&,IntVect&): expected \'(\'"); } - if (is.fail()) + if (is.fail()) { amrex::Error("operator>>(istream&,IntVect&) failed"); + } return is; } diff --git a/Src/Base/AMReX_Reduce.H b/Src/Base/AMReX_Reduce.H index 34f1c6e74bb..201d1064840 100644 --- a/Src/Base/AMReX_Reduce.H +++ b/Src/Base/AMReX_Reduce.H @@ -618,7 +618,7 @@ public: typename M=std::enable_if_t::value> > void eval (N n, D & reduce_data, F&& f) { - if (n <= 0) return; + if (n <= 0) { return; } using ReduceTuple = typename D::Type; auto const& stream = Gpu::gpuStream(); auto dp = reduce_data.devicePtr(stream); @@ -887,7 +887,7 @@ bool AnyOf (N n, T const* v, P&& pred) amrex::launch(ec.numBlocks.x, 0, Gpu::gpuStream(), [=] AMREX_GPU_DEVICE () noexcept { __shared__ int has_any; - if (threadIdx.x == 0) has_any = *dp; + if (threadIdx.x == 0) { has_any = *dp; } __syncthreads(); if (!has_any) @@ -953,7 +953,7 @@ bool AnyOf (Box const& box, P&& pred) Gpu::gpuStream(), [=] AMREX_GPU_DEVICE () noexcept { __shared__ int has_any; - if (threadIdx.x == 0) has_any = *dp; + if (threadIdx.x == 0) { has_any = *dp; } __syncthreads(); if (!has_any) @@ -1259,7 +1259,7 @@ bool AnyOf (Box const& box, P&&pred) for (int k = lo.z; k <= hi.z; ++k) { for (int j = lo.y; j <= hi.y; ++j) { for (int i = lo.x; i <= hi.x; ++i) { - if (pred(i,j,k)) return true; + if (pred(i,j,k)) { return true; } }}} return false; } diff --git a/Src/Base/AMReX_Scan.H b/Src/Base/AMReX_Scan.H index df255b16e09..11fdfd8bd70 100644 --- a/Src/Base/AMReX_Scan.H +++ b/Src/Base/AMReX_Scan.H @@ -189,7 +189,7 @@ struct BlockStatus template T PrefixSum_mp (N n, FIN && fin, FOUT && fout, TYPE, RetSum a_ret_sum) { - if (n <= 0) return 0; + if (n <= 0) { return 0; } constexpr int nwarps_per_block = 8; constexpr int nthreads = nwarps_per_block*Gpu::Device::warp_size; constexpr int nchunks = 12; @@ -234,7 +234,7 @@ T PrefixSum_mp (N n, FIN && fin, FOUT && fout, TYPE, RetSum a_ret_sum) T sum_prev_chunk = 0; // inclusive sum from previous chunks. for (int ichunk = 0; ichunk < nchunks; ++ichunk) { N offset = ibegin + ichunk*blockDimx; - if (offset >= iend) break; + if (offset >= iend) { break; } offset += threadIdxx; T x0 = (offset < iend) ? fin(offset) : 0; @@ -242,7 +242,7 @@ T PrefixSum_mp (N n, FIN && fin, FOUT && fout, TYPE, RetSum a_ret_sum) // Scan within a warp for (int i = 1; i <= Gpu::Device::warp_size; i *= 2) { T s = sycl::shift_group_right(sg, x, i); - if (lane >= i) x += s; + if (lane >= i) { x += s; } } // x now holds the inclusive sum within the warp. The @@ -260,10 +260,10 @@ T PrefixSum_mp (N n, FIN && fin, FOUT && fout, TYPE, RetSum a_ret_sum) T y = (lane < nwarps) ? shared[lane] : 0; for (int i = 1; i <= Gpu::Device::warp_size; i *= 2) { T s = sycl::shift_group_right(sg, y, i); - if (lane >= i) y += s; + if (lane >= i) { y += s; } } - if (lane < nwarps) shared2[lane] = y; + if (lane < nwarps) { shared2[lane] = y; } } gh.item->barrier(sycl::access::fence_space::local_space); @@ -309,7 +309,7 @@ T PrefixSum_mp (N n, FIN && fin, FOUT && fout, TYPE, RetSum a_ret_sum) // Scan within a warp for (int i = 1; i <= Gpu::Device::warp_size; i *= 2) { T s = sycl::shift_group_right(sg, x, i); - if (lane >= i) x += s; + if (lane >= i) { x += s; } } // x now holds the inclusive sum within the warp. The @@ -327,10 +327,10 @@ T PrefixSum_mp (N n, FIN && fin, FOUT && fout, TYPE, RetSum a_ret_sum) T y = (lane < nwarps) ? shared[lane] : 0; for (int i = 1; i <= Gpu::Device::warp_size; i *= 2) { T s = sycl::shift_group_right(sg, y, i); - if (lane >= i) y += s; + if (lane >= i) { y += s; } } - if (lane < nwarps) shared2[lane] = y; + if (lane < nwarps) { shared2[lane] = y; } } gh.item->barrier(sycl::access::fence_space::local_space); @@ -390,7 +390,7 @@ template ,Type::Exclusive>::value)> > T PrefixSum (N n, FIN && fin, FOUT && fout, TYPE type, RetSum a_ret_sum = retSum) { - if (n <= 0) return 0; + if (n <= 0) { return 0; } constexpr int nwarps_per_block = 8; constexpr int nthreads = nwarps_per_block*Gpu::Device::warp_size; constexpr int nchunks = 12; @@ -476,7 +476,7 @@ T PrefixSum (N n, FIN && fin, FOUT && fout, TYPE type, RetSum a_ret_sum = retSum T tmp_out[nchunks]; // block-wide inclusive sum for chunks for (int ichunk = 0; ichunk < nchunks; ++ichunk) { N offset = ibegin + ichunk*blockDimx; - if (offset >= iend) break; + if (offset >= iend) { break; } offset += threadIdxx; T x0 = (offset < iend) ? fin(offset) : 0; @@ -487,7 +487,7 @@ T PrefixSum (N n, FIN && fin, FOUT && fout, TYPE type, RetSum a_ret_sum = retSum // Scan within a warp for (int i = 1; i <= Gpu::Device::warp_size; i *= 2) { T s = sycl::shift_group_right(sg, x, i); - if (lane >= i) x += s; + if (lane >= i) { x += s; } } // x now holds the inclusive sum within the warp. The @@ -505,10 +505,10 @@ T PrefixSum (N n, FIN && fin, FOUT && fout, TYPE type, RetSum a_ret_sum = retSum T y = (lane < nwarps) ? shared[lane] : 0; for (int i = 1; i <= Gpu::Device::warp_size; i *= 2) { T s = sycl::shift_group_right(sg, y, i); - if (lane >= i) y += s; + if (lane >= i) { y += s; } } - if (lane < nwarps) shared2[lane] = y; + if (lane < nwarps) { shared2[lane] = y; } } gh.item->barrier(sycl::access::fence_space::local_space); @@ -533,7 +533,7 @@ T PrefixSum (N n, FIN && fin, FOUT && fout, TYPE type, RetSum a_ret_sum = retSum if (virtual_block_id == 0) { for (int ichunk = 0; ichunk < nchunks; ++ichunk) { N offset = ibegin + ichunk*blockDimx + threadIdxx; - if (offset >= iend) break; + if (offset >= iend) { break; } fout(offset, tmp_out[ichunk]); if (offset == n-1) { *totalsum_p += tmp_out[ichunk]; @@ -564,11 +564,11 @@ T PrefixSum (N n, FIN && fin, FOUT && fout, TYPE type, RetSum a_ret_sum = retSum if (stop_lookback == false) { if (status_bf != 0) { T y = x; - if (lane > 0) x = 0; + if (lane > 0) { x = 0; } unsigned int bit_mask = 0x1u; for (int i = 1; i < Gpu::Device::warp_size; ++i) { bit_mask <<= 1; - if (i == lane) x = y; + if (i == lane) { x = y; } if (status_bf & bit_mask) { stop_lookback = true; break; @@ -582,7 +582,7 @@ T PrefixSum (N n, FIN && fin, FOUT && fout, TYPE type, RetSum a_ret_sum = retSum } if (lane == 0) { exclusive_prefix += x; } - if (stop_lookback) break; + if (stop_lookback) { break; } } if (lane == 0) { @@ -597,7 +597,7 @@ T PrefixSum (N n, FIN && fin, FOUT && fout, TYPE type, RetSum a_ret_sum = retSum for (int ichunk = 0; ichunk < nchunks; ++ichunk) { N offset = ibegin + ichunk*blockDimx + threadIdxx; - if (offset >= iend) break; + if (offset >= iend) { break; } T t = tmp_out[ichunk] + exclusive_prefix; fout(offset, t); if (offset == n-1) { @@ -629,7 +629,7 @@ template ,Type::Exclusive>::value)> > T PrefixSum (N n, FIN && fin, FOUT && fout, TYPE, RetSum a_ret_sum = retSum) { - if (n <= 0) return 0; + if (n <= 0) { return 0; } constexpr int nwarps_per_block = 4; constexpr int nthreads = nwarps_per_block*Gpu::Device::warp_size; // # of threads per block constexpr int nelms_per_thread = sizeof(T) >= 8 ? 8 : 16; @@ -772,7 +772,7 @@ template ,Type::Exclusive>::value)> > T PrefixSum (N n, FIN && fin, FOUT && fout, TYPE, RetSum a_ret_sum = retSum) { - if (n <= 0) return 0; + if (n <= 0) { return 0; } constexpr int nwarps_per_block = 8; constexpr int nthreads = nwarps_per_block*Gpu::Device::warp_size; // # of threads per block constexpr int nelms_per_thread = sizeof(T) >= 8 ? 4 : 8; @@ -905,7 +905,7 @@ template ,Type::Exclusive>::value)> > T PrefixSum (N n, FIN && fin, FOUT && fout, TYPE, RetSum a_ret_sum = retSum) { - if (n <= 0) return 0; + if (n <= 0) { return 0; } constexpr int nwarps_per_block = 4; constexpr int nthreads = nwarps_per_block*Gpu::Device::warp_size; constexpr int nchunks = 12; @@ -980,7 +980,7 @@ T PrefixSum (N n, FIN && fin, FOUT && fout, TYPE, RetSum a_ret_sum = retSum) T tmp_out[nchunks]; // block-wide inclusive sum for chunks for (int ichunk = 0; ichunk < nchunks; ++ichunk) { N offset = ibegin + ichunk*blockDim.x; - if (offset >= iend) break; + if (offset >= iend) { break; } offset += threadIdx.x; T x0 = (offset < iend) ? fin(offset) : 0; @@ -992,7 +992,7 @@ T PrefixSum (N n, FIN && fin, FOUT && fout, TYPE, RetSum a_ret_sum = retSum) for (int i = 1; i <= Gpu::Device::warp_size; i *= 2) { AMREX_HIP_OR_CUDA( T s = __shfl_up(x,i);, T s = __shfl_up_sync(0xffffffff, x, i); ) - if (lane >= i) x += s; + if (lane >= i) { x += s; } } // x now holds the inclusive sum within the warp. The @@ -1013,7 +1013,7 @@ T PrefixSum (N n, FIN && fin, FOUT && fout, TYPE, RetSum a_ret_sum = retSum) int mask = (1 << nwarps) - 1; for (int i = 1; i <= nwarps; i *= 2) { T s = __shfl_up_sync(mask, y, i, nwarps); - if (lane >= i) y += s; + if (lane >= i) { y += s; } } shared2[lane] = y; } @@ -1025,7 +1025,7 @@ T PrefixSum (N n, FIN && fin, FOUT && fout, TYPE, RetSum a_ret_sum = retSum) } for (int i = 1; i <= nwarps; i *= 2) { T s = __shfl_up(y, i, nwarps); - if (lane >= i) y += s; + if (lane >= i) { y += s; } } if (lane < nwarps) { shared2[lane] = y; @@ -1055,7 +1055,7 @@ T PrefixSum (N n, FIN && fin, FOUT && fout, TYPE, RetSum a_ret_sum = retSum) if (virtual_block_id == 0) { for (int ichunk = 0; ichunk < nchunks; ++ichunk) { N offset = ibegin + ichunk*blockDim.x + threadIdx.x; - if (offset >= iend) break; + if (offset >= iend) { break; } fout(offset, tmp_out[ichunk]); if (offset == n-1) { *totalsum_p += tmp_out[ichunk]; @@ -1082,12 +1082,12 @@ T PrefixSum (N n, FIN && fin, FOUT && fout, TYPE, RetSum a_ret_sum = retSum) if (stop_lookback == false) { if (status_bf != 0) { T y = x; - if (lane > 0) x = 0; + if (lane > 0) { x = 0; } AMREX_HIP_OR_CUDA(uint64_t bit_mask = 0x1ull;, unsigned bit_mask = 0x1u); for (int i = 1; i < Gpu::Device::warp_size; ++i) { bit_mask <<= 1; - if (i == lane) x = y; + if (i == lane) { x = y; } if (status_bf & bit_mask) { stop_lookback = true; break; @@ -1102,7 +1102,7 @@ T PrefixSum (N n, FIN && fin, FOUT && fout, TYPE, RetSum a_ret_sum = retSum) } if (lane == 0) { exclusive_prefix += x; } - if (stop_lookback) break; + if (stop_lookback) { break; } } if (lane == 0) { @@ -1117,7 +1117,7 @@ T PrefixSum (N n, FIN && fin, FOUT && fout, TYPE, RetSum a_ret_sum = retSum) for (int ichunk = 0; ichunk < nchunks; ++ichunk) { N offset = ibegin + ichunk*blockDim.x + threadIdx.x; - if (offset >= iend) break; + if (offset >= iend) { break; } T t = tmp_out[ichunk] + exclusive_prefix; fout(offset, t); if (offset == n-1) { @@ -1208,7 +1208,7 @@ T InclusiveSum (N n, T const* in, T * out, RetSum a_ret_sum = retSum) template ::value> > T ExclusiveSum (N n, T const* in, T * out, RetSum a_ret_sum = retSum) { - if (n <= 0) return 0; + if (n <= 0) { return 0; } #if defined(AMREX_USE_CUDA) && defined(__CUDACC__) && (__CUDACC_VER_MAJOR__ >= 11) T in_last = 0; if (a_ret_sum) { @@ -1286,7 +1286,7 @@ template ,Type::Exclusive>::value)> > T PrefixSum (N n, FIN && fin, FOUT && fout, TYPE, RetSum = retSum) { - if (n <= 0) return 0; + if (n <= 0) { return 0; } T totalsum = 0; for (N i = 0; i < n; ++i) { T x = fin(i); @@ -1317,7 +1317,7 @@ T InclusiveSum (N n, T const* in, T * out, RetSum /*a_ret_sum*/ = retSum) template ::value> > T ExclusiveSum (N n, T const* in, T * out, RetSum /*a_ret_sum*/ = retSum) { - if (n <= 0) return 0; + if (n <= 0) { return 0; } auto in_last = in[n-1]; #if (__cplusplus >= 201703L) && (!defined(_GLIBCXX_RELEASE) || _GLIBCXX_RELEASE >= 10) @@ -1366,7 +1366,7 @@ namespace Gpu // GCC's __cplusplus is not a reliable indication for C++17 support return std::exclusive_scan(begin, end, result, 0); #else - if (begin == end) return result; + if (begin == end) { return result; } typename std::iterator_traits::value_type sum = *begin; *result++ = sum - *begin; diff --git a/Src/Base/AMReX_TagParallelFor.H b/Src/Base/AMReX_TagParallelFor.H index ae832f3b2af..5aa748a3d61 100644 --- a/Src/Base/AMReX_TagParallelFor.H +++ b/Src/Base/AMReX_TagParallelFor.H @@ -149,7 +149,7 @@ void ParallelFor_doit (Vector const& tags, F && f) { const int ntags = tags.size(); - if (ntags == 0) return; + if (ntags == 0) { return; } int ntotwarps = 0; Vector nwarps; @@ -197,7 +197,7 @@ ParallelFor_doit (Vector const& tags, F && f) int g_tid = blockDim.x*blockIdx.x + threadIdx.x; #endif int g_wid = g_tid / Gpu::Device::warp_size; - if (g_wid >= ntotwarps) return; + if (g_wid >= ntotwarps) { return; } int tag_id = amrex::bisect(d_nwarps, 0, ntags, g_wid); diff --git a/Src/Base/AMReX_TinyProfiler.cpp b/Src/Base/AMReX_TinyProfiler.cpp index 8c59a1eae7b..3d935589409 100644 --- a/Src/Base/AMReX_TinyProfiler.cpp +++ b/Src/Base/AMReX_TinyProfiler.cpp @@ -56,7 +56,7 @@ TinyProfiler::TinyProfiler (std::string funcname) noexcept TinyProfiler::TinyProfiler (std::string funcname, bool start_, bool useCUPTI) noexcept : fname(std::move(funcname)), uCUPTI(useCUPTI) { - if (start_) start(); + if (start_) { start(); } } TinyProfiler::TinyProfiler (const char* funcname) noexcept @@ -68,7 +68,7 @@ TinyProfiler::TinyProfiler (const char* funcname) noexcept TinyProfiler::TinyProfiler (const char* funcname, bool start_, bool useCUPTI) noexcept : fname(funcname), uCUPTI(useCUPTI) { - if (start_) start(); + if (start_) { start(); } } TinyProfiler::~TinyProfiler () @@ -543,7 +543,7 @@ TinyProfiler::PrintStats (std::map& regstats, double dt_max) } } - if (regstats.empty()) return; + if (regstats.empty()) { return; } int nprocs = ParallelDescriptor::NProcs(); int ioproc = ParallelDescriptor::IOProcessorNumber(); @@ -568,8 +568,8 @@ TinyProfiler::PrintStats (std::map& regstats, double dt_max) dtdt[1] = dts[1]; } else { - ParallelDescriptor::Gather(&n, 1, &ncalls[0], 1, ioproc); - ParallelDescriptor::Gather(dts, 2, &dtdt[0], 2, ioproc); + ParallelDescriptor::Gather(&n, 1, ncalls.data(), 1, ioproc); + ParallelDescriptor::Gather(dts, 2, dtdt.data(), 2, ioproc); } if (ParallelDescriptor::IOProcessor()) { @@ -742,7 +742,7 @@ TinyProfiler::PrintMemStats(std::map& memstats, } } - if (memstats.empty()) return; + if (memstats.empty()) { return; } const int nprocs = ParallelDescriptor::NProcs(); const int ioproc = ParallelDescriptor::IOProcessorNumber(); @@ -772,10 +772,10 @@ TinyProfiler::PrintMemStats(std::map& memstats, maxmem_vec[0] = maxmem; } else { - ParallelDescriptor::Gather(&nalloc, 1, &nalloc_vec[0], 1, ioproc); - ParallelDescriptor::Gather(&nfree, 1, &nfree_vec[0], 1, ioproc); - ParallelDescriptor::Gather(&maxmem, 1, &maxmem_vec[0], 1, ioproc); - ParallelDescriptor::Gather(&avgmem, 1, &avgmem_vec[0], 1, ioproc); + ParallelDescriptor::Gather(&nalloc, 1, nalloc_vec.data(), 1, ioproc); + ParallelDescriptor::Gather(&nfree , 1, nfree_vec.data(), 1, ioproc); + ParallelDescriptor::Gather(&maxmem, 1, maxmem_vec.data(), 1, ioproc); + ParallelDescriptor::Gather(&avgmem, 1, avgmem_vec.data(), 1, ioproc); } if (ParallelDescriptor::IOProcessor()) { @@ -864,7 +864,7 @@ TinyProfiler::PrintMemStats(std::map& memstats, maxlen[i] += 2; } - if (allstatsstr.size() == 1) return; + if (allstatsstr.size() == 1) { return; } int lenhline = 0; for (auto i : maxlen) { diff --git a/Src/Base/AMReX_TypeList.H b/Src/Base/AMReX_TypeList.H index 24262fbb7a3..3bd0a837069 100644 --- a/Src/Base/AMReX_TypeList.H +++ b/Src/Base/AMReX_TypeList.H @@ -106,7 +106,7 @@ ForEach (TypeList, F&& f) return false; } }); - if (!r) amrex::Abort("Unsupported types"); + if (!r) { amrex::Abort("Unsupported types"); } } \endverbatim */ diff --git a/Src/Base/AMReX_Utility.cpp b/Src/Base/AMReX_Utility.cpp index 423f3046ed9..b9cc90df5ae 100644 --- a/Src/Base/AMReX_Utility.cpp +++ b/Src/Base/AMReX_Utility.cpp @@ -89,8 +89,9 @@ amrex::Tokenize (const std::string& instr, if (!((token = std::strtok(line, separators.c_str())) == nullptr)) // NOLINT(bugprone-assignment-in-if-condition) { ptr.push_back(token); - while (!((token = std::strtok(nullptr, separators.c_str())) == nullptr)) // NOLINT(bugprone-assignment-in-if-condition) + while (!((token = std::strtok(nullptr, separators.c_str())) == nullptr)) { // NOLINT(bugprone-assignment-in-if-condition) ptr.push_back(token); + } } tokens.resize(ptr.size()); @@ -132,7 +133,7 @@ std::string amrex::trim(std::string s, std::string const& space) { const auto sbegin = s.find_first_not_of(space); - if (sbegin == std::string::npos) return std::string{}; + if (sbegin == std::string::npos) { return std::string{}; } const auto send = s.find_last_not_of(space); s = s.substr(sbegin, send-sbegin+1); return s; @@ -302,8 +303,9 @@ int amrex::CRRBetweenLevels(int fromlevel, int tolevel, double amrex::InvNormDist (double p) { - if (p <= 0 || p >= 1) + if (p <= 0 || p >= 1) { amrex::Error("amrex::InvNormDist(): p MUST be in (0,1)"); + } // // Coefficients in rational approximations. // @@ -474,8 +476,9 @@ amrex::InvNormDistBest (double p) double r, value; - if (p <= 0 || p >= 1) + if (p <= 0 || p >= 1) { amrex::Error("InvNormDistBest(): p MUST be in (0,1)"); + } double q = p - 0.5; @@ -528,7 +531,7 @@ amrex::InvNormDistBest (double p) value = num / den; } - if ( q < 0.0 ) value = -value; + if ( q < 0.0 ) { value = -value; } } return value; @@ -547,7 +550,7 @@ amrex::operator>>(std::istream& is, const expect& exp) { char c; is >> c; - if ( !is ) break; + if ( !is ) { break; } if ( c != exp.istr[n++] ) { is.putback(c); diff --git a/Src/Base/AMReX_Vector.H b/Src/Base/AMReX_Vector.H index 248aced1de4..c377076fe1b 100644 --- a/Src/Base/AMReX_Vector.H +++ b/Src/Base/AMReX_Vector.H @@ -63,7 +63,7 @@ namespace amrex { Vector r; r.reserve(a.size()); - for (auto& x : a) r.push_back(&x); + for (auto& x : a) { r.push_back(&x); } return r; } @@ -72,7 +72,7 @@ namespace amrex { Vector r; r.reserve(a.size()); - for (const auto& x : a) r.push_back(x.get()); + for (const auto& x : a) { r.push_back(x.get()); } return r; } @@ -83,7 +83,7 @@ namespace amrex { Vector r; r.reserve(a.size()); - for (const auto& x : a) r.push_back(&x); + for (const auto& x : a) { r.push_back(&x); } return r; } @@ -92,7 +92,7 @@ namespace amrex { Vector r; r.reserve(a.size()); - for (const auto& x : a) r.push_back(x.get()); + for (const auto& x : a) { r.push_back(x.get()); } return r; } @@ -109,7 +109,7 @@ namespace amrex { Vector > r; r.reserve(a.size()); - for (const auto& x : a) r.push_back(GetVecOfPtrs(x)); + for (const auto& x : a) { r.push_back(GetVecOfPtrs(x)); } return r; } @@ -122,7 +122,7 @@ namespace amrex { Vector > r; r.reserve(a.size()); - for (const auto& x : a) r.push_back(GetArrOfPtrs(x)); + for (const auto& x : a) { r.push_back(GetArrOfPtrs(x)); } return r; } @@ -132,7 +132,7 @@ namespace amrex { Vector > r; r.reserve(a.size()); - for (const auto& x : a) r.push_back(GetArrOfConstPtrs(x)); + for (const auto& x : a) { r.push_back(GetArrOfConstPtrs(x)); } return r; } @@ -142,7 +142,7 @@ namespace amrex { Vector > r; r.reserve(a.size()); - for (const auto& x : a) r.push_back(GetArrOfConstPtrs(x)); + for (const auto& x : a) { r.push_back(GetArrOfConstPtrs(x)); } return r; } @@ -154,7 +154,7 @@ namespace amrex { Vector > r; r.reserve(a.size()); - for (const auto& x : a) r.push_back(GetArrOfConstPtrs(x)); + for (const auto& x : a) { r.push_back(GetArrOfConstPtrs(x)); } return r; } @@ -166,7 +166,7 @@ namespace amrex { Vector > r; r.reserve(a.size()); - for (auto &x: a) r.push_back(GetArrOfPtrs(x)); + for (auto &x: a) { r.push_back(GetArrOfPtrs(x)); } return r; } #endif @@ -199,7 +199,7 @@ namespace amrex std::size_t removeDupDoit (Vector& vec, std::size_t start, std::size_t stop) { std::size_t N = stop-start; - if (N < 2) return stop; + if (N < 2) { return stop; } T* const data = vec.data() + start; T const sentinel = data[0]; // duplicates will be set to sentinel and removed later diff --git a/Src/Base/AMReX_VisMF.cpp b/Src/Base/AMReX_VisMF.cpp index a109a09b04e..52efe827460 100644 --- a/Src/Base/AMReX_VisMF.cpp +++ b/Src/Base/AMReX_VisMF.cpp @@ -1535,7 +1535,7 @@ VisMF::Read (FabArray &mf, // This allows us to read in an empty MultiFab without an error -- but only if explicitly told to if (allow_empty_mf > 0) { - if (hdr.m_ba.empty()) return; + if (hdr.m_ba.empty()) { return; } } else { if (hdr.m_ba.empty()) { @@ -2273,7 +2273,7 @@ VisMF::AsyncWriteDoit (const FabArray& mf, const std::string& mf_name RealDescriptor const& whichRD = FPC::NativeRealDescriptor(); auto hdr = std::make_shared(mf, VisMF::NFiles, VisMF::Header::Version_v1, false); - if (valid_cells_only) hdr->m_ngrow = IntVect(0); + if (valid_cells_only) { hdr->m_ngrow = IntVect(0); } constexpr int sizeof_int64_over_real = sizeof(int64_t) / sizeof(Real); const int n_local_fabs = mf.local_size(); @@ -2475,7 +2475,7 @@ VisMF::AsyncWriteDoit (const FabArray& mf, const std::string& mf_name ofs.rdbuf()->pubsetbuf(io_buffer.dataPtr(), io_buffer.size()); ofs.open(file_name.c_str(), (info.ispot == 0) ? (std::ios::binary | std::ios::trunc) : (std::ios::binary | std::ios::app)); - if (!ofs.good()) amrex::FileOpenFailed(file_name); + if (!ofs.good()) { amrex::FileOpenFailed(file_name); } for (auto const& fab : *myfabs) { fabio->write_header(ofs, fab, fab.nComp()); fabio->write(ofs, fab, 0, fab.nComp()); diff --git a/Src/Base/AMReX_iMultiFab.cpp b/Src/Base/AMReX_iMultiFab.cpp index 63465f0a036..3941c4267b2 100644 --- a/Src/Base/AMReX_iMultiFab.cpp +++ b/Src/Base/AMReX_iMultiFab.cpp @@ -148,7 +148,7 @@ iMultiFab::negate (const Box& region, int nghost) void iMultiFab::Initialize () { - if (initialized) return; + if (initialized) { return; } amrex::ExecOnFinalize(iMultiFab::Finalize); diff --git a/Src/Base/AMReX_parstream.cpp b/Src/Base/AMReX_parstream.cpp index cd223ac8180..824b9041ecc 100644 --- a/Src/Base/AMReX_parstream.cpp +++ b/Src/Base/AMReX_parstream.cpp @@ -59,7 +59,7 @@ namespace amrex int outInterv = 1; ParmParse pp("amrex"); pp.queryAdd("pout_int", outInterv); - if (outInterv == 0) outInterv=ParallelDescriptor::NProcs(); + if (outInterv == 0) { outInterv=ParallelDescriptor::NProcs(); } int thisProc = ParallelDescriptor::MyProc(); if ((thisProc % outInterv) != 0) diff --git a/Src/Base/Parser/AMReX_Parser_Y.H b/Src/Base/Parser/AMReX_Parser_Y.H index a6b39d54fb9..53b3dcc55a4 100644 --- a/Src/Base/Parser/AMReX_Parser_Y.H +++ b/Src/Base/Parser/AMReX_Parser_Y.H @@ -154,7 +154,7 @@ static constexpr std::string_view parser_node_s[] = struct parser_node { enum parser_node_t type; enum parser_node_t padding; - struct parser_node* l; + struct parser_node* l; // NOLINT(misc-confusable-identifiers) struct parser_node* r; struct parser_node* padding2; }; @@ -173,7 +173,7 @@ struct alignas(parser_node) parser_symbol { struct alignas(parser_node) parser_f1 { /* Builtin functions with one argument */ enum parser_node_t type; enum parser_f1_t ftype; - struct parser_node* l; + struct parser_node* l; // NOLINT(misc-confusable-identifiers) struct parser_node* padding1; struct parser_node* padding2; }; @@ -181,7 +181,7 @@ struct alignas(parser_node) parser_f1 { /* Builtin functions with one argument struct alignas(parser_node) parser_f2 { /* Builtin functions with two arguments */ enum parser_node_t type; enum parser_f2_t ftype; - struct parser_node* l; + struct parser_node* l; // NOLINT(misc-confusable-identifiers) struct parser_node* r; struct parser_node* padding; }; diff --git a/Src/Base/Parser/AMReX_Parser_Y.cpp b/Src/Base/Parser/AMReX_Parser_Y.cpp index 74dde9679ec..75a58498c15 100644 --- a/Src/Base/Parser/AMReX_Parser_Y.cpp +++ b/Src/Base/Parser/AMReX_Parser_Y.cpp @@ -631,7 +631,7 @@ namespace { bool parser_node_equal (struct parser_node* a, struct parser_node* b) { - if (a->type != b->type) return false; + if (a->type != b->type) { return false; } switch (a->type) { case PARSER_NUMBER: diff --git a/Tests/Amr/Advection_AmrCore/Source/Src_K/compute_flux_2D_K.H b/Tests/Amr/Advection_AmrCore/Source/Src_K/compute_flux_2D_K.H index 57d6a13aa82..51bda7f35ed 100644 --- a/Tests/Amr/Advection_AmrCore/Source/Src_K/compute_flux_2D_K.H +++ b/Tests/Amr/Advection_AmrCore/Source/Src_K/compute_flux_2D_K.H @@ -1,9 +1,8 @@ #ifndef compute_flux_2d_H_ #define compute_flux_2d_H_ -#include -#include -#include +#include +#include AMREX_GPU_DEVICE AMREX_FORCE_INLINE diff --git a/Tests/Amr/Advection_AmrCore/Source/Src_K/compute_flux_3D_K.H b/Tests/Amr/Advection_AmrCore/Source/Src_K/compute_flux_3D_K.H index d80666e1b2e..10caf821788 100644 --- a/Tests/Amr/Advection_AmrCore/Source/Src_K/compute_flux_3D_K.H +++ b/Tests/Amr/Advection_AmrCore/Source/Src_K/compute_flux_3D_K.H @@ -1,20 +1,17 @@ #ifndef compute_flux_3d_H_ #define compute_flux_3d_H_ -#include -#include -#include - -using namespace amrex; +#include +#include AMREX_GPU_DEVICE AMREX_FORCE_INLINE void flux_x(int i, int j, int k, - Array4 const& px, - Array4 const& phi, - Array4 const& vx, - Array4 const& slope, - Real dtdx) + amrex::Array4 const& px, + amrex::Array4 const& phi, + amrex::Array4 const& vx, + amrex::Array4 const& slope, + amrex::Real dtdx) { px(i,j,k) = ( (vx(i,j,k) < 0) ? phi(i ,j,k) - slope(i ,j,k)*(0.5 + 0.5*dtdx*vx(i,j,k)) : @@ -24,11 +21,11 @@ void flux_x(int i, int j, int k, AMREX_GPU_DEVICE AMREX_FORCE_INLINE void flux_y(int i, int j, int k, - Array4 const& py, - Array4 const& phi, - Array4 const& vy, - Array4 const& slope, - Real dtdy) + amrex::Array4 const& py, + amrex::Array4 const& phi, + amrex::Array4 const& vy, + amrex::Array4 const& slope, + amrex::Real dtdy) { py(i,j,k) = ( (vy(i,j,k) < 0) ? phi(i,j ,k) - slope(i,j ,k)*(0.5 + 0.5*dtdy*vy(i,j,k)) : @@ -38,11 +35,11 @@ void flux_y(int i, int j, int k, AMREX_GPU_DEVICE AMREX_FORCE_INLINE void flux_z(int i, int j, int k, - Array4 const& pz, - Array4 const& phi, - Array4 const& vz, - Array4 const& slope, - Real dtdz) + amrex::Array4 const& pz, + amrex::Array4 const& phi, + amrex::Array4 const& vz, + amrex::Array4 const& slope, + amrex::Real dtdz) { pz(i,j,k) = ( (vz(i,j,k) < 0) ? phi(i,j,k ) - slope(i,j,k )*(0.5 + 0.5*dtdz*vz(i,j,k)) : @@ -52,12 +49,12 @@ void flux_z(int i, int j, int k, AMREX_GPU_DEVICE AMREX_FORCE_INLINE void flux_xy(int i, int j, int k, - Array4 const& pxy, - Array4 const& vx, - Array4 const& vy, - Array4 const& px, - Array4 const& py, - Real dtdy) + amrex::Array4 const& pxy, + amrex::Array4 const& vx, + amrex::Array4 const& vy, + amrex::Array4 const& px, + amrex::Array4 const& py, + amrex::Real dtdy) { pxy(i,j,k) = ( (vx(i,j,k) < 0) ? px(i,j,k) - dtdy/3.0 * ( 0.5*(vy(i, j+1,k) + vy(i ,j,k)) * (py(i ,j+1,k) - py(i ,j,k))) : @@ -67,12 +64,12 @@ void flux_xy(int i, int j, int k, AMREX_GPU_DEVICE AMREX_FORCE_INLINE void flux_xz(int i, int j, int k, - Array4 const& pxz, - Array4 const& vx, - Array4 const& vz, - Array4 const& px, - Array4 const& pz, - Real dtdz) + amrex::Array4 const& pxz, + amrex::Array4 const& vx, + amrex::Array4 const& vz, + amrex::Array4 const& px, + amrex::Array4 const& pz, + amrex::Real dtdz) { pxz(i,j,k) = ( (vx(i,j,k) < 0) ? px(i,j,k) - dtdz/3.0 * ( 0.5*(vz(i, j,k+1) + vz(i ,j,k)) * (pz(i ,j,k+1) - pz(i ,j,k))) : @@ -82,12 +79,12 @@ void flux_xz(int i, int j, int k, AMREX_GPU_DEVICE AMREX_FORCE_INLINE void flux_yx(int i, int j, int k, - Array4 const& pyx, - Array4 const& vx, - Array4 const& vy, - Array4 const& px, - Array4 const& py, - Real dtdx) + amrex::Array4 const& pyx, + amrex::Array4 const& vx, + amrex::Array4 const& vy, + amrex::Array4 const& px, + amrex::Array4 const& py, + amrex::Real dtdx) { pyx(i,j,k) = ( (vy(i,j,k) < 0) ? py(i,j,k) - dtdx/3.0 * ( 0.5*(vx(i+1,j ,k) + vx(i,j ,k)) * (px(i+1,j ,k) - px(i,j ,k))) : @@ -97,12 +94,12 @@ void flux_yx(int i, int j, int k, AMREX_GPU_DEVICE AMREX_FORCE_INLINE void flux_yz(int i, int j, int k, - Array4 const& pyz, - Array4 const& vy, - Array4 const& vz, - Array4 const& py, - Array4 const& pz, - Real dtdz) + amrex::Array4 const& pyz, + amrex::Array4 const& vy, + amrex::Array4 const& vz, + amrex::Array4 const& py, + amrex::Array4 const& pz, + amrex::Real dtdz) { pyz(i,j,k) = ( (vy(i,j,k) < 0) ? py(i,j,k) - dtdz/3.0 * ( 0.5*(vz(i, j,k+1) + vz(i,j ,k)) * (pz(i,j ,k+1) - pz(i,j ,k))) : @@ -112,12 +109,12 @@ void flux_yz(int i, int j, int k, AMREX_GPU_DEVICE AMREX_FORCE_INLINE void flux_zx(int i, int j, int k, - Array4 const& pzx, - Array4 const& vx, - Array4 const& vz, - Array4 const& px, - Array4 const& pz, - Real dtdx) + amrex::Array4 const& pzx, + amrex::Array4 const& vx, + amrex::Array4 const& vz, + amrex::Array4 const& px, + amrex::Array4 const& pz, + amrex::Real dtdx) { pzx(i,j,k) = ( (vz(i,j,k) < 0) ? pz(i,j,k) - dtdx/3.0 * ( 0.5*(vx(i+1,j,k ) + vx(i,j,k )) * (px(i+1,j,k ) - px(i,j,k ))) : @@ -127,12 +124,12 @@ void flux_zx(int i, int j, int k, AMREX_GPU_DEVICE AMREX_FORCE_INLINE void flux_zy(int i, int j, int k, - Array4 const& pzy, - Array4 const& vy, - Array4 const& vz, - Array4 const& py, - Array4 const& pz, - Real dtdy) + amrex::Array4 const& pzy, + amrex::Array4 const& vy, + amrex::Array4 const& vz, + amrex::Array4 const& py, + amrex::Array4 const& pz, + amrex::Real dtdy) { pzy(i,j,k) = ( (vz(i,j,k) < 0) ? pz(i,j,k) - dtdy/3.0 * ( 0.5*(vy(i,j+1,k ) + vy(i,j,k )) * (py(i,j+1,k ) - py(i,j,k ))) : @@ -142,16 +139,16 @@ void flux_zy(int i, int j, int k, AMREX_GPU_DEVICE AMREX_FORCE_INLINE void create_flux_x(int i, int j, int k, - Array4 const& fx, - Array4 const& vx, - Array4 const& vy, - Array4 const& vz, - Array4 const& px, - Array4 const& pyz, - Array4 const& pzy, - Real dtdy, Real dtdz) + amrex::Array4 const& fx, + amrex::Array4 const& vx, + amrex::Array4 const& vy, + amrex::Array4 const& vz, + amrex::Array4 const& px, + amrex::Array4 const& pyz, + amrex::Array4 const& pzy, + amrex::Real dtdy, amrex::Real dtdz) { - Real f = ( (vx(i,j,k) < 0) ? + amrex::Real f = ( (vx(i,j,k) < 0) ? px(i,j,k) - 0.5*dtdy * ( 0.5*(vy(i ,j+1,k ) + vy(i ,j,k)) * (pyz(i ,j+1,k )-pyz(i ,j,k))) - 0.5*dtdz * ( 0.5*(vz(i ,j ,k+1) + vz(i ,j,k)) * (pzy(i ,j ,k+1)-pzy(i ,j,k))) : px(i,j,k) - 0.5*dtdy * ( 0.5*(vy(i-1,j+1,k ) + vy(i-1,j,k)) * (pyz(i-1,j+1,k )-pyz(i-1,j,k))) @@ -163,16 +160,16 @@ void create_flux_x(int i, int j, int k, AMREX_GPU_DEVICE AMREX_FORCE_INLINE void create_flux_y(int i, int j, int k, - Array4 const& fy, - Array4 const& vx, - Array4 const& vy, - Array4 const& vz, - Array4 const& py, - Array4 const& pxz, - Array4 const& pzx, - Real dtdx, Real dtdz) + amrex::Array4 const& fy, + amrex::Array4 const& vx, + amrex::Array4 const& vy, + amrex::Array4 const& vz, + amrex::Array4 const& py, + amrex::Array4 const& pxz, + amrex::Array4 const& pzx, + amrex::Real dtdx, amrex::Real dtdz) { - Real f = ( (vy(i,j,k) < 0) ? + amrex::Real f = ( (vy(i,j,k) < 0) ? py(i,j,k) - 0.5*dtdx * ( 0.5*(vx(i+1,j ,k ) + vx(i,j ,k)) * (pxz(i+1,j ,k )-pxz(i,j ,k))) - 0.5*dtdz * ( 0.5*(vz(i, j ,k+1) + vz(i,j ,k)) * (pzx(i, j ,k+1)-pzx(i,j ,k))) : py(i,j,k) - 0.5*dtdx * ( 0.5*(vx(i+1,j-1,k ) + vx(i,j-1,k)) * (pxz(i+1,j-1,k )-pxz(i,j-1,k))) @@ -184,16 +181,16 @@ void create_flux_y(int i, int j, int k, AMREX_GPU_DEVICE AMREX_FORCE_INLINE void create_flux_z(int i, int j, int k, - Array4 const& fz, - Array4 const& vx, - Array4 const& vy, - Array4 const& vz, - Array4 const& pz, - Array4 const& pxy, - Array4 const& pyx, - Real dtdx, Real dtdy) + amrex::Array4 const& fz, + amrex::Array4 const& vx, + amrex::Array4 const& vy, + amrex::Array4 const& vz, + amrex::Array4 const& pz, + amrex::Array4 const& pxy, + amrex::Array4 const& pyx, + amrex::Real dtdx, amrex::Real dtdy) { - Real f = ( (vz(i,j,k) < 0) ? + amrex::Real f = ( (vz(i,j,k) < 0) ? pz(i,j,k) - 0.5*dtdx * ( 0.5*(vx(i+1,j ,k ) + vx(i,j,k )) * (pxy(i+1,j ,k )-pxy(i,j,k ))) - 0.5*dtdy * ( 0.5*(vy(i, j+1,k ) + vy(i,j,k )) * (pyx(i, j+1,k )-pyx(i,j,k ))) : pz(i,j,k) - 0.5*dtdx * ( 0.5*(vx(i+1,j ,k-1) + vx(i,j,k-1)) * (pxy(i+1,j ,k-1)-pxy(i,j,k-1))) diff --git a/Tests/Amr/Advection_AmrLevel/Exec/SingleVortex/Prob_Parm.H b/Tests/Amr/Advection_AmrLevel/Exec/SingleVortex/Prob_Parm.H index a562656c6e4..8594d8e76b8 100644 --- a/Tests/Amr/Advection_AmrLevel/Exec/SingleVortex/Prob_Parm.H +++ b/Tests/Amr/Advection_AmrLevel/Exec/SingleVortex/Prob_Parm.H @@ -3,8 +3,6 @@ #include -using namespace amrex::literals; - // Define the struct to contain problem-specific variables here. // For this case, since we don't need any, the struct is empty. struct ProbParm {}; diff --git a/Tests/Amr/Advection_AmrLevel/Exec/UniformVelocity/Prob_Parm.H b/Tests/Amr/Advection_AmrLevel/Exec/UniformVelocity/Prob_Parm.H index e285ddaa8f4..bbb0b87d0f9 100644 --- a/Tests/Amr/Advection_AmrLevel/Exec/UniformVelocity/Prob_Parm.H +++ b/Tests/Amr/Advection_AmrLevel/Exec/UniformVelocity/Prob_Parm.H @@ -2,9 +2,6 @@ #define PROB_PARM_H_ #include -#include - -using namespace amrex::literals; // Define the struct to contain problem-specific variables here. struct ProbParm diff --git a/Tests/Amr/Advection_AmrLevel/Source/Src_K/Adv_K.H b/Tests/Amr/Advection_AmrLevel/Source/Src_K/Adv_K.H index 95d85827e94..c3e7d9b3022 100644 --- a/Tests/Amr/Advection_AmrLevel/Source/Src_K/Adv_K.H +++ b/Tests/Amr/Advection_AmrLevel/Source/Src_K/Adv_K.H @@ -2,6 +2,7 @@ #define Adv_K_H_ #include +#include AMREX_GPU_DEVICE AMREX_FORCE_INLINE diff --git a/Tests/Amr/Advection_AmrLevel/Source/Src_K/flux_2d_K.H b/Tests/Amr/Advection_AmrLevel/Source/Src_K/flux_2d_K.H index fd7ac553a04..27cc27c9dcf 100644 --- a/Tests/Amr/Advection_AmrLevel/Source/Src_K/flux_2d_K.H +++ b/Tests/Amr/Advection_AmrLevel/Source/Src_K/flux_2d_K.H @@ -1,8 +1,8 @@ #ifndef flux_2d_K_H_ #define flux_2d_K_H_ -#include -#include +#include +#include AMREX_GPU_DEVICE AMREX_FORCE_INLINE diff --git a/Tests/Amr/Advection_AmrLevel/Source/Src_K/flux_3d_K.H b/Tests/Amr/Advection_AmrLevel/Source/Src_K/flux_3d_K.H index 4a022639951..9201dc85ce7 100644 --- a/Tests/Amr/Advection_AmrLevel/Source/Src_K/flux_3d_K.H +++ b/Tests/Amr/Advection_AmrLevel/Source/Src_K/flux_3d_K.H @@ -1,19 +1,17 @@ #ifndef flux_3d_K_H_ #define flux_3d_K_H_ -#include -#include - -using namespace amrex; +#include +#include AMREX_GPU_DEVICE AMREX_FORCE_INLINE void flux_x(int i, int j, int k, - Array4 const& px, - Array4 const& phi, - Array4 const& vx, - Array4 const& slope, - Real hdtdx) + amrex::Array4 const& px, + amrex::Array4 const& phi, + amrex::Array4 const& vx, + amrex::Array4 const& slope, + amrex::Real hdtdx) { px(i,j,k) = ( (vx(i,j,k) < 0) ? phi(i ,j,k) - slope(i ,j,k)*(0.5 + hdtdx*vx(i,j,k)) : @@ -23,11 +21,11 @@ void flux_x(int i, int j, int k, AMREX_GPU_DEVICE AMREX_FORCE_INLINE void flux_y(int i, int j, int k, - Array4 const& py, - Array4 const& phi, - Array4 const& vy, - Array4 const& slope, - Real hdtdy) + amrex::Array4 const& py, + amrex::Array4 const& phi, + amrex::Array4 const& vy, + amrex::Array4 const& slope, + amrex::Real hdtdy) { py(i,j,k) = ( (vy(i,j,k) < 0) ? phi(i,j ,k) - slope(i,j ,k)*(0.5 + hdtdy*vy(i,j,k)) : @@ -37,11 +35,11 @@ void flux_y(int i, int j, int k, AMREX_GPU_DEVICE AMREX_FORCE_INLINE void flux_z(int i, int j, int k, - Array4 const& pz, - Array4 const& phi, - Array4 const& vz, - Array4 const& slope, - Real hdtdz) + amrex::Array4 const& pz, + amrex::Array4 const& phi, + amrex::Array4 const& vz, + amrex::Array4 const& slope, + amrex::Real hdtdz) { pz(i,j,k) = ( (vz(i,j,k) < 0) ? phi(i,j,k ) - slope(i,j,k )*(0.5 + hdtdz*vz(i,j,k)) : @@ -51,12 +49,12 @@ void flux_z(int i, int j, int k, AMREX_GPU_DEVICE AMREX_FORCE_INLINE void flux_xy(int i, int j, int k, - Array4 const& pxy, - Array4 const& vx, - Array4 const& vy, - Array4 const& px, - Array4 const& py, - Real tdtdy) + amrex::Array4 const& pxy, + amrex::Array4 const& vx, + amrex::Array4 const& vy, + amrex::Array4 const& px, + amrex::Array4 const& py, + amrex::Real tdtdy) { pxy(i,j,k) = ( (vx(i,j,k) < 0) ? px(i,j,k) - tdtdy * ( 0.5*(vy(i, j+1,k) + vy(i ,j,k)) * (py(i ,j+1,k) - py(i ,j,k))) : @@ -66,12 +64,12 @@ void flux_xy(int i, int j, int k, AMREX_GPU_DEVICE AMREX_FORCE_INLINE void flux_xz(int i, int j, int k, - Array4 const& pxz, - Array4 const& vx, - Array4 const& vz, - Array4 const& px, - Array4 const& pz, - Real tdtdz) + amrex::Array4 const& pxz, + amrex::Array4 const& vx, + amrex::Array4 const& vz, + amrex::Array4 const& px, + amrex::Array4 const& pz, + amrex::Real tdtdz) { pxz(i,j,k) = ( (vx(i,j,k) < 0) ? px(i,j,k) - tdtdz * ( 0.5*(vz(i, j,k+1) + vz(i ,j,k)) * (pz(i ,j,k+1) - pz(i ,j,k))) : @@ -81,12 +79,12 @@ void flux_xz(int i, int j, int k, AMREX_GPU_DEVICE AMREX_FORCE_INLINE void flux_yx(int i, int j, int k, - Array4 const& pyx, - Array4 const& vx, - Array4 const& vy, - Array4 const& px, - Array4 const& py, - Real tdtdx) + amrex::Array4 const& pyx, + amrex::Array4 const& vx, + amrex::Array4 const& vy, + amrex::Array4 const& px, + amrex::Array4 const& py, + amrex::Real tdtdx) { pyx(i,j,k) = ( (vy(i,j,k) < 0) ? py(i,j,k) - tdtdx * ( 0.5*(vx(i+1,j ,k) + vx(i,j ,k)) * (px(i+1,j ,k) - px(i,j ,k))) : @@ -96,12 +94,12 @@ void flux_yx(int i, int j, int k, AMREX_GPU_DEVICE AMREX_FORCE_INLINE void flux_yz(int i, int j, int k, - Array4 const& pyz, - Array4 const& vy, - Array4 const& vz, - Array4 const& py, - Array4 const& pz, - Real tdtdz) + amrex::Array4 const& pyz, + amrex::Array4 const& vy, + amrex::Array4 const& vz, + amrex::Array4 const& py, + amrex::Array4 const& pz, + amrex::Real tdtdz) { pyz(i,j,k) = ( (vy(i,j,k) < 0) ? py(i,j,k) - tdtdz * ( 0.5*(vz(i, j,k+1) + vz(i,j ,k)) * (pz(i,j ,k+1) - pz(i,j ,k))) : @@ -111,12 +109,12 @@ void flux_yz(int i, int j, int k, AMREX_GPU_DEVICE AMREX_FORCE_INLINE void flux_zx(int i, int j, int k, - Array4 const& pzx, - Array4 const& vx, - Array4 const& vz, - Array4 const& px, - Array4 const& pz, - Real tdtdx) + amrex::Array4 const& pzx, + amrex::Array4 const& vx, + amrex::Array4 const& vz, + amrex::Array4 const& px, + amrex::Array4 const& pz, + amrex::Real tdtdx) { pzx(i,j,k) = ( (vz(i,j,k) < 0) ? pz(i,j,k) - tdtdx * ( 0.5*(vx(i+1,j,k ) + vx(i,j,k )) * (px(i+1,j,k ) - px(i,j,k ))) : @@ -126,12 +124,12 @@ void flux_zx(int i, int j, int k, AMREX_GPU_DEVICE AMREX_FORCE_INLINE void flux_zy(int i, int j, int k, - Array4 const& pzy, - Array4 const& vy, - Array4 const& vz, - Array4 const& py, - Array4 const& pz, - Real tdtdy) + amrex::Array4 const& pzy, + amrex::Array4 const& vy, + amrex::Array4 const& vz, + amrex::Array4 const& py, + amrex::Array4 const& pz, + amrex::Real tdtdy) { pzy(i,j,k) = ( (vz(i,j,k) < 0) ? pz(i,j,k) - tdtdy * ( 0.5*(vy(i,j+1,k ) + vy(i,j,k )) * (py(i,j+1,k ) - py(i,j,k ))) : @@ -141,16 +139,16 @@ void flux_zy(int i, int j, int k, AMREX_GPU_DEVICE AMREX_FORCE_INLINE void create_flux_x(int i, int j, int k, - Array4 const& fx, - Array4 const& vx, - Array4 const& vy, - Array4 const& vz, - Array4 const& px, - Array4 const& pyz, - Array4 const& pzy, - Real hdtdy, Real hdtdz) + amrex::Array4 const& fx, + amrex::Array4 const& vx, + amrex::Array4 const& vy, + amrex::Array4 const& vz, + amrex::Array4 const& px, + amrex::Array4 const& pyz, + amrex::Array4 const& pzy, + amrex::Real hdtdy, amrex::Real hdtdz) { - Real f = ( (vx(i,j,k) < 0) ? + amrex::Real f = ( (vx(i,j,k) < 0) ? px(i,j,k) - hdtdy * ( 0.5*(vy(i ,j+1,k ) + vy(i ,j,k)) * (pyz(i ,j+1,k )-pyz(i ,j,k))) - hdtdz * ( 0.5*(vz(i ,j ,k+1) + vz(i ,j,k)) * (pzy(i ,j ,k+1)-pzy(i ,j,k))) : px(i,j,k) - hdtdy * ( 0.5*(vy(i-1,j+1,k ) + vy(i-1,j,k)) * (pyz(i-1,j+1,k )-pyz(i-1,j,k))) @@ -162,16 +160,16 @@ void create_flux_x(int i, int j, int k, AMREX_GPU_DEVICE AMREX_FORCE_INLINE void create_flux_y(int i, int j, int k, - Array4 const& fy, - Array4 const& vx, - Array4 const& vy, - Array4 const& vz, - Array4 const& py, - Array4 const& pxz, - Array4 const& pzx, - Real hdtdx, Real hdtdz) + amrex::Array4 const& fy, + amrex::Array4 const& vx, + amrex::Array4 const& vy, + amrex::Array4 const& vz, + amrex::Array4 const& py, + amrex::Array4 const& pxz, + amrex::Array4 const& pzx, + amrex::Real hdtdx, amrex::Real hdtdz) { - Real f = ( (vy(i,j,k) < 0) ? + amrex::Real f = ( (vy(i,j,k) < 0) ? py(i,j,k) - hdtdx * ( 0.5*(vx(i+1,j ,k ) + vx(i,j ,k)) * (pxz(i+1,j ,k )-pxz(i,j ,k))) - hdtdz * ( 0.5*(vz(i, j ,k+1) + vz(i,j ,k)) * (pzx(i, j ,k+1)-pzx(i,j ,k))) : py(i,j,k) - hdtdx * ( 0.5*(vx(i+1,j-1,k ) + vx(i,j-1,k)) * (pxz(i+1,j-1,k )-pxz(i,j-1,k))) @@ -183,16 +181,16 @@ void create_flux_y(int i, int j, int k, AMREX_GPU_DEVICE AMREX_FORCE_INLINE void create_flux_z(int i, int j, int k, - Array4 const& fz, - Array4 const& vx, - Array4 const& vy, - Array4 const& vz, - Array4 const& pz, - Array4 const& pxy, - Array4 const& pyx, - Real hdtdx, Real hdtdy) + amrex::Array4 const& fz, + amrex::Array4 const& vx, + amrex::Array4 const& vy, + amrex::Array4 const& vz, + amrex::Array4 const& pz, + amrex::Array4 const& pxy, + amrex::Array4 const& pyx, + amrex::Real hdtdx, amrex::Real hdtdy) { - Real f = ( (vz(i,j,k) < 0) ? + amrex::Real f = ( (vz(i,j,k) < 0) ? pz(i,j,k) - hdtdx * ( 0.5*(vx(i+1,j ,k ) + vx(i,j,k )) * (pxy(i+1,j ,k )-pxy(i,j,k ))) - hdtdy * ( 0.5*(vy(i, j+1,k ) + vy(i,j,k )) * (pyx(i, j+1,k )-pyx(i,j,k ))) : pz(i,j,k) - hdtdx * ( 0.5*(vx(i+1,j ,k-1) + vx(i,j,k-1)) * (pxy(i+1,j ,k-1)-pxy(i,j,k-1))) diff --git a/Tests/Amr/Advection_AmrLevel/Source/Src_K/slope_K.H b/Tests/Amr/Advection_AmrLevel/Source/Src_K/slope_K.H index 12f816fba82..8709e9c85f0 100644 --- a/Tests/Amr/Advection_AmrLevel/Source/Src_K/slope_K.H +++ b/Tests/Amr/Advection_AmrLevel/Source/Src_K/slope_K.H @@ -1,8 +1,9 @@ #ifndef slope_K_H_ #define slope_K_H_ +#include #include -#include +#include #include AMREX_GPU_DEVICE @@ -11,7 +12,7 @@ void slopex2(amrex::Box const& bx, amrex::Array4 const& dq, amrex::Array4 const& q) { - using namespace amrex; + using amrex::Real; const auto lo = amrex::lbound(bx); const auto hi = amrex::ubound(bx); @@ -39,7 +40,7 @@ void slopex4(amrex::Box const& bx, amrex::Array4 const& q, amrex::Array4 const& dq) { - using namespace amrex; + using amrex::Real; const auto lo = amrex::lbound(bx); const auto hi = amrex::ubound(bx); @@ -69,7 +70,7 @@ void slopey2(amrex::Box const& bx, amrex::Array4 const& dq, amrex::Array4 const& q) { - using namespace amrex; + using amrex::Real; const auto lo = amrex::lbound(bx); const auto hi = amrex::ubound(bx); @@ -97,7 +98,7 @@ void slopey4(amrex::Box const& bx, amrex::Array4 const& q, amrex::Array4 const& dq) { - using namespace amrex; + using amrex::Real; const auto lo = amrex::lbound(bx); const auto hi = amrex::ubound(bx); @@ -128,7 +129,7 @@ void slopez2(amrex::Box const& bx, amrex::Array4 const& dq, amrex::Array4 const& q) { - using namespace amrex; + using amrex::Real; const auto lo = amrex::lbound(bx); const auto hi = amrex::ubound(bx); @@ -156,7 +157,7 @@ void slopez4(amrex::Box const& bx, amrex::Array4 const& q, amrex::Array4 const& dq) { - using namespace amrex; + using amrex::Real; const auto lo = amrex::lbound(bx); const auto hi = amrex::ubound(bx); diff --git a/Tests/Amr/Advection_AmrLevel/Source/Src_K/tagging_K.H b/Tests/Amr/Advection_AmrLevel/Source/Src_K/tagging_K.H index cc58c427fd5..a3c9d13d616 100644 --- a/Tests/Amr/Advection_AmrLevel/Source/Src_K/tagging_K.H +++ b/Tests/Amr/Advection_AmrLevel/Source/Src_K/tagging_K.H @@ -2,6 +2,7 @@ #define TAGGING_K_H_ #include +#include #include // Tag regions of high phi. diff --git a/Tests/EB/CNS/Source/CNS.H b/Tests/EB/CNS/Source/CNS.H index af216738f58..feab3469d98 100644 --- a/Tests/EB/CNS/Source/CNS.H +++ b/Tests/EB/CNS/Source/CNS.H @@ -5,7 +5,6 @@ #include #include -using namespace amrex; class CNS : public amrex::AmrLevel