Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Clang-Tidy changes in Tests #3477

Merged
merged 1 commit into from
Aug 4, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 8 additions & 6 deletions Tests/Amr/Advection_AmrCore/Source/AmrCoreAdv.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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];

Expand Down Expand Up @@ -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) {
Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -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())
{
Expand All @@ -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];
Expand Down
3 changes: 2 additions & 1 deletion Tests/Amr/Advection_AmrCore/Source/DefineVelocity.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
3 changes: 2 additions & 1 deletion Tests/Amr/Advection_AmrCore/Source/Tagging.H
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,9 @@ state_error (int i, int j, int k,
amrex::Array4<amrex::Real const> 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
33 changes: 21 additions & 12 deletions Tests/Amr/Advection_AmrLevel/Source/AmrLevelAdv.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
Expand All @@ -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.);
}
}
}

Expand Down Expand Up @@ -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;
Expand All @@ -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;
Expand Down Expand Up @@ -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++)
{
Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -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();
}
}

/**
Expand Down Expand Up @@ -737,7 +746,7 @@ AmrLevelAdv::read_params ()
{
static bool done = false;

if (done) return;
if (done) { return; }

done = true;

Expand Down Expand Up @@ -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);
Expand Down
2 changes: 1 addition & 1 deletion Tests/DivFreePatch/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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<Array<MultiFab*, AMREX_SPACEDIM> > fine_v;
Vector<Array<MultiFab*, AMREX_SPACEDIM> > coarse_v;
Expand Down
9 changes: 5 additions & 4 deletions Tests/EB/CNS/Source/CNS.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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();
}
Expand Down Expand Up @@ -382,7 +383,7 @@ CNS::read_params ()
Vector<int> tilesize(AMREX_SPACEDIM);
if (pp.queryarr("hydro_tile_size", tilesize, 0, AMREX_SPACEDIM))
{
for (int i=0; i<AMREX_SPACEDIM; i++) hydro_tile_size[i] = tilesize[i];
for (int i=0; i<AMREX_SPACEDIM; i++) { hydro_tile_size[i] = tilesize[i]; }
}

pp.query("cfl", cfl);
Expand Down Expand Up @@ -417,7 +418,7 @@ CNS::avgDown ()
{
BL_PROFILE("CNS::avgDown()");

if (level == parent->finestLevel()) return;
if (level == parent->finestLevel()) { return; }

auto& fine_lev = getLevel(level+1);

Expand Down
8 changes: 4 additions & 4 deletions Tests/EB/CNS/Source/CNS_advance.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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]),
Expand All @@ -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]),
Expand Down
4 changes: 2 additions & 2 deletions Tests/EB_CNS/Source/CNS.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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();
}
Expand Down Expand Up @@ -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);

Expand Down
4 changes: 2 additions & 2 deletions Tests/GPU/CNS/Source/CNS.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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();
}
Expand Down Expand Up @@ -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);

Expand Down
7 changes: 5 additions & 2 deletions Tests/LinearSolvers/CellEB/MyTest.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
3 changes: 2 additions & 1 deletion Tests/LinearSolvers/NodalPoisson/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down
10 changes: 6 additions & 4 deletions Tests/LinearSolvers/Nodal_Projection_EB/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
4 changes: 2 additions & 2 deletions Tests/MultiBlock/IndexType/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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)
{
Expand Down Expand Up @@ -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)
{
Expand Down
2 changes: 1 addition & 1 deletion Tests/Parser2/fn.cpp
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
#include <AMReX.H>
#include <cmath>

// This is intentional. Cannot have std:: in amrex::Parser expressions.
using std::sin;
using std::cos;
using std::atan2;
using std::pow;

Expand Down
Loading
Loading