From 753b75e122c31a89fa34bf807f334f8433a16975 Mon Sep 17 00:00:00 2001 From: Weiqun Zhang Date: Fri, 4 Aug 2023 08:51:39 -0700 Subject: [PATCH] Clang-Tidy changes in Tools (#3478) --- Tools/Plotfile/fcompare.cpp | 2 +- Tools/Plotfile/fextract.cpp | 4 ++-- Tools/Plotfile/fnan.cpp | 2 +- Tools/Plotfile/fsnapshot.cpp | 6 +++--- Tools/Postprocessing/C_Src/particle_compare.cpp | 6 +++--- 5 files changed, 10 insertions(+), 10 deletions(-) diff --git a/Tools/Plotfile/fcompare.cpp b/Tools/Plotfile/fcompare.cpp index 7dc5ed361ad..6a7b95daf5a 100644 --- a/Tools/Plotfile/fcompare.cpp +++ b/Tools/Plotfile/fcompare.cpp @@ -366,7 +366,7 @@ int main_main() if (! all_variables_found) { amrex::Print() << " WARNING: not all variables present in both files\n"; - if (abort_if_not_all_found) return EXIT_FAILURE; + if (abort_if_not_all_found) { return EXIT_FAILURE; } } if (any_nans) { diff --git a/Tools/Plotfile/fextract.cpp b/Tools/Plotfile/fextract.cpp index eb1b50a2192..9da5ede5176 100644 --- a/Tools/Plotfile/fextract.cpp +++ b/Tools/Plotfile/fextract.cpp @@ -200,7 +200,7 @@ void main_main() const IntVect ivloc{AMREX_D_DECL(iloc,jloc,kloc)}; - if (fine_level < 0) fine_level = pf.finestLevel(); + if (fine_level < 0) { fine_level = pf.finestLevel(); } // sanity check on valid selected levels if (fine_level > pf.finestLevel() || coarse_level < 0 || coarse_level > fine_level) { amrex::Abort("Invalid level selection"); @@ -373,7 +373,7 @@ void main_main() for (int i = 0; i < posidx.size(); ++i) { ofs << std::setw(25) << std::right << std::setprecision(precision) << posidx[i].first; for (int j = 0; j < var_names.size(); ++j) { - if (std::abs(data[j][posidx[i].second])< tolerance ) data[j][posidx[i].second] = 0.; + if (std::abs(data[j][posidx[i].second])< tolerance ) { data[j][posidx[i].second] = 0.; } ofs << std::setw(25) << std::right << std::setprecision(precision) << data[j][posidx[i].second]; } ofs << "\n"; diff --git a/Tools/Plotfile/fnan.cpp b/Tools/Plotfile/fnan.cpp index 50f9b60c120..ba8f7276790 100644 --- a/Tools/Plotfile/fnan.cpp +++ b/Tools/Plotfile/fnan.cpp @@ -42,7 +42,7 @@ int main_main() int num_nans = 0; for (int b : has_nan) { - if (b) ++num_nans; + if (b) { ++num_nans; } } if (num_nans == 0) { amrex::Print() << " " << std::setw(nwidth+1) << std::left << varname << ": clean" << "\n"; diff --git a/Tools/Plotfile/fsnapshot.cpp b/Tools/Plotfile/fsnapshot.cpp index d35cef2a718..e68f8a33b6d 100644 --- a/Tools/Plotfile/fsnapshot.cpp +++ b/Tools/Plotfile/fsnapshot.cpp @@ -97,8 +97,8 @@ void main_main() // make sure we have valid options set if (do_log) { - if (ldef_mx && def_mx < 0.) amrex::Abort("ERROR: log plot specified with negative maximum"); - if (ldef_mn && def_mn < 0.) amrex::Abort("ERROR: log plot specified with negative minimum"); + if (ldef_mx && def_mx < 0.) { amrex::Abort("ERROR: log plot specified with negative maximum"); } + if (ldef_mn && def_mn < 0.) { amrex::Abort("ERROR: log plot specified with negative minimum"); } } // get the palette @@ -291,7 +291,7 @@ void main_main() int jj = (idir == 2) ? height - 1 - j : j; // flip the data in second image direction int kk = (idir == 2) ? k : height - 1 - k; Real rd = realarr(i,jj,kk); - if (do_log) rd = std::log10(rd); + if (do_log) { rd = std::log10(rd); } int id = std::max(0,std::min(255,static_cast((rd-gmn)*fac))); auto c = static_cast(id); constexpr auto cmn = static_cast(1); // avoid zero diff --git a/Tools/Postprocessing/C_Src/particle_compare.cpp b/Tools/Postprocessing/C_Src/particle_compare.cpp index 84ceeed914a..9967625cca6 100644 --- a/Tools/Postprocessing/C_Src/particle_compare.cpp +++ b/Tools/Postprocessing/C_Src/particle_compare.cpp @@ -302,8 +302,8 @@ int sort_particles_ascending(const void *p, const void *q) std::memcpy(&cpu1, iptr1, sizeof(int)); std::memcpy(&cpu2, iptr2, sizeof(int)); - if (cpu1 != cpu2) return (cpu1 - cpu2); - if (id1 != id2 ) return (id1 - id2 ); + if (cpu1 != cpu2) { return (cpu1 - cpu2); } + if (id1 != id2 ) { return (id1 - id2 ); } return 0; } @@ -312,7 +312,7 @@ void compare_particle_chunk(const ParticleHeader& header1, std::vector& norms, int level, int file_num, int np, int offset) { - if (np == 0) return; + if (np == 0) { return; } std::string read_file1 = getDataFileName(header1.par_file_name, level, file_num); std::string read_file2 = getDataFileName(header2.par_file_name, level, file_num);