From b84e52a2e15ac87db2ad03329a58eb0c4cea4619 Mon Sep 17 00:00:00 2001 From: Weiqun Zhang Date: Thu, 3 Aug 2023 11:24:39 -0700 Subject: [PATCH] Clang-Tidy changes in Src/Amr --- Src/Amr/AMReX_Amr.cpp | 182 ++++++++++++++++++------------ Src/Amr/AMReX_AmrLevel.cpp | 80 +++++++------ Src/Amr/AMReX_AuxBoundaryData.H | 2 +- Src/Amr/AMReX_AuxBoundaryData.cpp | 2 +- Src/Amr/AMReX_Derive.cpp | 15 ++- Src/Amr/AMReX_Extrapolater.cpp | 2 +- Src/Amr/AMReX_StateData.cpp | 13 ++- Src/Amr/AMReX_StateDescriptor.cpp | 15 ++- Src/Amr/AMReX_extrapolater_2D_K.H | 8 +- Src/Amr/AMReX_extrapolater_3D_K.H | 12 +- 10 files changed, 199 insertions(+), 132 deletions(-) diff --git a/Src/Amr/AMReX_Amr.cpp b/Src/Amr/AMReX_Amr.cpp index 56e253b6ece..d14e3d6ed36 100644 --- a/Src/Amr/AMReX_Amr.cpp +++ b/Src/Amr/AMReX_Amr.cpp @@ -103,7 +103,7 @@ Amr::UsingPrecreateDirectories () noexcept void Amr::Initialize () { - if (initialized) return; + if (initialized) { return; } // // Set all defaults here!!! // @@ -171,8 +171,9 @@ Amr::RegridOnRestart () noexcept void Amr::setDtMin (const Vector& dt_min_in) noexcept { - for (int i = 0; i <= finest_level; i++) + for (int i = 0; i <= finest_level; i++) { dt_min[i] = dt_min_in[i]; + } } Vector >& @@ -295,12 +296,13 @@ Amr::InitAmr () if (pp.contains("data_log")) { - int num_datalogs = pp.countval("data_log"); - datalog.resize(num_datalogs); - datalogname.resize(num_datalogs); - pp.queryarr("data_log",datalogname,0,num_datalogs); - for (int i = 0; i < num_datalogs; i++) - setRecordDataInfo(i,datalogname[i]); + int num_datalogs = pp.countval("data_log"); + datalog.resize(num_datalogs); + datalogname.resize(num_datalogs); + pp.queryarr("data_log",datalogname,0,num_datalogs); + for (int i = 0; i < num_datalogs; i++) { + setRecordDataInfo(i,datalogname[i]); + } } #ifndef AMREX_NO_PROBINIT @@ -349,8 +351,9 @@ Amr::InitAmr () if (max_level > 0) { regrid_int.resize(max_level); - for (int i = 0; i < max_level; i++) + for (int i = 0; i < max_level; i++) { regrid_int[i] = 1; + } } // @@ -411,8 +414,9 @@ Amr::InitAmr () #define STRIP while( is.get() != '\n' ) {} std::ifstream is(initial_grids_file.c_str(),std::ios::in); - if (!is.good()) + if (!is.good()) { amrex::FileOpenFailed(initial_grids_file); + } int in_finest,ngrid; @@ -422,8 +426,9 @@ Amr::InitAmr () initial_ba.resize(in_finest); use_fixed_upto_level = in_finest; - if (in_finest > max_level) + if (in_finest > max_level) { amrex::Error("You have fewer levels in your inputs file then in your grids file!"); + } for (int lev = 1; lev <= in_finest; lev++) { @@ -454,8 +459,9 @@ Amr::InitAmr () #define STRIP while( is.get() != '\n' ) {} std::ifstream is(regrid_grids_file.c_str(),std::ios::in); - if (!is.good()) + if (!is.good()) { amrex::FileOpenFailed(regrid_grids_file); + } int in_finest,ngrid; @@ -610,8 +616,9 @@ Amr::addStatePlotVar (const std::string& name) void Amr::addStateSmallPlotVar (const std::string& name) { - if (!isStateSmallPlotVar(name)) + if (!isStateSmallPlotVar(name)) { state_small_plot_vars.push_back(name); + } } void @@ -1200,8 +1207,9 @@ Amr::readProbinFile (int& a_init) const int iBuff = 0; const int wakeUpPID = (MyProc + nAtOnce); const int tag = (MyProc % nAtOnce); - if (wakeUpPID < NProcs) + if (wakeUpPID < NProcs) { ParallelDescriptor::Send(&iBuff, 1, wakeUpPID, tag); + } } if (MySet == (iSet + 1)) { @@ -1228,8 +1236,9 @@ Amr::readProbinFile (int& a_init) << "amrex_probinit total time = " << piTotalAll << '\n'; } - if (verbose > 0) + if (verbose > 0) { amrex::Print() << "Successfully run amrex_probinit\n"; + } } #endif @@ -1259,7 +1268,7 @@ Amr::InitializeInit(Real strt_time, { BL_PROFILE("Amr::InitializeInit()"); BL_COMM_PROFILE_NAMETAG("Amr::InitializeInit TOP"); - if (check_input) checkInput(); + if (check_input) { checkInput(); } // // Generate internal values from user-supplied values. // @@ -1304,8 +1313,9 @@ Amr::FinalizeInit (Real strt_time, dt_min[0] = dt_level[0]; n_cycle[0] = 1; - if (max_level > 0) + if (max_level > 0) { bldFineLevels(strt_time); + } for (int lev = 1; lev <= finest_level; lev++) { @@ -1314,11 +1324,13 @@ Amr::FinalizeInit (Real strt_time, dt_min[lev] = dt_level[lev]; } - for (int lev = 0; lev <= finest_level; lev++) + for (int lev = 0; lev <= finest_level; lev++) { amr_level[lev]->setTimeLevel(strt_time,dt_level[lev],dt_level[lev]); + } - for (int lev = 0; lev <= finest_level; lev++) + for (int lev = 0; lev <= finest_level; lev++) { amr_level[lev]->post_regrid(0,finest_level); + } for (int lev = 0; lev <= finest_level; lev++) { @@ -1330,21 +1342,21 @@ Amr::FinalizeInit (Real strt_time, // Perform any special post_initialization operations. // for(int lev(0); lev <= finest_level; ++lev) { - amr_level[lev]->post_init(stop_time); + amr_level[lev]->post_init(stop_time); } if (ParallelDescriptor::IOProcessor()) { - if (verbose > 1) - { - amrex::Print() << "INITIAL GRIDS \n"; - printGridInfo(amrex::OutStream(),0,finest_level); - } - else if (verbose > 0) - { - amrex::Print() << "INITIAL GRIDS \n"; - printGridSummary(amrex::OutStream(),0,finest_level); - } + if (verbose > 1) + { + amrex::Print() << "INITIAL GRIDS \n"; + printGridInfo(amrex::OutStream(),0,finest_level); + } + else if (verbose > 0) + { + amrex::Print() << "INITIAL GRIDS \n"; + printGridSummary(amrex::OutStream(),0,finest_level); + } } if (record_grid_info && ParallelDescriptor::IOProcessor()) @@ -1885,14 +1897,17 @@ Amr::RegridOnly (Real time, bool do_io) if (do_io) { - if (plotfile_on_restart) + if (plotfile_on_restart) { writePlotFile(); + } - if (checkpoint_on_restart) + if (checkpoint_on_restart) { checkPoint(); + } - if (insitu_on_restart) + if (insitu_on_restart) { updateInSitu(); + } } } @@ -2043,8 +2058,9 @@ Amr::timeStep (int level, const int ncycle = n_cycle[lev_fine]; BL_COMM_PROFILE_NAMETAG("Amr::timeStep timeStep subcycle"); - for (int i = 1; i <= ncycle; i++) + for (int i = 1; i <= ncycle; i++) { timeStep(lev_fine,time+static_cast(i-1)*dt_level[lev_fine],i,ncycle,stop_time); + } } else { @@ -2181,8 +2197,9 @@ Amr::coarseTimeStep (Real stop_time) << " TIME = " << cumtime << " DT = " << dt_level[0] << '\n'; } - if (record_run_info_terse && ParallelDescriptor::IOProcessor()) + if (record_run_info_terse && ParallelDescriptor::IOProcessor()) { runlog_terse << level_steps[0] << " " << cumtime << " " << dt_level[0] << '\n'; + } int check_test = 0; @@ -2494,9 +2511,11 @@ Amr::defBaseLevel (Real strt_time, const Box& domain = Geom(0).Domain(); const IntVect& d_len = domain.size(); - for (int idir = 0; idir < AMREX_SPACEDIM; idir++) - if (d_len[idir]%2 != 0) + for (int idir = 0; idir < AMREX_SPACEDIM; idir++) { + if (d_len[idir]%2 != 0) { amrex::Error("defBaseLevel: must have even number of cells"); + } + } BoxArray lev0; @@ -2505,10 +2524,12 @@ Amr::defBaseLevel (Real strt_time, BL_ASSERT(pmap != nullptr); BoxArray domain_ba(domain); - if (!domain_ba.contains(*lev0_grids)) + if (!domain_ba.contains(*lev0_grids)) { amrex::Error("defBaseLevel: domain does not contain lev0_grids!"); - if (!lev0_grids->contains(domain_ba)) + } + if (!lev0_grids->contains(domain_ba)) { amrex::Error("defBaseLevel: lev0_grids does not contain domain"); + } lev0 = *lev0_grids; @@ -2541,10 +2562,11 @@ Amr::regrid (int lbase, { BL_PROFILE("Amr::regrid()"); - if (lbase > std::min(finest_level,max_level-1)) return; + if (lbase > std::min(finest_level,max_level-1)) { return; } - if (verbose > 0) + if (verbose > 0) { amrex::Print() << "Now regridding at level lbase = " << lbase << "\n"; + } // // Compute positions of new grids. @@ -2648,8 +2670,9 @@ Amr::regrid (int lbase, { a->init(); amr_level[lev].reset(a); - if (lev > 0) + if (lev > 0) { level_steps[lev] = level_steps[lev-1] * n_cycle[lev-1]; + } this->SetBoxArray(lev, amr_level[lev]->boxArray()); this->SetDistributionMap(lev, amr_level[lev]->DistributionMap()); } @@ -2677,8 +2700,9 @@ Amr::regrid (int lbase, if (record_grid_info && ParallelDescriptor::IOProcessor()) { - if (lbase == 0) + if (lbase == 0) { gridlog << "STEP = " << level_steps[0] << ' '; + } gridlog << "TIME = " << time @@ -2828,13 +2852,15 @@ Amr::regrid_level_0_on_restart() } } - if (record_grid_info && ParallelDescriptor::IOProcessor()) + if (record_grid_info && ParallelDescriptor::IOProcessor()) { printGridInfo(gridlog,0,finest_level); + } } else { - if (verbose > 0) + if (verbose > 0) { amrex::Print() << "Regridding at level 0 but grids unchanged \n"; + } } } @@ -2870,8 +2896,9 @@ Amr::printGridInfo (std::ostream& os, os << ' ' << lev << ": " << b << " "; - for (int i = 0; i < AMREX_SPACEDIM; i++) + for (int i = 0; i < AMREX_SPACEDIM; i++) { os << b.length(i) << ' '; + } os << ":: " << map[k] << '\n'; } @@ -2908,11 +2935,13 @@ Amr::grid_places (int lbase, for (int i = 0; i < ngrid; i++) { Box bx(initial_ba[lev-1][i]); - if (lev > lbase) + if (lev > lbase) { bl.push_back(bx); + } } - if (lev > lbase) + if (lev > lbase) { new_grids[lev].define(bl); + } } return; } @@ -2931,12 +2960,13 @@ Amr::grid_places (int lbase, { Box bx(initial_ba[lev-1][i]); - if (lev > lbase) + if (lev > lbase) { bl.push_back(bx); - + } } - if (lev > lbase) + if (lev > lbase) { new_grids[lev].define(bl); + } new_grids[lev].maxSize(max_grid_size[lev]); } } @@ -2951,11 +2981,13 @@ Amr::grid_places (int lbase, for (int i = 0; i < ngrid; i++) { Box bx(regrid_ba[lev-1][i]); - if (lev > lbase) + if (lev > lbase) { bl.push_back(bx); + } } - if (lev > lbase) + if (lev > lbase) { new_grids[lev].define(bl); + } } return; } @@ -3011,7 +3043,7 @@ Amr::bldFineLevels (Real strt_time) grid_places(finest_level,strt_time,new_finest,new_grids); - if (new_finest <= finest_level) break; + if (new_finest <= finest_level) { break; } // // Create a new level and link with others. // @@ -3081,10 +3113,11 @@ Amr::initSubcycle () } int nosub; pp.query("nosub",nosub); - if (nosub > 0) + if (nosub > 0) { sub_cycle = false; - else + } else { amrex::Error("nosub <= 0 not allowed.\n"); + } subcycling_mode = "None"; } else @@ -3137,10 +3170,12 @@ Amr::initSubcycle () } for (int i = 1; i <= max_level; i++) { - if (n_cycle[i] > MaxRefRatio(i-1)) + if (n_cycle[i] > MaxRefRatio(i-1)) { amrex::Error("subcycling iterations must always be <= ref_ratio"); - if (n_cycle[i] <= 0) + } + if (n_cycle[i] <= 0) { amrex::Error("subcycling iterations must always be > 0"); + } } } else if (subcycling_mode == "Auto") @@ -3181,8 +3216,8 @@ Amr::initPltAndChk () // // -1 ==> use ParallelDescriptor::NProcs(). // - if (plot_nfiles == -1) plot_nfiles = ParallelDescriptor::NProcs(); - if (checkpoint_nfiles == -1) checkpoint_nfiles = ParallelDescriptor::NProcs(); + if (plot_nfiles == -1) { plot_nfiles = ParallelDescriptor::NProcs(); } + if (checkpoint_nfiles == -1) { checkpoint_nfiles = ParallelDescriptor::NProcs(); } check_file_root = "chk"; pp.queryAdd("check_file",check_file_root); @@ -3195,8 +3230,9 @@ Amr::initPltAndChk () if (check_int > 0 && check_per > 0) { - if (ParallelDescriptor::IOProcessor()) + if (ParallelDescriptor::IOProcessor()) { amrex::Warning("Warning: both amr.check_int and amr.check_per are > 0."); + } } plot_file_root = "plt"; @@ -3213,8 +3249,9 @@ Amr::initPltAndChk () if (plot_int > 0 && plot_per > 0) { - if (ParallelDescriptor::IOProcessor()) + if (ParallelDescriptor::IOProcessor()) { amrex::Warning("Warning: both amr.plot_int and amr.plot_per are > 0."); + } } small_plot_file_root = "smallplt"; @@ -3231,8 +3268,9 @@ Amr::initPltAndChk () if (small_plot_int > 0 && small_plot_per > 0) { - if (ParallelDescriptor::IOProcessor()) + if (ParallelDescriptor::IOProcessor()) { amrex::Warning("Warning: both amr.small_plot_int and amr.small_plot_per are > 0."); + } } write_plotfile_with_checkpoint = 1; @@ -3251,11 +3289,11 @@ Amr::initPltAndChk () int phvInt(plot_headerversion), chvInt(checkpoint_headerversion); pp.queryAdd("plot_headerversion", phvInt); if(phvInt != plot_headerversion) { - plot_headerversion = static_cast (phvInt); + plot_headerversion = static_cast (phvInt); } pp.queryAdd("checkpoint_headerversion", chvInt); if(chvInt != checkpoint_headerversion) { - checkpoint_headerversion = static_cast (chvInt); + checkpoint_headerversion = static_cast (chvInt); } } @@ -3263,10 +3301,11 @@ Amr::initPltAndChk () bool Amr::okToRegrid(int level) noexcept { - if (regrid_int[level] < 0) + if (regrid_int[level] < 0) { return false; - else + } else { return level_count[level] >= regrid_int[level] && amr_level[level]->okToRegrid(); + } } Real @@ -3287,8 +3326,9 @@ Amr::computeOptimalSubcycling(int n, int* best, const Real* dt_max, const Real* Real work; int limit = 1; // This provides a memory efficient way to test all candidates - for (int i = 1; i < n; i++) + for (int i = 1; i < n; i++) { limit *= cycle_max[i]; + } for (int candidate = 0; candidate < limit; candidate++) { int temp_cand = candidate; @@ -3306,8 +3346,9 @@ Amr::computeOptimalSubcycling(int n, int* best, const Real* dt_max, const Real* ratio = work/dt; if (ratio < best_ratio) { - for (int i = 0; i < n; i++) + for (int i = 0; i < n; i++) { best[i] = cycles[i]; + } best_ratio = ratio; best_dt = dt; } @@ -3315,8 +3356,9 @@ Amr::computeOptimalSubcycling(int n, int* best, const Real* dt_max, const Real* // // Now we convert best back to n_cycles format // - for (int i = n-1; i > 0; i--) + for (int i = n-1; i > 0; i--) { best[i] /= best[i-1]; + } return best_dt; } diff --git a/Src/Amr/AMReX_AmrLevel.cpp b/Src/Amr/AMReX_AmrLevel.cpp index 7ef14b505fb..7cdd83e1cae 100644 --- a/Src/Amr/AMReX_AmrLevel.cpp +++ b/Src/Amr/AMReX_AmrLevel.cpp @@ -123,7 +123,7 @@ AmrLevel::AmrLevel (Amr& papa, *m_factory); } - if (parent->useFixedCoarseGrids()) constructAreaNotToTag(); + if (parent->useFixedCoarseGrids()) { constructAreaNotToTag(); } post_step_regrid = 0; @@ -186,8 +186,9 @@ AmrLevel::writePlotFile (const std::string& dir, // os << thePlotFileType() << '\n'; - if (n_data_items == 0) + if (n_data_items == 0) { amrex::Error("Must specify at least one valid data item to plot"); + } os << n_data_items << '\n'; @@ -219,25 +220,31 @@ AmrLevel::writePlotFile (const std::string& dir, os << parent->cumTime() << '\n'; int f_lev = parent->finestLevel(); os << f_lev << '\n'; - for (i = 0; i < AMREX_SPACEDIM; i++) + for (i = 0; i < AMREX_SPACEDIM; i++) { os << Geom().ProbLo(i) << ' '; + } os << '\n'; - for (i = 0; i < AMREX_SPACEDIM; i++) + for (i = 0; i < AMREX_SPACEDIM; i++) { os << Geom().ProbHi(i) << ' '; + } os << '\n'; - for (i = 0; i < f_lev; i++) + for (i = 0; i < f_lev; i++) { os << parent->refRatio(i)[0] << ' '; + } os << '\n'; - for (i = 0; i <= f_lev; i++) + for (i = 0; i <= f_lev; i++) { os << parent->Geom(i).Domain() << ' '; + } os << '\n'; - for (i = 0; i <= f_lev; i++) + for (i = 0; i <= f_lev; i++) { os << parent->levelSteps(i) << ' '; + } os << '\n'; for (i = 0; i <= f_lev; i++) { - for (int k = 0; k < AMREX_SPACEDIM; k++) + for (int k = 0; k < AMREX_SPACEDIM; k++) { os << parent->Geom(i).CellSize()[k] << ' '; + } os << '\n'; } os << (int) Geom().Coord() << '\n'; @@ -281,8 +288,9 @@ AmrLevel::writePlotFile (const std::string& dir, for (i = 0; i < grids.size(); ++i) { RealBox gridloc = RealBox(grids[i],geom.CellSize(),geom.ProbLo()); - for (n = 0; n < AMREX_SPACEDIM; n++) + for (n = 0; n < AMREX_SPACEDIM; n++) { os << gridloc.lo(n) << ' ' << gridloc.hi(n) << '\n'; +} } // // The full relative pathname of the MultiFabs at this level. @@ -447,7 +455,7 @@ AmrLevel::restart (Amr& papa, m_fillpatcher.resize(ndesc); - if (parent->useFixedCoarseGrids()) constructAreaNotToTag(); + if (parent->useFixedCoarseGrids()) { constructAreaNotToTag(); } post_step_regrid = 0; @@ -483,8 +491,9 @@ AmrLevel::isStateVariable (const std::string& name, int& state_indx, int& n) for (n = 0; n < desc.nComp(); n++) { - if (desc.name(n) == name) + if (desc.name(n) == name) { return true; + } } } return false; @@ -773,7 +782,7 @@ FillPatchIteratorHelper::Initialize (int boxGrow, using IntAAAFBIDMapValType = std::map > > >::value_type; - if (m_leveldata.DistributionMap()[i] != MyProc) continue; + if (m_leveldata.DistributionMap()[i] != MyProc) { continue; } // // Insert with a hint since the indices are ordered lowest to highest. // @@ -1179,7 +1188,7 @@ FixUpPhysCorners (FArrayBox& fab, const Geometry& TheGeom = TheLevel.Geom(); const Box& ProbDomain = TheState.getDomain(); - if (!HasPhysBndry(fab.box(),ProbDomain,TheGeom)) return; + if (!HasPhysBndry(fab.box(),ProbDomain,TheGeom)) { return; } FArrayBox tmp; @@ -1191,14 +1200,14 @@ FixUpPhysCorners (FArrayBox& fab, { const int lo = ProbDomain.smallEnd(dir) - fab.box().smallEnd(dir); const int hi = fab.box().bigEnd(dir) - ProbDomain.bigEnd(dir); - if (lo > 0) GrownDomain.growLo(dir,lo); - if (hi > 0) GrownDomain.growHi(dir,hi); + if (lo > 0) { GrownDomain.growLo(dir,lo); } + if (hi > 0) { GrownDomain.growHi(dir,hi); } } } for (int dir = 0; dir < AMREX_SPACEDIM; dir++) { - if (!TheGeom.isPeriodic(dir)) continue; + if (!TheGeom.isPeriodic(dir)) { continue; } Box lo_slab = fab.box(); Box hi_slab = fab.box(); @@ -1331,7 +1340,7 @@ FillPatchIteratorHelper::fill (FArrayBox& fab, { FArrayBox& dstfab = *CrseFabs[i]; - if (ThePDomain.contains(dstfab.box())) continue; + if (ThePDomain.contains(dstfab.box())) { continue; } Vector pshifts(27); @@ -1469,8 +1478,9 @@ FillPatchIteratorHelper::fill (FArrayBox& fab, Box src_dst = FinestCrseFabs[i]->box() & fab.box(); src_dst &= FineDomain; - if (src_dst.ok()) + if (src_dst.ok()) { fab.copy(*FinestCrseFabs[i],src_dst,0,src_dst,dcomp,m_ncomp); + } fab.shift(-iv); } @@ -1856,8 +1866,9 @@ AmrLevel::getBCArray (int State_Type, { bcr = state[State_Type].getBC(strt_comp+n,gridno); const int* b_rec = bcr.vect(); - for (int m = 0; m < 2*AMREX_SPACEDIM; m++) + for (int m = 0; m < 2*AMREX_SPACEDIM; m++) { bc[2*AMREX_SPACEDIM*n + m] = b_rec[m]; + } } return bc; @@ -1884,12 +1895,13 @@ AmrLevel::setPlotVariables () { pp.get("plot_vars", nm, i); - if (nm == "ALL") + if (nm == "ALL") { amrex::Amr::fillStatePlotVarList(); - else if (nm == "NONE") + } else if (nm == "NONE") { amrex::Amr::clearStatePlotVarList(); - else + } else { amrex::Amr::addStatePlotVar(nm); + } } } else @@ -1910,12 +1922,13 @@ AmrLevel::setPlotVariables () { pp.get("derive_plot_vars", nm, i); - if (nm == "ALL") + if (nm == "ALL") { amrex::Amr::fillDerivePlotVarList(); - else if (nm == "NONE") + } else if (nm == "NONE") { amrex::Amr::clearDerivePlotVarList(); - else + } else { amrex::Amr::addDerivePlotVar(nm); + } } } else @@ -1942,12 +1955,13 @@ AmrLevel::setSmallPlotVariables () { pp.get("small_plot_vars", nm, i); - if (nm == "ALL") + if (nm == "ALL") { amrex::Amr::fillStateSmallPlotVarList(); - else if (nm == "NONE") + } else if (nm == "NONE") { amrex::Amr::clearStateSmallPlotVarList(); - else + } else { amrex::Amr::addStateSmallPlotVar(nm); + } } } else @@ -1968,12 +1982,13 @@ AmrLevel::setSmallPlotVariables () { pp.get("derive_small_plot_vars", nm, i); - if (nm == "ALL") + if (nm == "ALL") { amrex::Amr::fillDeriveSmallPlotVarList(); - else if (nm == "NONE") + } else if (nm == "NONE") { amrex::Amr::clearDeriveSmallPlotVarList(); - else + } else { amrex::Amr::addDeriveSmallPlotVar(nm); + } } } else @@ -2056,8 +2071,9 @@ void AmrLevel::setAreaNotToTag (BoxArray& ba) noexcept void AmrLevel::constructAreaNotToTag () { - if (level == 0 || !parent->useFixedCoarseGrids() || parent->useFixedUpToLevel()>level) + if (level == 0 || !parent->useFixedCoarseGrids() || parent->useFixedUpToLevel()>level) { return; + } // We are restricting the tagging on the finest fixed level if (parent->useFixedUpToLevel()==level) diff --git a/Src/Amr/AMReX_AuxBoundaryData.H b/Src/Amr/AMReX_AuxBoundaryData.H index 7e5aadf5575..bfaf7df8a2c 100644 --- a/Src/Amr/AMReX_AuxBoundaryData.H +++ b/Src/Amr/AMReX_AuxBoundaryData.H @@ -58,7 +58,7 @@ public: BL_ASSERT(!m_empty); BL_ASSERT(m_initialized); return m_fabs.boxArray(); } - void setVal (Real r) { BL_ASSERT(m_initialized); if (!m_empty) m_fabs.setVal(r); } + void setVal (Real r) { BL_ASSERT(m_initialized); if (!m_empty) { m_fabs.setVal(r); } } const DistributionMapping& DistributionMap () const noexcept { diff --git a/Src/Amr/AMReX_AuxBoundaryData.cpp b/Src/Amr/AMReX_AuxBoundaryData.cpp index fb8ffd6743e..361e09fe068 100644 --- a/Src/Amr/AMReX_AuxBoundaryData.cpp +++ b/Src/Amr/AMReX_AuxBoundaryData.cpp @@ -25,7 +25,7 @@ AuxBoundaryData::copy (const AuxBoundaryData& src, int dst_comp, int num_comp) { - if (m_empty || src.m_empty) return; + if (m_empty || src.m_empty) { return; } BL_ASSERT(m_initialized); BL_ASSERT(src_comp + num_comp <= src.m_fabs.nComp()); diff --git a/Src/Amr/AMReX_Derive.cpp b/Src/Amr/AMReX_Derive.cpp index 14f8f809d39..7b9a55e48cc 100644 --- a/Src/Amr/AMReX_Derive.cpp +++ b/Src/Amr/AMReX_Derive.cpp @@ -328,8 +328,9 @@ const std::string& DeriveRec::variableName(int comp) const noexcept { - if (comp < variable_names.size()) + if (comp < variable_names.size()) { return variable_names[comp]; + } return derive_name; } @@ -426,12 +427,14 @@ DeriveList::canDerive (const std::string& name) const { // Can be either a component name ... for (int i = 0; i < li.numDerive(); i++) { - if (li.variableName(i) == name) + if (li.variableName(i) == name) { return true; + } } // ... or a derive name - if (li.derive_name == name) + if (li.derive_name == name) { return true; + } } return false; } @@ -443,12 +446,14 @@ DeriveList::get (const std::string& name) const { // Can be either a component name ... for (int i = 0; i < li.numDerive(); i++) { - if (li.variableName(i) == name) + if (li.variableName(i) == name) { return &(li); + } } // ... or a derive name - if (li.derive_name == name) + if (li.derive_name == name) { return &(li); + } } return nullptr; } diff --git a/Src/Amr/AMReX_Extrapolater.cpp b/Src/Amr/AMReX_Extrapolater.cpp index ca3f4d525ec..cbac2648b9b 100644 --- a/Src/Amr/AMReX_Extrapolater.cpp +++ b/Src/Amr/AMReX_Extrapolater.cpp @@ -44,7 +44,7 @@ namespace amrex::Extrapolater [=] AMREX_GPU_DEVICE (int i, int j, int k, int n) noexcept { if (!gbx.contains(i,j,k)) { - if (mask_arr(i,j,k) == crsebnd) data_arr(i,j,k,n) = 0.0; + if (mask_arr(i,j,k) == crsebnd) { data_arr(i,j,k,n) = 0.0; } } }); ParallelFor(amrex::grow(gbx,1), ncomp, diff --git a/Src/Amr/AMReX_StateData.cpp b/Src/Amr/AMReX_StateData.cpp index b7429fd33e6..fffa8074e8b 100644 --- a/Src/Amr/AMReX_StateData.cpp +++ b/Src/Amr/AMReX_StateData.cpp @@ -442,7 +442,7 @@ StateData::FillBoundary (FArrayBox& dest, BL_PROFILE("StateData::FillBoundary(dx)"); BL_ASSERT(dest.box().ixType() == desc->getType()); - if (domain.contains(dest.box())) return; + if (domain.contains(dest.box())) { return; } const Box& bx = dest.box(); const int* dlo = dest.loVect(); @@ -487,8 +487,9 @@ StateData::FillBoundary (FArrayBox& dest, const int* bc = bcr.vect(); - for (int k = 0; k < 2*AMREX_SPACEDIM; k++) + for (int k = 0; k < 2*AMREX_SPACEDIM; k++) { bci[k] = bc[k]; + } bci += 2*AMREX_SPACEDIM; } @@ -531,7 +532,7 @@ StateData::FillBoundary (Box const& bx, { BL_PROFILE("StateData::FillBoundary(geom)"); - if (domain.contains(convert(bx,domain.ixType()))) return; + if (domain.contains(convert(bx,domain.ixType()))) { return; } Vector bcr(num_comp); @@ -925,14 +926,14 @@ StateDataPhysBCFunct::operator() (MultiFab& mf, int dest_comp, int num_comp, Int { const int lo = domainlo[dir] - bx.smallEnd(dir); const int hi = bx.bigEnd(dir) - domainhi[dir]; - if (lo > 0) GrownDomain.growLo(dir,lo); - if (hi > 0) GrownDomain.growHi(dir,hi); + if (lo > 0) { GrownDomain.growLo(dir,lo); } + if (hi > 0) { GrownDomain.growHi(dir,hi); } } } for (int dir = 0; dir < AMREX_SPACEDIM; dir++) { - if (!geom.isPeriodic(dir)) continue; + if (!geom.isPeriodic(dir)) { continue; } Box lo_slab = bx; Box hi_slab = bx; diff --git a/Src/Amr/AMReX_StateDescriptor.cpp b/Src/Amr/AMReX_StateDescriptor.cpp index aa9d15445a4..161090d1a7f 100644 --- a/Src/Amr/AMReX_StateDescriptor.cpp +++ b/Src/Amr/AMReX_StateDescriptor.cpp @@ -21,7 +21,7 @@ StateDescriptor::bf_thread_safety (const int* /*lo*/,const int* /*hi*/, for (int i=0; i<2*AMREX_SPACEDIM*ng && !has_ext_dir; ++i) { has_ext_dir = bc[i]==BCType::ext_dir; } - if (has_ext_dir) thread_safe = false; + if (has_ext_dir) { thread_safe = false; } } return thread_safe; } @@ -417,7 +417,7 @@ StateDescriptor::setUpMaps (int& use_default_map, // First, count number of interpolaters needed and allocate. // InterpBase* map = mapper_comp[start_comp]; - if (!map) map = (InterpBase*) default_map; + if (!map) { map = (InterpBase*) default_map; } nmaps = 1; int icomp = start_comp+1; @@ -441,7 +441,7 @@ StateDescriptor::setUpMaps (int& use_default_map, icomp++; } - if (use_default_map) return; + if (use_default_map) { return; } maps = new InterpBase*[nmaps]; map_start_comp = new int[nmaps]; @@ -472,8 +472,9 @@ StateDescriptor::setUpMaps (int& use_default_map, { InterpBase* mapper_icomp = mapper_comp[icomp]; - if (!mapper_icomp) + if (!mapper_icomp) { mapper_icomp = (InterpBase *) default_map; + } if (maps[imap] != mapper_icomp) { @@ -521,9 +522,11 @@ StateDescriptor::identicalInterps (int a_scomp, InterpBase* map = interp(a_scomp); - for (int i = a_scomp+1; i < a_scomp+a_ncomp; i++) - if (!(map == interp(i))) + for (int i = a_scomp+1; i < a_scomp+a_ncomp; i++) { + if (!(map == interp(i))) { return false; + } + } return true; } diff --git a/Src/Amr/AMReX_extrapolater_2D_K.H b/Src/Amr/AMReX_extrapolater_2D_K.H index b3bb3b8281a..33296c545e9 100644 --- a/Src/Amr/AMReX_extrapolater_2D_K.H +++ b/Src/Amr/AMReX_extrapolater_2D_K.H @@ -28,21 +28,21 @@ amrex_first_order_extrap_cpu(amrex::Box const& bx, { // y-dir edges int j = lo.y-1; for (int i = lo.x-1; i <= hi.x+1; ++i) { - if (mask(i,j,k) == crsecell) data(i,j,k,n) = Real(0.0); + if (mask(i,j,k) == crsecell) { data(i,j,k,n) = Real(0.0); } } j = hi.y+1; for (int i = lo.x-1; i <= hi.x+1; ++i) { - if (mask(i,j,k) == crsecell) data(i,j,k,n) = Real(0.0); + if (mask(i,j,k) == crsecell) { data(i,j,k,n) = Real(0.0); } } } { // x-dir edges int i = lo.x-1; for (int j = lo.y-1; j <= hi.y+1; ++j) { - if (mask(i,j,k) == crsecell) data(i,j,k,n) = Real(0.0); + if (mask(i,j,k) == crsecell) { data(i,j,k,n) = Real(0.0); } } i = hi.x+1; for (int j = lo.y-1; j <= hi.y+1; ++j) { - if (mask(i,j,k) == crsecell) data(i,j,k,n) = Real(0.0); + if (mask(i,j,k) == crsecell) { data(i,j,k,n) = Real(0.0); } } } diff --git a/Src/Amr/AMReX_extrapolater_3D_K.H b/Src/Amr/AMReX_extrapolater_3D_K.H index 63ff96b3265..ccf0b7506ba 100644 --- a/Src/Amr/AMReX_extrapolater_3D_K.H +++ b/Src/Amr/AMReX_extrapolater_3D_K.H @@ -27,13 +27,13 @@ amrex_first_order_extrap_cpu(amrex::Box const& bx, int k = lo.z-1; for (int j = lo.y-1; j <= hi.y+1; ++j) { for (int i = lo.x-1; i <= hi.x+1; ++i) { - if (mask(i,j,k) == crsecell) data(i,j,k,n) = Real(0.0); + if (mask(i,j,k) == crsecell) { data(i,j,k,n) = Real(0.0); } } } k = hi.z+1; for (int j = lo.y-1; j <= hi.y+1; ++j) { for (int i = lo.x-1; i <= hi.x+1; ++i) { - if (mask(i,j,k) == crsecell) data(i,j,k,n) = Real(0.0); + if (mask(i,j,k) == crsecell) { data(i,j,k,n) = Real(0.0); } } } } @@ -41,13 +41,13 @@ amrex_first_order_extrap_cpu(amrex::Box const& bx, int j = lo.y-1; for (int k = lo.z-1; k <= hi.z+1; ++k) { for (int i = lo.x-1; i <= hi.x+1; ++i) { - if (mask(i,j,k) == crsecell) data(i,j,k,n) = Real(0.0); + if (mask(i,j,k) == crsecell) { data(i,j,k,n) = Real(0.0); } } } j = hi.y+1; for (int k = lo.z-1; k <= hi.z+1; ++k) { for (int i = lo.x-1; i <= hi.x+1; ++i) { - if (mask(i,j,k) == crsecell) data(i,j,k,n) = Real(0.0); + if (mask(i,j,k) == crsecell) { data(i,j,k,n) = Real(0.0); } } } } @@ -55,13 +55,13 @@ amrex_first_order_extrap_cpu(amrex::Box const& bx, int i = lo.x-1; for (int k = lo.z-1; k <= hi.z+1; ++k) { for (int j = lo.y-1; j <= hi.y+1; ++j) { - if (mask(i,j,k) == crsecell) data(i,j,k,n) = Real(0.0); + if (mask(i,j,k) == crsecell) { data(i,j,k,n) = Real(0.0); } } } i = hi.x+1; for (int k = lo.z-1; k <= hi.z+1; ++k) { for (int j = lo.y-1; j <= hi.y+1; ++j) { - if (mask(i,j,k) == crsecell) data(i,j,k,n) = Real(0.0); + if (mask(i,j,k) == crsecell) { data(i,j,k,n) = Real(0.0); } } } }