From 23e72e90d983f22578c51d4c9bafd282d2395949 Mon Sep 17 00:00:00 2001 From: Jon Rood Date: Thu, 30 Dec 2021 20:59:05 -0700 Subject: [PATCH] Add fixes for readability-implicit-bool-conversion check. (#542) --- .clang-tidy | 2 +- amr-wind/boundary_conditions/BCInterface.cpp | 22 ++++++++-------- .../convection/incflo_godunov_advection.cpp | 26 +++++++++---------- amr-wind/core/MLMGOptions.cpp | 2 +- amr-wind/setup/init.cpp | 6 ++--- 5 files changed, 29 insertions(+), 29 deletions(-) diff --git a/.clang-tidy b/.clang-tidy index 77b909a4d3..629616b33f 100644 --- a/.clang-tidy +++ b/.clang-tidy @@ -1,5 +1,5 @@ --- -Checks: 'clang-diagnostic-*,clang-analyzer-*,corecppguidelines-*,modernize-*,readability-*,-readability-magic-numbers,-readability-identifier-naming,-modernize-avoid-c-arrays,-modernize-use-trailing-return-type,-readability-named-parameter,-readability-implicit-bool-conversion,-readability-isolate-declaration,-readability-braces-around-statements,-clang-analyzer-optin.cplusplus.VirtualCall,-clang-analyzer-core.NonNullParamChecker' +Checks: 'clang-diagnostic-*,clang-analyzer-*,corecppguidelines-*,modernize-*,readability-*,-readability-magic-numbers,-readability-identifier-naming,-modernize-avoid-c-arrays,-modernize-use-trailing-return-type,-readability-named-parameter,-readability-isolate-declaration,-readability-braces-around-statements,-clang-analyzer-optin.cplusplus.VirtualCall,-clang-analyzer-core.NonNullParamChecker' WarningsAsErrors: '' HeaderFilterRegex: '^((?!/amrex/Src/|/googletest/).)*$' AnalyzeTemporaryDtors: false diff --git a/amr-wind/boundary_conditions/BCInterface.cpp b/amr-wind/boundary_conditions/BCInterface.cpp index c74f8381d6..83e3e62a9e 100644 --- a/amr-wind/boundary_conditions/BCInterface.cpp +++ b/amr-wind/boundary_conditions/BCInterface.cpp @@ -39,7 +39,7 @@ void BCIface::operator()(const amrex::Real value) inline void BCIface::set_default_value(const amrex::Real value) { auto& bcval = m_field.bc_values(); - for (amrex::OrientationIter oit; oit; ++oit) { + for (amrex::OrientationIter oit; oit != nullptr; ++oit) { auto ori = oit(); for (int i = 0; i < m_field.num_comp(); ++i) bcval[ori][i] = value; } @@ -50,7 +50,7 @@ void BCIface::read_bctype() const std::string key = m_field.name() + "_type"; auto& ibctype = m_field.bc_type(); const auto& geom = m_field.repo().mesh().Geom(0); - for (amrex::OrientationIter oit; oit; ++oit) { + for (amrex::OrientationIter oit; oit != nullptr; ++oit) { auto ori = oit(); const auto& bcid = bcnames[ori]; amrex::ParmParse pp(bcid); @@ -104,7 +104,7 @@ void BCIface::read_bctype() void BCIface::set_bcfuncs() { const auto& ibctype = m_field.bc_type(); - for (amrex::OrientationIter oit; oit; ++oit) { + for (amrex::OrientationIter oit; oit != nullptr; ++oit) { auto ori = oit(); const auto bct = ibctype[ori]; @@ -130,7 +130,7 @@ std::pair BCIface::get_dirichlet_udfs() bool has_inflow_udf = false; bool has_wall_udf = false; - for (amrex::OrientationIter oit; oit; ++oit) { + for (amrex::OrientationIter oit; oit != nullptr; ++oit) { auto ori = oit(); const auto& bcid = bcnames[ori]; const auto bct = bctype[ori]; @@ -182,7 +182,7 @@ void BCVelocity::set_bcrec() const auto& ibctype = m_field.bc_type(); auto& bcrec = m_field.bcrec(); - for (amrex::OrientationIter oit; oit; ++oit) { + for (amrex::OrientationIter oit; oit != nullptr; ++oit) { auto ori = oit(); const auto side = ori.faceDir(); const auto bct = ibctype[ori]; @@ -240,7 +240,7 @@ void BCVelocity::read_values() const auto& bctype = m_field.bc_type(); auto& bcval = m_field.bc_values(); const int ndim = m_field.num_comp(); - for (amrex::OrientationIter oit; oit; ++oit) { + for (amrex::OrientationIter oit; oit != nullptr; ++oit) { auto ori = oit(); const auto& bcid = bcnames[ori]; const auto bct = bctype[ori]; @@ -267,7 +267,7 @@ void BCVelocity::read_values() void BCScalar::set_bcrec() { const auto& ibctype = m_field.bc_type(); - for (amrex::OrientationIter oit; oit; ++oit) { + for (amrex::OrientationIter oit; oit != nullptr; ++oit) { auto ori = oit(); const auto side = ori.faceDir(); const auto bct = ibctype[ori]; @@ -320,7 +320,7 @@ void BCScalar::read_values() const auto& bctype = m_field.bc_type(); auto& bcval = m_field.bc_values(); const int ndim = m_field.num_comp(); - for (amrex::OrientationIter oit; oit; ++oit) { + for (amrex::OrientationIter oit; oit != nullptr; ++oit) { auto ori = oit(); const auto& bcid = bcnames[ori]; const auto bct = bctype[ori]; @@ -344,7 +344,7 @@ void BCPressure::read_values() const auto& bctype = m_field.bc_type(); auto& bcval = m_field.bc_values(); const int ndim = m_field.num_comp(); - for (amrex::OrientationIter oit; oit; ++oit) { + for (amrex::OrientationIter oit; oit != nullptr; ++oit) { auto ori = oit(); const auto& bcid = bcnames[ori]; const auto bct = bctype[ori]; @@ -365,7 +365,7 @@ void BCPressure::read_values() void BCSrcTerm::set_bcrec() { const auto& ibctype = m_field.bc_type(); - for (amrex::OrientationIter oit; oit; ++oit) { + for (amrex::OrientationIter oit; oit != nullptr; ++oit) { auto ori = oit(); const auto side = ori.faceDir(); const auto bct = ibctype[ori]; @@ -392,7 +392,7 @@ void BCSrcTerm::set_bcrec() void BCFillPatchExtrap::set_bcrec() { const auto& ibctype = m_field.bc_type(); - for (amrex::OrientationIter oit; oit; ++oit) { + for (amrex::OrientationIter oit; oit != nullptr; ++oit) { auto ori = oit(); const auto side = ori.faceDir(); const auto bct = ibctype[ori]; diff --git a/amr-wind/convection/incflo_godunov_advection.cpp b/amr-wind/convection/incflo_godunov_advection.cpp index bfe0fdcf1e..13790192a7 100644 --- a/amr-wind/convection/incflo_godunov_advection.cpp +++ b/amr-wind/convection/incflo_godunov_advection.cpp @@ -274,7 +274,7 @@ void godunov::compute_fluxes( const auto bc = pbc[n]; Real l_zylo, l_zyhi; Godunov_corner_couple_zy( - l_zylo, l_zyhi, i, j, k, n, l_dt, dy, iconserv[n], + l_zylo, l_zyhi, i, j, k, n, l_dt, dy, iconserv[n] != 0, zlo(i, j, k, n), zhi(i, j, k, n), q, vmac, yedge); Real wad = wmac(i, j, k); @@ -293,7 +293,7 @@ void godunov::compute_fluxes( const auto bc = pbc[n]; Real l_yzlo, l_yzhi; Godunov_corner_couple_yz( - l_yzlo, l_yzhi, i, j, k, n, l_dt, dz, iconserv[n], + l_yzlo, l_yzhi, i, j, k, n, l_dt, dz, iconserv[n] != 0, ylo(i, j, k, n), yhi(i, j, k, n), q, wmac, zedge); Real vad = vmac(i, j, k); @@ -313,7 +313,7 @@ void godunov::compute_fluxes( xbx, ncomp, [=] AMREX_GPU_DEVICE(int i, int j, int k, int n) noexcept { Real stl, sth; constexpr Real small_vel = 1.e-10; - if (iconserv[n]) { + if (iconserv[n] != 0) { stl = xlo(i, j, k, n) - (0.5 * dtdy) * (yzlo(i - 1, j + 1, k, n) * vmac(i - 1, j + 1, k) - @@ -360,7 +360,7 @@ void godunov::compute_fluxes( ? 0.5 * (stl + sth) : qx; - if (iconserv[n]) + if (iconserv[n] != 0) fx(i, j, k, n) = umac(i, j, k) * qx; else fx(i, j, k, n) = qx; @@ -380,7 +380,7 @@ void godunov::compute_fluxes( const auto bc = pbc[n]; Real l_xzlo, l_xzhi; Godunov_corner_couple_xz( - l_xzlo, l_xzhi, i, j, k, n, l_dt, dz, iconserv[n], + l_xzlo, l_xzhi, i, j, k, n, l_dt, dz, iconserv[n] != 0, xlo(i, j, k, n), xhi(i, j, k, n), q, wmac, zedge); Real uad = umac(i, j, k); @@ -399,7 +399,7 @@ void godunov::compute_fluxes( const auto bc = pbc[n]; Real l_zxlo, l_zxhi; Godunov_corner_couple_zx( - l_zxlo, l_zxhi, i, j, k, n, l_dt, dx, iconserv[n], + l_zxlo, l_zxhi, i, j, k, n, l_dt, dx, iconserv[n] != 0, zlo(i, j, k, n), zhi(i, j, k, n), q, umac, xedge); Real wad = wmac(i, j, k); @@ -419,7 +419,7 @@ void godunov::compute_fluxes( Real stl, sth; constexpr Real small_vel = 1.e-10; - if (iconserv[n]) { + if (iconserv[n] != 0) { stl = ylo(i, j, k, n) - (0.5 * dtdx) * (xzlo(i + 1, j - 1, k, n) * umac(i + 1, j - 1, k) - @@ -466,7 +466,7 @@ void godunov::compute_fluxes( ? 0.5 * (stl + sth) : qy; - if (iconserv[n]) + if (iconserv[n] != 0) fy(i, j, k, n) = vmac(i, j, k) * qy; else fy(i, j, k, n) = qy; @@ -486,7 +486,7 @@ void godunov::compute_fluxes( const auto bc = pbc[n]; Real l_xylo, l_xyhi; Godunov_corner_couple_xy( - l_xylo, l_xyhi, i, j, k, n, l_dt, dy, iconserv[n], + l_xylo, l_xyhi, i, j, k, n, l_dt, dy, iconserv[n] != 0, xlo(i, j, k, n), xhi(i, j, k, n), q, vmac, yedge); Real uad = umac(i, j, k); @@ -505,7 +505,7 @@ void godunov::compute_fluxes( const auto bc = pbc[n]; Real l_yxlo, l_yxhi; Godunov_corner_couple_yx( - l_yxlo, l_yxhi, i, j, k, n, l_dt, dx, iconserv[n], + l_yxlo, l_yxhi, i, j, k, n, l_dt, dx, iconserv[n] != 0, ylo(i, j, k, n), yhi(i, j, k, n), q, umac, xedge); Real vad = vmac(i, j, k); @@ -524,7 +524,7 @@ void godunov::compute_fluxes( zbx, ncomp, [=] AMREX_GPU_DEVICE(int i, int j, int k, int n) noexcept { Real stl, sth; constexpr Real small_vel = 1.e-10; - if (iconserv[n]) { + if (iconserv[n] != 0) { stl = zlo(i, j, k, n) - (0.5 * dtdx) * (xylo(i + 1, j, k - 1, n) * umac(i + 1, j, k - 1) - @@ -571,7 +571,7 @@ void godunov::compute_fluxes( ? 0.5 * (stl + sth) : qz; - if (iconserv[n]) + if (iconserv[n] != 0) fz(i, j, k, n) = wmac(i, j, k) * qz; else fz(i, j, k, n) = qz; @@ -599,7 +599,7 @@ void godunov::compute_advection( amrex::ParallelFor( bx, ncomp, [=] AMREX_GPU_DEVICE(int i, int j, int k, int n) noexcept { - if (iconserv[n]) { + if (iconserv[n] != 0) { dqdt(i, j, k, n) = dxinv[0] * (fx(i, j, k, n) - fx(i + 1, j, k, n)) + dxinv[1] * (fy(i, j, k, n) - fy(i, j + 1, k, n)) + diff --git a/amr-wind/core/MLMGOptions.cpp b/amr-wind/core/MLMGOptions.cpp index 6003d7604b..bd5412de73 100644 --- a/amr-wind/core/MLMGOptions.cpp +++ b/amr-wind/core/MLMGOptions.cpp @@ -64,7 +64,7 @@ void MLMGOptions::operator()(amrex::MLMG& mlmg) if (do_fixed_iters) mlmg.setFixedIter(max_iter); - mlmg.setNSolve(do_nsolve); + mlmg.setNSolve(static_cast(do_nsolve)); mlmg.setNSolveGridSize(nsolve_grid_size); mlmg.setPreSmooth(num_pre_smooth); mlmg.setPostSmooth(num_post_smooth); diff --git a/amr-wind/setup/init.cpp b/amr-wind/setup/init.cpp index 1ab40bc6fa..c02c71e186 100644 --- a/amr-wind/setup/init.cpp +++ b/amr-wind/setup/init.cpp @@ -102,7 +102,7 @@ void incflo::InitialIterations() } for (int iter = 0; iter < m_initial_iterations; ++iter) { - if (m_verbose) + if (m_verbose != 0) amrex::Print() << "In initial_iterations: iter = " << iter << "\n"; ApplyPredictor(true); @@ -141,7 +141,7 @@ void incflo::InitialProjection() BL_PROFILE("amr-wind::incflo::InitialProjection()"); amrex::Print() << "Begin initial projection" << std::endl; - if (m_verbose) { + if (m_verbose != 0) { PrintMaxValues("before initial projection"); } @@ -155,7 +155,7 @@ void incflo::InitialProjection() pressure().setVal(0.0); grad_p().setVal(0.0); - if (m_verbose) { + if (m_verbose != 0) { PrintMaxValues("after initial projection"); } amrex::Print() << "Completed initial projection" << std::endl << std::endl;