Skip to content

Commit

Permalink
Add fixes for readability-implicit-bool-conversion check. (Exawind#542)
Browse files Browse the repository at this point in the history
  • Loading branch information
jrood-nrel authored Dec 31, 2021
1 parent d424a89 commit 23e72e9
Show file tree
Hide file tree
Showing 5 changed files with 29 additions and 29 deletions.
2 changes: 1 addition & 1 deletion .clang-tidy
Original file line number Diff line number Diff line change
@@ -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
Expand Down
22 changes: 11 additions & 11 deletions amr-wind/boundary_conditions/BCInterface.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Expand All @@ -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);
Expand Down Expand Up @@ -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];

Expand All @@ -130,7 +130,7 @@ std::pair<const std::string, const std::string> 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];
Expand Down Expand Up @@ -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];
Expand Down Expand Up @@ -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];
Expand All @@ -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];
Expand Down Expand Up @@ -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];
Expand All @@ -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];
Expand All @@ -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];
Expand All @@ -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];
Expand Down
26 changes: 13 additions & 13 deletions amr-wind/convection/incflo_godunov_advection.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand All @@ -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);
Expand All @@ -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) -
Expand Down Expand Up @@ -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;
Expand All @@ -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);
Expand All @@ -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);
Expand All @@ -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) -
Expand Down Expand Up @@ -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;
Expand All @@ -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);
Expand All @@ -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);
Expand All @@ -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) -
Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -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)) +
Expand Down
2 changes: 1 addition & 1 deletion amr-wind/core/MLMGOptions.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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<int>(do_nsolve));
mlmg.setNSolveGridSize(nsolve_grid_size);
mlmg.setPreSmooth(num_pre_smooth);
mlmg.setPostSmooth(num_post_smooth);
Expand Down
6 changes: 3 additions & 3 deletions amr-wind/setup/init.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down Expand Up @@ -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");
}

Expand All @@ -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;
Expand Down

0 comments on commit 23e72e9

Please sign in to comment.