diff --git a/Tests/Amr/Advection_AmrCore/Source/AmrCoreAdv.cpp b/Tests/Amr/Advection_AmrCore/Source/AmrCoreAdv.cpp index ea60a0a4077..48a5d96e37d 100644 --- a/Tests/Amr/Advection_AmrCore/Source/AmrCoreAdv.cpp +++ b/Tests/Amr/Advection_AmrCore/Source/AmrCoreAdv.cpp @@ -117,10 +117,11 @@ AmrCoreAdv::Evolve () int lev = 0; int iteration = 1; - if (do_subcycle) + if (do_subcycle) { timeStepWithSubcycling(lev, cur_time, iteration); - else + } else { timeStepNoSubcycling(cur_time, iteration); + } cur_time += dt[0]; @@ -152,7 +153,7 @@ AmrCoreAdv::Evolve () } #endif - if (cur_time >= stop_time - 1.e-6*dt[0]) break; + if (cur_time >= stop_time - 1.e-6*dt[0]) { break; } } if (plot_int > 0 && istep[0] > last_plot_file_step) { @@ -332,7 +333,7 @@ AmrCoreAdv::ErrorEst (int lev, TagBoxArray& tags, Real /*time*/, int /*ngrow*/) } } - if (lev >= phierr.size()) return; + if (lev >= phierr.size()) { return; } // const int clearval = TagBox::CLEAR; const int tagval = TagBox::SET; @@ -722,8 +723,9 @@ AmrCoreAdv::timeStepNoSubcycling (Real time, int iteration) fp.reset(); // Because the data have changed. } - for (int lev = 0; lev <= finest_level; lev++) + for (int lev = 0; lev <= finest_level; lev++) { ++istep[lev]; + } if (Verbose()) { @@ -745,7 +747,7 @@ AmrCoreAdv::ComputeDt () { dt_tmp[lev] = EstTimeStep(lev, t_new[lev]); } - ParallelDescriptor::ReduceRealMin(&dt_tmp[0], int(dt_tmp.size())); + ParallelDescriptor::ReduceRealMin(dt_tmp.data(), int(dt_tmp.size())); constexpr Real change_max = 1.1; Real dt_0 = dt_tmp[0]; diff --git a/Tests/Amr/Advection_AmrCore/Source/DefineVelocity.cpp b/Tests/Amr/Advection_AmrCore/Source/DefineVelocity.cpp index 4dc1076dec8..4591a85375f 100644 --- a/Tests/Amr/Advection_AmrCore/Source/DefineVelocity.cpp +++ b/Tests/Amr/Advection_AmrCore/Source/DefineVelocity.cpp @@ -8,8 +8,9 @@ using namespace amrex; void AmrCoreAdv::DefineVelocityAllLevels (Real time) { - for (int lev = 0; lev <= finest_level; ++lev) + for (int lev = 0; lev <= finest_level; ++lev) { DefineVelocityAtLevel(lev,time); + } } void diff --git a/Tests/Amr/Advection_AmrCore/Source/Tagging.H b/Tests/Amr/Advection_AmrCore/Source/Tagging.H index ace85b04ed2..6f05edd2260 100644 --- a/Tests/Amr/Advection_AmrCore/Source/Tagging.H +++ b/Tests/Amr/Advection_AmrCore/Source/Tagging.H @@ -11,8 +11,9 @@ state_error (int i, int j, int k, amrex::Array4 const& state, amrex::Real phierr, char tagval) { - if (state(i,j,k) > phierr) + if (state(i,j,k) > phierr) { tag(i,j,k) = tagval; + } } #endif diff --git a/Tests/Amr/Advection_AmrLevel/Source/AmrLevelAdv.cpp b/Tests/Amr/Advection_AmrLevel/Source/AmrLevelAdv.cpp index ecf7aec9f73..f9d13cec1d7 100644 --- a/Tests/Amr/Advection_AmrLevel/Source/AmrLevelAdv.cpp +++ b/Tests/Amr/Advection_AmrLevel/Source/AmrLevelAdv.cpp @@ -368,8 +368,9 @@ AmrLevelAdv::advance (Real time, #ifndef AMREX_USE_GPU if (do_reflux) { - for (int i = 0; i < BL_SPACEDIM ; i++) + for (int i = 0; i < BL_SPACEDIM ; i++) { fluxes[i][mfi].copy(*flux[i],mfi.nodaltilebox(i)); + } } #endif } @@ -378,12 +379,14 @@ AmrLevelAdv::advance (Real time, if (do_reflux) { if (current) { - for (int i = 0; i < BL_SPACEDIM ; i++) + for (int i = 0; i < BL_SPACEDIM ; i++) { current->FineAdd(fluxes[i],i,0,0,NUM_STATE,1.); + } } if (fine) { - for (int i = 0; i < BL_SPACEDIM ; i++) + for (int i = 0; i < BL_SPACEDIM ; i++) { fine->CrseInit(fluxes[i],i,0,0,NUM_STATE,-1.); + } } } @@ -477,8 +480,9 @@ AmrLevelAdv::computeInitialDt (int finest_level, // // Grids have been constructed, compute dt for all levels. // - if (level > 0) + if (level > 0) { return; + } Real dt_0 = 1.0e+100; int n_factor = 1; @@ -495,8 +499,9 @@ AmrLevelAdv::computeInitialDt (int finest_level, const Real eps = 0.001*dt_0; Real cur_time = state[Phi_Type].curTime(); if (stop_time >= 0.0) { - if ((cur_time + dt_0) > (stop_time - eps)) + if ((cur_time + dt_0) > (stop_time - eps)) { dt_0 = stop_time - cur_time; + } } n_factor = 1; @@ -524,8 +529,9 @@ AmrLevelAdv::computeNewDt (int finest_level, // We are at the end of a coarse grid timecycle. // Compute the timesteps for the next iteration. // - if (level > 0) + if (level > 0) { return; + } for (int i = 0; i <= finest_level; i++) { @@ -572,8 +578,9 @@ AmrLevelAdv::computeNewDt (int finest_level, const Real eps = 0.001*dt_0; Real cur_time = state[Phi_Type].curTime(); if (stop_time >= 0.0) { - if ((cur_time + dt_0) > (stop_time - eps)) + if ((cur_time + dt_0) > (stop_time - eps)) { dt_0 = stop_time - cur_time; + } } n_factor = 1; @@ -660,15 +667,17 @@ AmrLevelAdv::post_restart() void AmrLevelAdv::post_init (Real /*stop_time*/) { - if (level > 0) + if (level > 0) { return; + } // // Average data down from finer levels // so that conserved data is consistent between levels. // int finest_level = parent->finestLevel(); - for (int k = finest_level-1; k>= 0; k--) + for (int k = finest_level-1; k>= 0; k--) { getLevel(k).avgDown(); + } } /** @@ -737,7 +746,7 @@ AmrLevelAdv::read_params () { static bool done = false; - if (done) return; + if (done) { return; } done = true; @@ -793,14 +802,14 @@ AmrLevelAdv::reflux () void AmrLevelAdv::avgDown () { - if (level == parent->finestLevel()) return; + if (level == parent->finestLevel()) { return; } avgDown(Phi_Type); } void AmrLevelAdv::avgDown (int state_indx) { - if (level == parent->finestLevel()) return; + if (level == parent->finestLevel()) { return; } AmrLevelAdv& fine_lev = getLevel(level+1); MultiFab& S_fine = fine_lev.get_new_data(state_indx); diff --git a/Tests/DivFreePatch/main.cpp b/Tests/DivFreePatch/main.cpp index 2eb6fb8a4a4..77973484a8d 100644 --- a/Tests/DivFreePatch/main.cpp +++ b/Tests/DivFreePatch/main.cpp @@ -463,7 +463,7 @@ void main_main () } // Make sure coarse & fine are properly setup for the interpolation stencil. - amrex::average_down_faces( {AMREX_D_DECL(&f_mf_faces[0], &f_mf_faces[1], &f_mf_faces[2])}, coarse_faces, ratio, 0); + amrex::average_down_faces( {AMREX_D_DECL(f_mf_faces.data(), f_mf_faces.data()+1, f_mf_faces.data()+2)}, coarse_faces, ratio, 0); Vector > fine_v; Vector > coarse_v; diff --git a/Tests/EB/CNS/Source/CNS.cpp b/Tests/EB/CNS/Source/CNS.cpp index 3ab01b68dd0..c2416c54339 100644 --- a/Tests/EB/CNS/Source/CNS.cpp +++ b/Tests/EB/CNS/Source/CNS.cpp @@ -142,8 +142,9 @@ CNS::computeInitialDt (int finest_level, const Real eps = 0.001*dt_0; Real cur_time = state[State_Type].curTime(); if (stop_time >= 0.0) { - if ((cur_time + dt_0) > (stop_time - eps)) + if ((cur_time + dt_0) > (stop_time - eps)) { dt_0 = stop_time - cur_time; + } } n_factor = 1; @@ -286,7 +287,7 @@ CNS::printTotal () const void CNS::post_init (Real) { - if (level > 0) return; + if (level > 0) { return; } for (int k = parent->finestLevel()-1; k >= 0; --k) { getLevel(k).avgDown(); } @@ -382,7 +383,7 @@ CNS::read_params () Vector tilesize(AMREX_SPACEDIM); if (pp.queryarr("hydro_tile_size", tilesize, 0, AMREX_SPACEDIM)) { - for (int i=0; ifinestLevel()) return; + if (level == parent->finestLevel()) { return; } auto& fine_lev = getLevel(level+1); diff --git a/Tests/EB/CNS/Source/CNS_advance.cpp b/Tests/EB/CNS/Source/CNS_advance.cpp index d38d05632ef..213383cf21e 100644 --- a/Tests/EB/CNS/Source/CNS_advance.cpp +++ b/Tests/EB/CNS/Source/CNS_advance.cpp @@ -117,11 +117,11 @@ CNS::compute_dSdt (const MultiFab& S, MultiFab& dSdt, Real dt, dx, &dt,&level); if (fr_as_crse) { - fr_as_crse->CrseAdd(mfi,{&flux[0],&flux[1],&flux[2]},dx,dt,RunOn::Cpu); + fr_as_crse->CrseAdd(mfi,{flux.data(),flux.data()+1,flux.data()+2},dx,dt,RunOn::Cpu); } if (fr_as_fine) { - fr_as_fine->FineAdd(mfi,{&flux[0],&flux[1],&flux[2]},dx,dt,RunOn::Cpu); + fr_as_fine->FineAdd(mfi,{flux.data(),flux.data()+1,flux.data()+2},dx,dt,RunOn::Cpu); } } else @@ -159,7 +159,7 @@ CNS::compute_dSdt (const MultiFab& S, MultiFab& dSdt, Real dt, dx, &dt,&level); if (fr_as_crse) { - fr_as_crse->CrseAdd(mfi, {&flux[0],&flux[1],&flux[2]}, dx,dt, + fr_as_crse->CrseAdd(mfi, {flux.data(),flux.data()+1,flux.data()+2}, dx,dt, (*volfrac)[mfi], {&((*areafrac[0])[mfi]), &((*areafrac[1])[mfi]), @@ -168,7 +168,7 @@ CNS::compute_dSdt (const MultiFab& S, MultiFab& dSdt, Real dt, } if (fr_as_fine) { - fr_as_fine->FineAdd(mfi, {&flux[0],&flux[1],&flux[2]}, dx,dt, + fr_as_fine->FineAdd(mfi, {flux.data(),flux.data()+1,flux.data()+2}, dx,dt, (*volfrac)[mfi], {&((*areafrac[0])[mfi]), &((*areafrac[1])[mfi]), diff --git a/Tests/EB_CNS/Source/CNS.cpp b/Tests/EB_CNS/Source/CNS.cpp index 5bb3c4e2532..40882a4edb0 100644 --- a/Tests/EB_CNS/Source/CNS.cpp +++ b/Tests/EB_CNS/Source/CNS.cpp @@ -293,7 +293,7 @@ CNS::printTotal () const void CNS::post_init (Real) { - if (level > 0) return; + if (level > 0) { return; } for (int k = parent->finestLevel()-1; k >= 0; --k) { getLevel(k).avgDown(); } @@ -462,7 +462,7 @@ CNS::avgDown () { BL_PROFILE("CNS::avgDown()"); - if (level == parent->finestLevel()) return; + if (level == parent->finestLevel()) { return; } auto& fine_lev = getLevel(level+1); diff --git a/Tests/GPU/CNS/Source/CNS.cpp b/Tests/GPU/CNS/Source/CNS.cpp index 1a073c68c8a..25823b9b76d 100644 --- a/Tests/GPU/CNS/Source/CNS.cpp +++ b/Tests/GPU/CNS/Source/CNS.cpp @@ -284,7 +284,7 @@ CNS::printTotal () const void CNS::post_init (Real) { - if (level > 0) return; + if (level > 0) { return; } for (int k = parent->finestLevel()-1; k >= 0; --k) { getLevel(k).avgDown(); } @@ -401,7 +401,7 @@ CNS::avgDown () { BL_PROFILE("CNS::avgDown()"); - if (level == parent->finestLevel()) return; + if (level == parent->finestLevel()) { return; } auto& fine_lev = getLevel(level+1); diff --git a/Tests/LinearSolvers/CellEB/MyTest.cpp b/Tests/LinearSolvers/CellEB/MyTest.cpp index 473c72ed758..f7e83e1b848 100644 --- a/Tests/LinearSolvers/CellEB/MyTest.cpp +++ b/Tests/LinearSolvers/CellEB/MyTest.cpp @@ -78,8 +78,11 @@ MyTest::solve () mlmg.setBottomTolerance(bottom_reltol); mlmg.setVerbose(verbose); mlmg.setBottomVerbose(bottom_verbose); - if (use_hypre) mlmg.setBottomSolver(MLMG::BottomSolver::hypre); - if (use_petsc) mlmg.setBottomSolver(MLMG::BottomSolver::petsc); + if (use_hypre) { + mlmg.setBottomSolver(MLMG::BottomSolver::hypre); + } else if (use_petsc) { + mlmg.setBottomSolver(MLMG::BottomSolver::petsc); + } const Real tol_rel = reltol; const Real tol_abs = 0.0; mlmg.solve(amrex::GetVecOfPtrs(phi), amrex::GetVecOfConstPtrs(rhs), tol_rel, tol_abs); diff --git a/Tests/LinearSolvers/NodalPoisson/main.cpp b/Tests/LinearSolvers/NodalPoisson/main.cpp index db78e65acd1..3e0d102a401 100644 --- a/Tests/LinearSolvers/NodalPoisson/main.cpp +++ b/Tests/LinearSolvers/NodalPoisson/main.cpp @@ -13,8 +13,9 @@ int main (int argc, char* argv[]) mytest.solve(); mytest.compute_norms(); } - if (mytest.getDoPlots()) + if (mytest.getDoPlots()) { mytest.writePlotfile(); + } } amrex::Finalize(); diff --git a/Tests/LinearSolvers/Nodal_Projection_EB/main.cpp b/Tests/LinearSolvers/Nodal_Projection_EB/main.cpp index b1aa6c001de..3a01aac3bbc 100644 --- a/Tests/LinearSolvers/Nodal_Projection_EB/main.cpp +++ b/Tests/LinearSolvers/Nodal_Projection_EB/main.cpp @@ -57,12 +57,14 @@ int main (int argc, char* argv[]) } #ifndef AMREX_USE_HYPRE - if (use_hypre == 1) - amrex::Abort("Cant use hypre if we dont build with USE_HYPRE=TRUE"); + if (use_hypre == 1) { + amrex::Abort("Cant use hypre if we dont build with USE_HYPRE=TRUE"); + } #endif - if (n_cell%8 != 0) - amrex::Abort("n_cell must be a multiple of 8"); + if (n_cell%8 != 0) { + amrex::Abort("n_cell must be a multiple of 8"); + } int n_cell_y = n_cell; int n_cell_x = 2*n_cell; diff --git a/Tests/MultiBlock/IndexType/main.cpp b/Tests/MultiBlock/IndexType/main.cpp index 84f939dd5e0..1a35bc1e5b4 100644 --- a/Tests/MultiBlock/IndexType/main.cpp +++ b/Tests/MultiBlock/IndexType/main.cpp @@ -53,7 +53,7 @@ bool ParallelCopyWithItselfIsCorrect(amrex::iMultiFab& mf, const amrex::Box& dom int fails = 0; for (amrex::MFIter mfi(mf); mfi.isValid(); ++mfi) { const amrex::Box section = dest_box & mfi.tilebox(); - if (section.isEmpty()) continue; + if (section.isEmpty()) { continue; } auto array = mf.const_array(mfi); amrex::LoopOnCpu(section, [&](int i, int j, int k) { @@ -115,7 +115,7 @@ bool ParallelCopyFaceToFace(amrex::iMultiFab& dest, const amrex::Box& domain_des const int ny = domain_src.length(1); for (amrex::MFIter mfi(dest); mfi.isValid(); ++mfi) { const amrex::Box section = dest_box & mfi.tilebox(); - if (section.isEmpty()) continue; + if (section.isEmpty()) { continue; } auto darray = dest.const_array(mfi); amrex::LoopOnCpu(section, [&](int i, int j, int k) { diff --git a/Tests/Parser2/fn.cpp b/Tests/Parser2/fn.cpp index 18e2b00d694..46ce898b320 100644 --- a/Tests/Parser2/fn.cpp +++ b/Tests/Parser2/fn.cpp @@ -1,8 +1,8 @@ #include #include +// This is intentional. Cannot have std:: in amrex::Parser expressions. using std::sin; -using std::cos; using std::atan2; using std::pow; diff --git a/Tests/Particles/AssignDensity/main.cpp b/Tests/Particles/AssignDensity/main.cpp index f0c1b1a3b19..fb4a0fb970b 100644 --- a/Tests/Particles/AssignDensity/main.cpp +++ b/Tests/Particles/AssignDensity/main.cpp @@ -56,8 +56,9 @@ void test_assign_density(TestParams& parms) myPC.SetVerbose(false); int num_particles = parms.nppc * parms.nx * parms.ny * parms.nz; - if (ParallelDescriptor::IOProcessor()) + if (ParallelDescriptor::IOProcessor()) { std::cout << "Total number of particles : " << num_particles << '\n' << '\n'; + } bool serialize = true; int iseed = 451; @@ -93,8 +94,9 @@ int main(int argc, char* argv[]) pp.get("nz", parms.nz); pp.get("max_grid_size", parms.max_grid_size); pp.get("nppc", parms.nppc); - if (parms.nppc < 1 && ParallelDescriptor::IOProcessor()) + if (parms.nppc < 1 && ParallelDescriptor::IOProcessor()) { amrex::Abort("Must specify at least one particle per cell"); + } parms.verbose = false; pp.query("verbose", parms.verbose); diff --git a/Tests/Particles/AssignMultiLevelDensity/main.cpp b/Tests/Particles/AssignMultiLevelDensity/main.cpp index f2f11d035ae..0ffa37dd695 100644 --- a/Tests/Particles/AssignMultiLevelDensity/main.cpp +++ b/Tests/Particles/AssignMultiLevelDensity/main.cpp @@ -42,8 +42,9 @@ void test_assign_density(TestParams& parms) // Define the refinement ratio Vector rr(nlevs-1); - for (int lev = 1; lev < nlevs; lev++) + for (int lev = 1; lev < nlevs; lev++) { rr[lev-1] = 2; + } // This sets the boundary conditions to be doubly or triply periodic int is_per[] = {AMREX_D_DECL(1,1,1)}; @@ -147,8 +148,9 @@ int main(int argc, char* argv[]) pp.get("max_grid_size", parms.max_grid_size); pp.get("nlevs", parms.nlevs); pp.get("nppc", parms.nppc); - if (parms.nppc < 1 && ParallelDescriptor::IOProcessor()) + if (parms.nppc < 1 && ParallelDescriptor::IOProcessor()) { amrex::Abort("Must specify at least one particle per cell"); + } parms.verbose = false; pp.query("verbose", parms.verbose); diff --git a/Tests/Particles/AsyncIO/main.cpp b/Tests/Particles/AsyncIO/main.cpp index 1dd88e9671e..1ea036113d8 100644 --- a/Tests/Particles/AsyncIO/main.cpp +++ b/Tests/Particles/AsyncIO/main.cpp @@ -101,18 +101,35 @@ class MyParticleContainer p.pos(2) = static_cast (plo[2] + (iv[2] + r[2])*dx[2]); #endif - for (int i = 0; i < NSR; ++i) p.rdata(i) = ParticleReal(p.id()); - for (int i = 0; i < NSI; ++i) p.idata(i) = p.id(); + if constexpr (NSR > 0) { + for (int i = 0; i < NSR; ++i) { + p.rdata(i) = ParticleReal(p.id()); + } + } + if constexpr (NSI > 0) { + for (int i = 0; i < NSI; ++i) { + p.idata(i) = p.id(); + } + } host_particles.push_back(p); - for (int i = 0; i < NAR; ++i) - host_real[i].push_back(ParticleReal(p.id())); - for (int i = 0; i < NAI; ++i) - host_int[i].push_back(int(p.id())); - for (int i = 0; i < NumRuntimeRealComps(); ++i) + + if constexpr (NAR > 0) { + for (int i = 0; i < NAR; ++i) { + host_real[i].push_back(ParticleReal(p.id())); + } + } + if constexpr (NAI > 0) { + for (int i = 0; i < NAI; ++i) { + host_int[i].push_back(int(p.id())); + } + } + for (int i = 0; i < NumRuntimeRealComps(); ++i) { host_runtime_real[i].push_back(ParticleReal(p.id())); - for (int i = 0; i < NumRuntimeIntComps(); ++i) + } + for (int i = 0; i < NumRuntimeIntComps(); ++i) { host_runtime_int[i].push_back(int(p.id())); + } } } @@ -188,8 +205,9 @@ void test_async_io(TestParams& parms) // Define the refinement ratio Vector rr(nlevs-1); - for (int lev = 1; lev < nlevs; lev++) + for (int lev = 1; lev < nlevs; lev++) { rr[lev-1] = IntVect(AMREX_D_DECL(2, 2, 2)); + } // This sets the boundary conditions to be doubly or triply periodic int is_per[] = {AMREX_D_DECL(1,1,1)}; @@ -290,8 +308,9 @@ int main(int argc, char* argv[]) pp.get("max_grid_size", parms.max_grid_size); pp.get("nlevs", parms.nlevs); pp.get("nppc", parms.nppc); - if (parms.nppc < 1 && ParallelDescriptor::IOProcessor()) + if (parms.nppc < 1 && ParallelDescriptor::IOProcessor()) { amrex::Abort("Must specify at least one particle per cell"); + } parms.verbose = false; pp.query("verbose", parms.verbose); diff --git a/Tests/Particles/CheckpointRestart/main.cpp b/Tests/Particles/CheckpointRestart/main.cpp index 1c743280cc9..9d15324d88c 100644 --- a/Tests/Particles/CheckpointRestart/main.cpp +++ b/Tests/Particles/CheckpointRestart/main.cpp @@ -122,12 +122,14 @@ void test () amrex::Print() << " done \n"; Vector particle_realnames; - for (int i = 0; i < NStructReal + NArrayReal; ++i) + for (int i = 0; i < NStructReal + NArrayReal; ++i) { particle_realnames.push_back("particle_real_component_" + std::to_string(i)); + } Vector particle_intnames; - for (int i = 0; i < NStructInt + NArrayInt; ++i) + for (int i = 0; i < NStructInt + NArrayInt; ++i) { particle_intnames.push_back("particle_int_component_" + std::to_string(i)); + } for (int ts = 0; ts < nparticlefile; ts++) { std::snprintf(fname, sizeof fname, "%splt%05d", directory.c_str(), ts); @@ -194,8 +196,9 @@ void set_grids_nested (Vector& domains, domains[0].setBig(domain_hi); ref_ratio.resize(nlevs-1); - for (int lev = 1; lev < nlevs; lev++) + for (int lev = 1; lev < nlevs; lev++) { ref_ratio[lev-1] = IntVect(AMREX_D_DECL(2, 2, 2)); + } grids.resize(nlevs); grids[0].define(domains[0]); diff --git a/Tests/Particles/CheckpointRestartSOA/main.cpp b/Tests/Particles/CheckpointRestartSOA/main.cpp index 7fa6475b4cc..e8629560196 100644 --- a/Tests/Particles/CheckpointRestartSOA/main.cpp +++ b/Tests/Particles/CheckpointRestartSOA/main.cpp @@ -120,12 +120,14 @@ void test () amrex::Print() << " done \n"; Vector particle_realnames; - for (int i = 0; i < NReal; ++i) + for (int i = 0; i < NReal; ++i) { particle_realnames.push_back("particle_real_component_" + std::to_string(i)); + } Vector particle_intnames; - for (int i = 0; i < NInt; ++i) + for (int i = 0; i < NInt; ++i) { particle_intnames.push_back("particle_int_component_" + std::to_string(i)); + } for (int ts = 0; ts < nparticlefile; ts++) { std::snprintf(fname, sizeof fname, "%splt%05d", directory.c_str(), ts); @@ -217,8 +219,9 @@ void set_grids_nested (Vector& domains, domains[0].setBig(domain_hi); ref_ratio.resize(nlevs-1); - for (int lev = 1; lev < nlevs; lev++) + for (int lev = 1; lev < nlevs; lev++) { ref_ratio[lev-1] = IntVect(AMREX_D_DECL(2, 2, 2)); + } grids.resize(nlevs); grids[0].define(domains[0]); diff --git a/Tests/Particles/DenseBins/main.cpp b/Tests/Particles/DenseBins/main.cpp index dd3019d5951..cc40e2fcb77 100644 --- a/Tests/Particles/DenseBins/main.cpp +++ b/Tests/Particles/DenseBins/main.cpp @@ -47,7 +47,7 @@ void checkAnswer (const amrex::DenseBins& bins) for (int i = 0; i < bins.numBins(); ++i) { auto start = offsets[i ]; auto stop = offsets[i+1]; - if (start == stop) continue; + if (start == stop) { continue; } for (auto j = start+1; j < stop; ++j) { AMREX_ALWAYS_ASSERT(bins_ptr[perm[start]] == bins_ptr[perm[j]]); diff --git a/Tests/Particles/GhostsAndVirtuals/main.cpp b/Tests/Particles/GhostsAndVirtuals/main.cpp index 6ed294b11dc..02384eb43ea 100644 --- a/Tests/Particles/GhostsAndVirtuals/main.cpp +++ b/Tests/Particles/GhostsAndVirtuals/main.cpp @@ -43,13 +43,15 @@ void test_ghosts_and_virtuals (TestParams& parms) // Define the refinement ratio Vector rr(nlevs); - for (int lev = 1; lev < nlevs; lev++) + for (int lev = 1; lev < nlevs; lev++) { rr.at(lev-1) = 2; + } // This sets the boundary conditions to be doubly or triply periodic std::array is_per; - for (int i = 0; i < BL_SPACEDIM; i++) + for (int i = 0; i < BL_SPACEDIM; i++) { is_per.at(i) = 1; + } // This defines a Geometry object which is useful for writing the plotfiles Vector geom(nlevs); @@ -135,13 +137,15 @@ void test_ghosts_and_virtuals_ascii (TestParams& parms) // Define the refinement ratio Vector rr(nlevs); rr[0] = 2; - for (int lev = 1; lev < nlevs; lev++) + for (int lev = 1; lev < nlevs; lev++) { rr.at(lev) = 2; + } // This sets the boundary conditions to be doubly or triply periodic std::array is_per; - for (int i = 0; i < BL_SPACEDIM; i++) + for (int i = 0; i < BL_SPACEDIM; i++) { is_per[i] = 1; + } // This defines a Geometry object which is useful for writing the plotfiles Vector geom(nlevs); @@ -162,8 +166,9 @@ void test_ghosts_and_virtuals_ascii (TestParams& parms) #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; @@ -373,13 +378,15 @@ void test_ghosts_and_virtuals_randomperbox (TestParams& parms) // Define the refinement ratio Vector rr(nlevs); - for (int lev = 1; lev < nlevs; lev++) + for (int lev = 1; lev < nlevs; lev++) { rr.at(lev-1) = 2; + } // This sets the boundary conditions to be doubly or triply periodic std::array is_per; - for (int i = 0; i < BL_SPACEDIM; i++) + for (int i = 0; i < BL_SPACEDIM; i++) { is_per.at(i) = 1; + } // This defines a Geometry object which is useful for writing the plotfiles Vector geom(nlevs); @@ -566,13 +573,15 @@ void test_ghosts_and_virtuals_onepercell (TestParams& parms) // Define the refinement ratio Vector rr(nlevs); - for (int lev = 1; lev < nlevs; lev++) + for (int lev = 1; lev < nlevs; lev++) { rr.at(lev-1) = 2; + } // This sets the boundary conditions to be doubly or triply periodic std::array is_per; - for (int i = 0; i < BL_SPACEDIM; i++) + for (int i = 0; i < BL_SPACEDIM; i++) { is_per.at(i) = 1; + } // This defines a Geometry object which is useful for writing the plotfiles Vector geom(nlevs); @@ -740,8 +749,9 @@ int main(int argc, char* argv[]) pp.get("max_grid_size", parms.max_grid_size); pp.get("nlevs", parms.nlevs); pp.get("nppc", parms.nppc); - if (parms.nppc < 1 && ParallelDescriptor::IOProcessor()) + if (parms.nppc < 1 && ParallelDescriptor::IOProcessor()) { amrex::Abort("Must specify at least one particle per cell"); + } parms.verbose = false; pp.query("verbose", parms.verbose); diff --git a/Tests/Particles/InitRandom/main.cpp b/Tests/Particles/InitRandom/main.cpp index 14eb0c715c1..43a7b838710 100644 --- a/Tests/Particles/InitRandom/main.cpp +++ b/Tests/Particles/InitRandom/main.cpp @@ -159,8 +159,9 @@ void set_grids_nested (Vector& domains, domains[0].setBig(domain_hi); ref_ratio.resize(nlevs-1); - for (int lev = 1; lev < nlevs; lev++) + for (int lev = 1; lev < nlevs; lev++) { ref_ratio[lev-1] = IntVect(AMREX_D_DECL(2, 2, 2)); + } grids.resize(nlevs); grids[0].define(domains[0]); diff --git a/Tests/Particles/Intersection/main.cpp b/Tests/Particles/Intersection/main.cpp index 5a8e87711f2..48ccb3c0bcd 100644 --- a/Tests/Particles/Intersection/main.cpp +++ b/Tests/Particles/Intersection/main.cpp @@ -32,8 +32,9 @@ void testIntersection() params.is_periodic)}; Vector rr(params.nlevs-1); - for (int lev = 1; lev < params.nlevs; lev++) + for (int lev = 1; lev < params.nlevs; lev++) { rr[lev-1] = IntVect(AMREX_D_DECL(2,2,2)); + } RealBox real_box; for (int n = 0; n < AMREX_SPACEDIM; n++) @@ -77,7 +78,7 @@ void testIntersection() const Box& box = ba[lev][i]; Gpu::HostVector host_cells; - for (IntVect iv = box.smallEnd(); iv <= box.bigEnd(); box.next(iv)) host_cells.push_back(iv); + for (IntVect iv = box.smallEnd(); iv <= box.bigEnd(); box.next(iv)) { host_cells.push_back(iv); } //host_cells.push_back(box.smallEnd()); auto const num_cells = int(host_cells.size()); diff --git a/Tests/Particles/NeighborParticles/MDParticleContainer.cpp b/Tests/Particles/NeighborParticles/MDParticleContainer.cpp index bcbf6760b0e..c4d4d800847 100644 --- a/Tests/Particles/NeighborParticles/MDParticleContainer.cpp +++ b/Tests/Particles/NeighborParticles/MDParticleContainer.cpp @@ -100,10 +100,12 @@ InitParticles(const IntVect& a_num_particles_per_cell, p.idata(0) = mfi.index(); host_particles.push_back(p); - for (int i = 0; i < NumRealComps(); ++i) + for (int i = 0; i < NumRealComps(); ++i) { host_real[i].push_back(ParticleReal(mfi.index())); - for (int i = 0; i < NumIntComps(); ++i) + } + for (int i = 0; i < NumIntComps(); ++i) { host_int[i].push_back(mfi.index()); + } } } @@ -212,7 +214,7 @@ void MDParticleContainer::moveParticles(amrex::ParticleReal dx) auto& ptile = plev[std::make_pair(gid, tid)]; auto& aos = ptile.GetArrayOfStructs(); - ParticleType* pstruct = &(aos[0]); + ParticleType* pstruct = aos.data(); const size_t np = aos.numParticles(); @@ -251,7 +253,7 @@ void MDParticleContainer::checkNeighborParticles() { int gid = mfi.index(); - if (gid != 0) continue; + if (gid != 0) { continue; } int tid = mfi.LocalTileIndex(); auto index = std::make_pair(gid, tid); @@ -320,7 +322,7 @@ void MDParticleContainer::checkNeighborList() for (int j = 0; j < np_total; j++) { // Don't be your own neighbor. - if ( i == j ) continue; + if ( i == j ) { continue; } ParticleType& p2 = h_pstruct[j]; AMREX_D_TERM(Real dx = p1.pos(0) - p2.pos(0);, diff --git a/Tests/Particles/NeighborParticles/main.cpp b/Tests/Particles/NeighborParticles/main.cpp index 7853c568ce8..92e2a0268ef 100644 --- a/Tests/Particles/NeighborParticles/main.cpp +++ b/Tests/Particles/NeighborParticles/main.cpp @@ -85,41 +85,49 @@ void testNeighborParticles () IntVect nppc(params.num_ppc); - if (ParallelDescriptor::MyProc() == dm[0]) + if (ParallelDescriptor::MyProc() == dm[0]) { amrex::PrintToFile("neighbor_test") << "About to initialize particles \n"; + } pc.InitParticles(nppc, 1.0, 0.0); - if (ParallelDescriptor::MyProc() == dm[0]) + if (ParallelDescriptor::MyProc() == dm[0]) { amrex::PrintToFile("neighbor_test") << "Check neighbors after init ... \n"; + } pc.checkNeighborParticles(); pc.fillNeighbors(); - if (ParallelDescriptor::MyProc() == dm[0]) + if (ParallelDescriptor::MyProc() == dm[0]) { amrex::PrintToFile("neighbor_test") << "Check neighbors after fill ... \n"; + } pc.checkNeighborParticles(); pc.updateNeighbors(); - if (ParallelDescriptor::MyProc() == dm[0]) + if (ParallelDescriptor::MyProc() == dm[0]) { amrex::PrintToFile("neighbor_test") << "Check neighbors after update ... \n"; + } pc.checkNeighborParticles(); - if (ParallelDescriptor::MyProc() == dm[0]) + if (ParallelDescriptor::MyProc() == dm[0]) { amrex::PrintToFile("neighbor_test") << "Now resetting the particle test_id values \n"; + } pc.reset_test_id(); - if (ParallelDescriptor::MyProc() == dm[0]) + if (ParallelDescriptor::MyProc() == dm[0]) { amrex::PrintToFile("neighbor_test") << "Check neighbors after reset ... \n"; + } pc.checkNeighborParticles(); - if (ParallelDescriptor::MyProc() == dm[0]) + if (ParallelDescriptor::MyProc() == dm[0]) { amrex::PrintToFile("neighbor_test") << "Now updateNeighbors again ... \n"; + } pc.updateNeighbors(); - if (ParallelDescriptor::MyProc() == dm[0]) + if (ParallelDescriptor::MyProc() == dm[0]) { amrex::PrintToFile("neighbor_test") << "Check neighbors after update ... \n"; + } pc.checkNeighborParticles(); ParallelDescriptor::Barrier(); diff --git a/Tests/Particles/ParallelContext/main.cpp b/Tests/Particles/ParallelContext/main.cpp index 5deb22245ca..3208b1f3597 100644 --- a/Tests/Particles/ParallelContext/main.cpp +++ b/Tests/Particles/ParallelContext/main.cpp @@ -106,18 +106,22 @@ class TestParticleContainer p.pos(2) = static_cast (plo[2] + (iv[2] + r[2])*dx[2]); #endif - for (int i = 0; i < NSR; ++i) p.rdata(i) = ParticleReal(p.id()); - for (int i = 0; i < NSI; ++i) p.idata(i) = int(p.id()); + for (int i = 0; i < NSR; ++i) { p.rdata(i) = ParticleReal(p.id()); } + for (int i = 0; i < NSI; ++i) { p.idata(i) = int(p.id()); } host_particles.push_back(p); - for (int i = 0; i < NAR; ++i) + for (int i = 0; i < NAR; ++i) { host_real[i].push_back(ParticleReal(p.id())); - for (int i = 0; i < NAI; ++i) + } + for (int i = 0; i < NAI; ++i) { host_int[i].push_back(int(p.id())); - for (int i = 0; i < NumRuntimeRealComps(); ++i) + } + for (int i = 0; i < NumRuntimeRealComps(); ++i) { host_runtime_real[i].push_back(ParticleReal(p.id())); - for (int i = 0; i < NumRuntimeIntComps(); ++i) + } + for (int i = 0; i < NumRuntimeIntComps(); ++i) { host_runtime_int[i].push_back(int(p.id())); + } } } @@ -184,7 +188,7 @@ class TestParticleContainer int tid = mfi.LocalTileIndex(); auto& ptile = plev[std::make_pair(gid, tid)]; auto& aos = ptile.GetArrayOfStructs(); - ParticleType* pstruct = &(aos[0]); + ParticleType* pstruct = aos.data(); const size_t np = aos.numParticles(); if (do_random == 0) @@ -328,7 +332,7 @@ void testParallelContext () int myproc = ParallelContext::MyProcSub(); int task_me = myproc / (amrex::max(rank_n, 2) / 2); - if (task_me > 1) task_me = 1; + if (task_me > 1) { task_me = 1; } #ifdef BL_USE_MPI MPI_Comm new_comm; @@ -394,11 +398,13 @@ void testParallelContext () { pc.moveParticles(params.move_dir, params.do_random); pc.RedistributeLocal(); - if (params.sort) pc.SortParticlesByCell(); + if (params.sort) { pc.SortParticlesByCell(); } pc.checkAnswer(); } - if (geom.isAllPeriodic()) AMREX_ALWAYS_ASSERT(np_old == pc.TotalNumberOfParticles()); + if (geom.isAllPeriodic()) { + AMREX_ALWAYS_ASSERT(np_old == pc.TotalNumberOfParticles()); + } } if (task_me == 1) @@ -417,11 +423,13 @@ void testParallelContext () { pc.moveParticles(params.move_dir, params.do_random); pc.RedistributeLocal(); - if (params.sort) pc.SortParticlesByCell(); + if (params.sort) { pc.SortParticlesByCell(); } pc.checkAnswer(); } - if (geom.isAllPeriodic()) AMREX_ALWAYS_ASSERT(np_old == pc.TotalNumberOfParticles()); + if (geom.isAllPeriodic()) { + AMREX_ALWAYS_ASSERT(np_old == pc.TotalNumberOfParticles()); + } } } diff --git a/Tests/Particles/ParticleIterator/main.cpp b/Tests/Particles/ParticleIterator/main.cpp index a195a905008..aa54681d426 100644 --- a/Tests/Particles/ParticleIterator/main.cpp +++ b/Tests/Particles/ParticleIterator/main.cpp @@ -31,8 +31,9 @@ int main(int argc, char* argv[]) const Box domain(domain_lo, domain_hi); Vector rr(nlevs-1); - for (int lev = 1; lev < nlevs; lev++) + for (int lev = 1; lev < nlevs; lev++) { rr[lev-1] = 2; + } int is_per[] = {AMREX_D_DECL(1,1,1)}; @@ -42,12 +43,14 @@ int main(int argc, char* argv[]) Vector ba(nlevs); ba[0].define(domain); - for (int lev = 0; lev < nlevs; lev++) + for (int lev = 0; lev < nlevs; lev++) { ba[lev].maxSize(max_grid_size); + } Vector dmap(nlevs); - for (int lev = 0; lev < nlevs; lev++) + for (int lev = 0; lev < nlevs; lev++) { dmap[lev].define(ba[lev]); + } using MyParticleContainer = ParticleContainer<1+BL_SPACEDIM>; MyParticleContainer MyPC(geom, dmap, ba, rr); diff --git a/Tests/Particles/ParticleMesh/main.cpp b/Tests/Particles/ParticleMesh/main.cpp index cc116593b86..df398a52756 100644 --- a/Tests/Particles/ParticleMesh/main.cpp +++ b/Tests/Particles/ParticleMesh/main.cpp @@ -55,8 +55,9 @@ void testParticleMesh (TestParams& parms) myPC.SetVerbose(false); int num_particles = parms.nppc * parms.nx * parms.ny * parms.nz; - if (ParallelDescriptor::IOProcessor()) + if (ParallelDescriptor::IOProcessor()) { std::cout << "Total number of particles : " << num_particles << '\n' << '\n'; + } bool serialize = true; int iseed = 451; @@ -165,8 +166,9 @@ int main(int argc, char* argv[]) pp.get("nz", parms.nz); pp.get("max_grid_size", parms.max_grid_size); pp.get("nppc", parms.nppc); - if (parms.nppc < 1 && ParallelDescriptor::IOProcessor()) + if (parms.nppc < 1 && ParallelDescriptor::IOProcessor()) { amrex::Abort("Must specify at least one particle per cell"); + } parms.verbose = false; pp.query("verbose", parms.verbose); diff --git a/Tests/Particles/ParticleMeshMultiLevel/main.cpp b/Tests/Particles/ParticleMeshMultiLevel/main.cpp index 53b11252cae..1cd6f45e1c5 100644 --- a/Tests/Particles/ParticleMeshMultiLevel/main.cpp +++ b/Tests/Particles/ParticleMeshMultiLevel/main.cpp @@ -25,8 +25,9 @@ struct TestParams { void testParticleMesh (TestParams& parms) { Vector rr(parms.nlevs-1); - for (int lev = 1; lev < parms.nlevs; lev++) + for (int lev = 1; lev < parms.nlevs; lev++) { rr[lev-1] = IntVect(AMREX_D_DECL(2,2,2)); + } RealBox real_box; for (int n = 0; n < BL_SPACEDIM; n++) { @@ -161,8 +162,9 @@ int main(int argc, char* argv[]) pp.get("max_grid_size", parms.max_grid_size); pp.get("nppc", parms.nppc); pp.get("nlevs", parms.nlevs); - if (parms.nppc < 1 && ParallelDescriptor::IOProcessor()) + if (parms.nppc < 1 && ParallelDescriptor::IOProcessor()) { amrex::Abort("Must specify at least one particle per cell"); + } parms.verbose = false; pp.query("verbose", parms.verbose); diff --git a/Tests/Particles/ParticleReduce/main.cpp b/Tests/Particles/ParticleReduce/main.cpp index 5e461084273..e7b912902c6 100644 --- a/Tests/Particles/ParticleReduce/main.cpp +++ b/Tests/Particles/ParticleReduce/main.cpp @@ -82,14 +82,16 @@ class TestParticleContainer p.pos(1) = y;, p.pos(2) = z;) - for (int i = 0; i < NSR; ++i) p.rdata(i) = ParticleReal(i); - for (int i = 0; i < NSI; ++i) p.idata(i) = i; + for (int i = 0; i < NSR; ++i) { p.rdata(i) = ParticleReal(i); } + for (int i = 0; i < NSI; ++i) { p.idata(i) = i; } host_particles.push_back(p); - for (int i = 0; i < NAR; ++i) + for (int i = 0; i < NAR; ++i) { host_real[i].push_back(ParticleReal(i)); - for (int i = 0; i < NAI; ++i) + } + for (int i = 0; i < NAI; ++i) { host_int[i].push_back(i); + } } } @@ -176,8 +178,9 @@ void testReduce () IntVect nppc(params.num_ppc); - if (ParallelDescriptor::MyProc() == dm[0]) + if (ParallelDescriptor::MyProc() == dm[0]) { amrex::Print() << "About to initialize particles \n"; + } pc.InitParticles(nppc); diff --git a/Tests/Particles/ParticleTransformations/main.cpp b/Tests/Particles/ParticleTransformations/main.cpp index a55111f4b78..f88b68444b8 100644 --- a/Tests/Particles/ParticleTransformations/main.cpp +++ b/Tests/Particles/ParticleTransformations/main.cpp @@ -83,14 +83,25 @@ class TestParticleContainer p.pos(1) = y;, p.pos(2) = z;) - for (int i = 0; i < NSR; ++i) p.rdata(i) = ParticleReal(i); - for (int i = 0; i < NSI; ++i) p.idata(i) = i; + if constexpr (NSR > 0) { + for (int i = 0; i < NSR; ++i) { p.rdata(i) = ParticleReal(i); } + } + if constexpr (NSI > 0) { + for (int i = 0; i < NSI; ++i) { p.idata(i) = i; } + } host_particles.push_back(p); - for (int i = 0; i < NAR; ++i) - host_real[i].push_back(ParticleReal(i)); - for (int i = 0; i < NAI; ++i) - host_int[i].push_back(i); + + if constexpr (NAR > 0) { + for (int i = 0; i < NAR; ++i) { + host_real[i].push_back(ParticleReal(i)); + } + } + if constexpr (NAI > 0) { + for (int i = 0; i < NAI; ++i) { + host_int[i].push_back(i); + } + } } } @@ -139,14 +150,18 @@ struct Transformer int src_i, int dst_i) const noexcept { dst.m_aos[dst_i] = src.m_aos[src_i]; - for (int j = 0; j < DstData::NAR; ++j) + for (int j = 0; j < DstData::NAR; ++j) { dst.m_rdata[j][dst_i] = src.m_rdata[j][src_i]; - for (int j = 0; j < dst.m_num_runtime_real; ++j) + } + for (int j = 0; j < dst.m_num_runtime_real; ++j) { dst.m_runtime_rdata[j][dst_i] = src.m_runtime_rdata[j][src_i]; - for (int j = 0; j < DstData::NAI; ++j) + } + for (int j = 0; j < DstData::NAI; ++j) { dst.m_idata[j][dst_i] = m_factor*src.m_idata[j][src_i]; - for (int j = 0; j < dst.m_num_runtime_int; ++j) + } + for (int j = 0; j < dst.m_num_runtime_int; ++j) { dst.m_runtime_idata[j][dst_i] = src.m_runtime_idata[j][src_i]; + } } }; @@ -170,24 +185,32 @@ struct TwoWayTransformer int src_i, int dst1_i, int dst2_i) const noexcept { dst1.m_aos[dst1_i] = src.m_aos[src_i]; - for (int j = 0; j < DstData::NAR; ++j) + for (int j = 0; j < DstData::NAR; ++j) { dst1.m_rdata[j][dst1_i] = src.m_rdata[j][src_i]; - for (int j = 0; j < dst1.m_num_runtime_real; ++j) + } + for (int j = 0; j < dst1.m_num_runtime_real; ++j) { dst1.m_runtime_rdata[j][dst1_i] = src.m_runtime_rdata[j][src_i]; - for (int j = 0; j < DstData::NAI; ++j) + } + for (int j = 0; j < DstData::NAI; ++j) { dst1.m_idata[j][dst1_i] = m_factor1*src.m_idata[j][src_i]; - for (int j = 0; j < dst1.m_num_runtime_int; ++j) + } + for (int j = 0; j < dst1.m_num_runtime_int; ++j) { dst1.m_runtime_idata[j][dst1_i] = src.m_runtime_idata[j][src_i]; + } dst2.m_aos[dst2_i] = src.m_aos[src_i]; - for (int j = 0; j < DstData::NAR; ++j) + for (int j = 0; j < DstData::NAR; ++j) { dst2.m_rdata[j][dst2_i] = src.m_rdata[j][src_i]; - for (int j = 0; j < dst2.m_num_runtime_real; ++j) + } + for (int j = 0; j < dst2.m_num_runtime_real; ++j) { dst2.m_runtime_rdata[j][dst2_i] = src.m_runtime_rdata[j][src_i]; - for (int j = 0; j < DstData::NAI; ++j) + } + for (int j = 0; j < DstData::NAI; ++j) { dst2.m_idata[j][dst2_i] = m_factor2*src.m_idata[j][src_i]; - for (int j = 0; j < dst2.m_num_runtime_int; ++j) + } + for (int j = 0; j < dst2.m_num_runtime_int; ++j) { dst2.m_runtime_idata[j][dst2_i] = src.m_runtime_idata[j][src_i]; + } } }; @@ -545,8 +568,9 @@ void testTransformations () IntVect nppc(params.num_ppc); - if (ParallelDescriptor::MyProc() == dm[0]) + if (ParallelDescriptor::MyProc() == dm[0]) { amrex::Print() << "About to initialize particles \n"; + } pc.InitParticles(nppc); diff --git a/Tests/Particles/Redistribute/main.cpp b/Tests/Particles/Redistribute/main.cpp index 83ed2cd390c..139c63dd0e1 100644 --- a/Tests/Particles/Redistribute/main.cpp +++ b/Tests/Particles/Redistribute/main.cpp @@ -118,18 +118,22 @@ class TestParticleContainer p.pos(2) = static_cast (plo[2] + (iv[2] + r[2])*dx[2]); #endif - for (int i = 0; i < NSR; ++i) p.rdata(i) = ParticleReal(p.id()); - for (int i = 0; i < NSI; ++i) p.idata(i) = int(p.id()); + for (int i = 0; i < NSR; ++i) { p.rdata(i) = ParticleReal(p.id()); } + for (int i = 0; i < NSI; ++i) { p.idata(i) = int(p.id()); } host_particles.push_back(p); - for (int i = 0; i < NAR; ++i) + for (int i = 0; i < NAR; ++i) { host_real[i].push_back(ParticleReal(p.id())); - for (int i = 0; i < NAI; ++i) + } + for (int i = 0; i < NAI; ++i) { host_int[i].push_back(int(p.id())); - for (int i = 0; i < NumRuntimeRealComps(); ++i) + } + for (int i = 0; i < NumRuntimeRealComps(); ++i) { host_runtime_real[i].push_back(ParticleReal(p.id())); - for (int i = 0; i < NumRuntimeIntComps(); ++i) + } + for (int i = 0; i < NumRuntimeIntComps(); ++i) { host_runtime_int[i].push_back(int(p.id())); + } } } @@ -196,7 +200,7 @@ class TestParticleContainer int tid = mfi.LocalTileIndex(); auto& ptile = plev[std::make_pair(gid, tid)]; auto& aos = ptile.GetArrayOfStructs(); - ParticleType* pstruct = &(aos[0]); + ParticleType* pstruct = aos.data(); const size_t np = aos.numParticles(); if (do_random == 0) @@ -246,7 +250,7 @@ class TestParticleContainer int tid = mfi.LocalTileIndex(); auto& ptile = plev[std::make_pair(gid, tid)]; auto& aos = ptile.GetArrayOfStructs(); - ParticleType* pstruct = &(aos[0]); + ParticleType* pstruct = aos.data(); const size_t np = aos.numParticles(); amrex::ParallelFor( np, [=] AMREX_GPU_DEVICE (int i) noexcept { @@ -370,8 +374,9 @@ void testRedistribute () params.is_periodic)}; Vector rr(params.nlevs-1); - for (int lev = 1; lev < params.nlevs; lev++) + for (int lev = 1; lev < params.nlevs; lev++) { rr[lev-1] = IntVect(AMREX_D_DECL(2,2,2)); + } RealBox real_box; for (int n = 0; n < BL_SPACEDIM; n++) @@ -416,7 +421,7 @@ void testRedistribute () auto np_old = pc.TotalNumberOfParticles(); - if (params.sort) pc.SortParticlesByCell(); + if (params.sort) { pc.SortParticlesByCell(); } for (int i = 0; i < params.nsteps; ++i) { @@ -429,7 +434,7 @@ void testRedistribute () pc.negateEven(); } pc.RedistributeLocal(); - if (params.sort) pc.SortParticlesByCell(); + if (params.sort) { pc.SortParticlesByCell(); } pc.checkAnswer(); } @@ -441,7 +446,7 @@ void testRedistribute () { DistributionMapping new_dm; Vector pmap; - for (int i = 0; i < ba[lev].size(); ++i) pmap.push_back(i % NProcs); + for (int i = 0; i < ba[lev].size(); ++i) { pmap.push_back(i % NProcs); } new_dm.define(pmap); pc.SetParticleDistributionMap(lev, new_dm); } @@ -461,7 +466,7 @@ void testRedistribute () { DistributionMapping new_dm; Vector pmap; - for (int i = 0; i < ba[lev].size(); ++i) pmap.push_back((i+1) % NProcs); + for (int i = 0; i < ba[lev].size(); ++i) { pmap.push_back((i+1) % NProcs); } new_dm.define(pmap); pc.SetParticleDistributionMap(lev, new_dm); } @@ -491,7 +496,9 @@ void testRedistribute () } } - if (geom[0].isAllPeriodic()) AMREX_ALWAYS_ASSERT(np_old == pc.TotalNumberOfParticles()); + if (geom[0].isAllPeriodic()) { + AMREX_ALWAYS_ASSERT(np_old == pc.TotalNumberOfParticles()); + } // the way this test is set up, if we make it here we pass amrex::Print() << "pass \n"; diff --git a/Tests/Particles/RedistributeSOA/main.cpp b/Tests/Particles/RedistributeSOA/main.cpp index 0bf11f6f11c..eba02904fb7 100644 --- a/Tests/Particles/RedistributeSOA/main.cpp +++ b/Tests/Particles/RedistributeSOA/main.cpp @@ -116,14 +116,18 @@ class TestParticleContainer host_real[2].push_back(static_cast (plo[2] + (iv[2] + r[2])*dx[2])); #endif - for (int i = AMREX_SPACEDIM; i < NR; ++i) + for (int i = AMREX_SPACEDIM; i < NR; ++i) { host_real[i].push_back(static_cast(id)); - for (int i = 2; i < NI; ++i) + } + for (int i = 2; i < NI; ++i) { host_int[i].push_back(static_cast(id)); - for (int i = 0; i < NumRuntimeRealComps(); ++i) + } + for (int i = 0; i < NumRuntimeRealComps(); ++i) { host_runtime_real[i].push_back(static_cast(id)); - for (int i = 0; i < NumRuntimeIntComps(); ++i) + } + for (int i = 0; i < NumRuntimeIntComps(); ++i) { host_runtime_int[i].push_back(static_cast(id)); + } } } @@ -345,12 +349,14 @@ void testRedistribute () get_test_params(params, "redistribute"); int is_per[BL_SPACEDIM]; - for (int & d : is_per) + for (int & d : is_per) { d = params.is_periodic; + } Vector rr(params.nlevs-1); - for (int lev = 1; lev < params.nlevs; lev++) + for (int lev = 1; lev < params.nlevs; lev++) { rr[lev-1] = IntVect(AMREX_D_DECL(2,2,2)); + } RealBox real_box; for (int n = 0; n < BL_SPACEDIM; n++) @@ -396,7 +402,7 @@ void testRedistribute () auto np_old = pc.TotalNumberOfParticles(); - if (params.sort) pc.SortParticlesByCell(); + if (params.sort) { pc.SortParticlesByCell(); } for (int i = 0; i < params.nsteps; ++i) { @@ -410,7 +416,7 @@ void testRedistribute () pc.negateEven(); } pc.RedistributeLocal(); - if (params.sort) pc.SortParticlesByCell(); + if (params.sort) { pc.SortParticlesByCell(); } pc.checkAnswer(); } @@ -422,7 +428,7 @@ void testRedistribute () { DistributionMapping new_dm; Vector pmap; - for (int i = 0; i < ba[lev].size(); ++i) pmap.push_back(i % NProcs); + for (int i = 0; i < ba[lev].size(); ++i) { pmap.push_back(i % NProcs); } new_dm.define(pmap); pc.SetParticleDistributionMap(lev, new_dm); } @@ -442,7 +448,7 @@ void testRedistribute () { DistributionMapping new_dm; Vector pmap; - for (int i = 0; i < ba[lev].size(); ++i) pmap.push_back((i+1) % NProcs); + for (int i = 0; i < ba[lev].size(); ++i) { pmap.push_back((i+1) % NProcs); } new_dm.define(pmap); pc.SetParticleDistributionMap(lev, new_dm); } diff --git a/Tests/Particles/SOAParticle/GNUmakefile b/Tests/Particles/SOAParticle/GNUmakefile new file mode 100644 index 00000000000..9f49d3ec029 --- /dev/null +++ b/Tests/Particles/SOAParticle/GNUmakefile @@ -0,0 +1,22 @@ +AMREX_HOME = ../../../ + +DEBUG = FALSE + +DIM = 3 + +COMP = gcc + +USE_MPI = TRUE +USE_OMP = FALSE +USE_CUDA = FALSE + +#TINY_PROFILE = TRUE +USE_PARTICLES = TRUE + +include $(AMREX_HOME)/Tools/GNUMake/Make.defs + +include ./Make.package +include $(AMREX_HOME)/Src/Base/Make.package +include $(AMREX_HOME)/Src/Particle/Make.package + +include $(AMREX_HOME)/Tools/GNUMake/Make.rules diff --git a/Tests/Particles/SOAParticle/Make.package b/Tests/Particles/SOAParticle/Make.package new file mode 100644 index 00000000000..6b4b865e8fc --- /dev/null +++ b/Tests/Particles/SOAParticle/Make.package @@ -0,0 +1 @@ +CEXE_sources += main.cpp diff --git a/Tests/Particles/SOAParticle/main.cpp b/Tests/Particles/SOAParticle/main.cpp index 56a621daf40..d800f9ddffb 100644 --- a/Tests/Particles/SOAParticle/main.cpp +++ b/Tests/Particles/SOAParticle/main.cpp @@ -15,8 +15,9 @@ template class Allocator=DefaultAllocator> void addParticles () { int is_per[AMREX_SPACEDIM]; - for (int & d : is_per) + for (int & d : is_per) { d = 1; + } RealBox real_box; for (int n = 0; n < AMREX_SPACEDIM; n++) @@ -49,8 +50,9 @@ void addParticles () for (int i = 0; i < add_num_particles; ++i) { - for (int d = 0; d < AMREX_SPACEDIM; d++) + for (int d = 0; d < AMREX_SPACEDIM; d++) { ptile1.pos(i, d) = 12.0; + } ptile1.getParticleTileData().rdata(AMREX_SPACEDIM)[i] = 1.2; // w ptile1.push_back_int(0, ParticleType::NextID()); @@ -184,7 +186,3 @@ int main(int argc, char* argv[]) } amrex::Finalize(); } - - - - diff --git a/Tests/Particles/SparseBins/main.cpp b/Tests/Particles/SparseBins/main.cpp index 7acd1d0767e..7a028072f5c 100644 --- a/Tests/Particles/SparseBins/main.cpp +++ b/Tests/Particles/SparseBins/main.cpp @@ -32,8 +32,9 @@ void testIntersection() params.is_periodic)}; Vector rr(params.nlevs-1); - for (int lev = 1; lev < params.nlevs; lev++) + for (int lev = 1; lev < params.nlevs; lev++) { rr[lev-1] = IntVect(AMREX_D_DECL(2,2,2)); + } RealBox real_box; for (int n = 0; n < AMREX_SPACEDIM; n++)