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

Fix readability-implicit-bool-conversion #251

Merged
merged 1 commit into from
Sep 18, 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
49 changes: 25 additions & 24 deletions Source/DiffusionOp.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,8 @@

// Solve LPInfo
LPInfo info_solve;
info_solve.setAgglomeration(1);
info_solve.setConsolidation(1);
info_solve.setAgglomeration(true);
info_solve.setConsolidation(true);
info_solve.setMaxCoarseningLevel(m_mg_max_coarsening_level);

// Apply LPInfo (no coarsening)
Expand All @@ -45,7 +45,7 @@
m_pelelm->DistributionMap(0, m_pelelm->finestLevel()), info_apply,
ebfactVec, m_ncomp));
#else
m_scal_apply_op.reset(new MLABecLaplacian(

Check warning on line 48 in Source/DiffusionOp.cpp

View workflow job for this annotation

GitHub Actions / Lint-clang-tidy

use std::make_unique instead [modernize-make-unique]
m_pelelm->Geom(0, m_pelelm->finestLevel()),
m_pelelm->boxArray(0, m_pelelm->finestLevel()),
m_pelelm->DistributionMap(0, m_pelelm->finestLevel()), info_apply, {},
Expand All @@ -61,7 +61,7 @@
m_pelelm->DistributionMap(0, m_pelelm->finestLevel()), info_solve,
ebfactVec, m_ncomp));
#else
m_scal_solve_op.reset(new MLABecLaplacian(

Check warning on line 64 in Source/DiffusionOp.cpp

View workflow job for this annotation

GitHub Actions / Lint-clang-tidy

use std::make_unique instead [modernize-make-unique]
m_pelelm->Geom(0, m_pelelm->finestLevel()),
m_pelelm->boxArray(0, m_pelelm->finestLevel()),
m_pelelm->DistributionMap(0, m_pelelm->finestLevel()), info_solve, {},
Expand All @@ -77,7 +77,7 @@
m_pelelm->DistributionMap(0, m_pelelm->finestLevel()), info_apply,
ebfactVec, m_ncomp));
#else
m_gradient_op.reset(new MLABecLaplacian(

Check warning on line 80 in Source/DiffusionOp.cpp

View workflow job for this annotation

GitHub Actions / Lint-clang-tidy

use std::make_unique instead [modernize-make-unique]
m_pelelm->Geom(0, m_pelelm->finestLevel()),
m_pelelm->boxArray(0, m_pelelm->finestLevel()),
m_pelelm->DistributionMap(0, m_pelelm->finestLevel()), info_apply, {},
Expand Down Expand Up @@ -121,10 +121,10 @@
AMREX_ASSERT(m_ncomp == 1 || m_ncomp == ncomp);
AMREX_ASSERT(a_phi[0]->nComp() >= phi_comp + ncomp);
AMREX_ASSERT(a_rhs[0]->nComp() >= rhs_comp + ncomp);
if (have_fluxes) {
if (have_fluxes != 0) {
AMREX_ASSERT(a_flux[0][0]->nComp() >= flux_comp + ncomp);
}
if (have_bcoeff) {
if (have_bcoeff != 0) {
AMREX_ASSERT(a_bcoeff[0]->nComp() >= bcoeff_comp + ncomp);
AMREX_ASSERT(a_bcrec.size() >= ncomp);
}
Expand All @@ -150,15 +150,15 @@
const Box& gbx = mfi.growntilebox();
auto const& a_phi_arr = a_phi[lev]->const_array(mfi, phi_comp);
auto const& a_rho_arr =
(have_density)
(have_density) != 0
? a_density[lev]->const_array(mfi)
: a_phi[lev]->const_array(mfi); // Get dummy Array4 if no density
auto const& phi_arr = phi[lev].array(mfi);
amrex::ParallelFor(
gbx, ncomp,
[a_phi_arr, a_rho_arr, phi_arr,
have_density] AMREX_GPU_DEVICE(int i, int j, int k, int n) noexcept {
if (have_density) {
if (have_density != 0) {
phi_arr(i, j, k, n) = a_phi_arr(i, j, k, n) / a_rho_arr(i, j, k);
} else {
phi_arr(i, j, k, n) = a_phi_arr(i, j, k, n);
Expand All @@ -173,11 +173,11 @@
// => \alpha = 1.0, A is a_acoeff if provided, 1.0 otherwise
// => \beta = a_dt, B face centered diffusivity bcoeff^{np1,k}

Real alpha = (isPoissonSolve) ? 0.0 : 1.0;
Real alpha = (isPoissonSolve) != 0 ? 0.0 : 1.0;
Real beta = a_dt;
m_scal_solve_op->setScalars(alpha, beta);
for (int lev = 0; lev <= finest_level; ++lev) {
if (have_acoeff) {
if (have_acoeff != 0) {
m_scal_solve_op->setACoeffs(lev, *a_acoeff[lev]);
} else {
m_scal_solve_op->setACoeffs(lev, 1.0);
Expand All @@ -200,14 +200,14 @@

// Set aliases and bcoeff comp
for (int lev = 0; lev <= finest_level; ++lev) {
if (have_fluxes) {
if (have_fluxes != 0) {
for (int idim = 0; idim < AMREX_SPACEDIM; idim++) {
fluxes[lev][idim] = new MultiFab(
*a_flux[lev][idim], amrex::make_alias, flux_comp + comp, m_ncomp);
}
}

if (have_bcoeff) {
if (have_bcoeff != 0) {
int doZeroVisc = 1;
int addTurbContrib = 1;
Vector<BCRec> subBCRec = {
Expand Down Expand Up @@ -251,7 +251,7 @@
GetVecOfPtrs(component), GetVecOfConstPtrs(rhs), m_mg_rtol, m_mg_atol);

// Need to get the fluxes
if (have_fluxes) {
if (have_fluxes != 0) {
#ifdef AMREX_USE_EB
mlmg.getFluxes(fluxes, MLMG::Location::FaceCentroid);
#else
Expand All @@ -278,15 +278,15 @@
const Box& bx = mfi.tilebox();
auto const& a_phi_arr = a_phi[lev]->array(mfi, phi_comp);
auto const& a_rho_arr =
(have_density)
(have_density) != 0
? a_density[lev]->const_array(mfi)
: a_phi[lev]->const_array(mfi); // Get dummy Array4 if no density
auto const& phi_arr = phi[lev].const_array(mfi);
amrex::ParallelFor(
bx, ncomp,
[a_phi_arr, a_rho_arr, phi_arr,
have_density] AMREX_GPU_DEVICE(int i, int j, int k, int n) noexcept {
if (have_density) {
if (have_density != 0) {
a_phi_arr(i, j, k, n) = phi_arr(i, j, k, n) * a_rho_arr(i, j, k);
} else {
a_phi_arr(i, j, k, n) = phi_arr(i, j, k, n);
Expand Down Expand Up @@ -622,15 +622,15 @@
const Box& gbx = mfi.growntilebox();
auto const& a_phi_arr = a_phi[lev]->const_array(mfi, phi_comp);
auto const& a_rho_arr =
(have_density)
(have_density) != 0
? a_density[lev]->const_array(mfi)
: a_phi[lev]->const_array(mfi); // Get dummy Array4 if no density
auto const& phi_arr = phi[lev].array(mfi);
amrex::ParallelFor(
gbx, ncomp,
[a_phi_arr, a_rho_arr, phi_arr,
have_density] AMREX_GPU_DEVICE(int i, int j, int k, int n) noexcept {
if (have_density) {
if (have_density != 0) {
phi_arr(i, j, k, n) = a_phi_arr(i, j, k, n) / a_rho_arr(i, j, k);
} else {
phi_arr(i, j, k, n) = a_phi_arr(i, j, k, n);
Expand Down Expand Up @@ -702,7 +702,7 @@
}

// Average down if requested
if (do_avgDown) {
if (do_avgDown != 0) {
avgDownFluxes(a_flux, flux_comp, ncomp);
}
}
Expand Down Expand Up @@ -869,7 +869,7 @@
a_phi[lev]->Factory());
MultiFab::Copy(phi[lev], *a_phi[lev], 0, 0, 1, 1);
m_gradient_op->setLevelBC(lev, &phi[lev]);
if (need_laplacian) {
if (need_laplacian != 0) {
laps.emplace_back(*a_laps[lev], amrex::make_alias, 0, 1);
} else {
laps.emplace_back(
Expand All @@ -885,13 +885,13 @@
#else
mlmg.getFluxes(a_grad, GetVecOfPtrs(phi), MLMG::Location::FaceCenter);
#endif
if (do_avgDown) {
if (do_avgDown != 0) {
avgDownFluxes(a_grad, 0, 1);
}
}

void
DiffusionOp::avgDownFluxes(

Check warning on line 894 in Source/DiffusionOp.cpp

View workflow job for this annotation

GitHub Actions / Lint-clang-tidy

method 'avgDownFluxes' can be made const [readability-make-member-function-const]
const Vector<Array<MultiFab*, AMREX_SPACEDIM>>& a_fluxes,
int flux_comp,
int ncomp)
Expand Down Expand Up @@ -967,7 +967,7 @@
m_pelelm->Geom(0, finest_level), m_pelelm->boxArray(0, finest_level),
m_pelelm->DistributionMap(0, finest_level), info_solve, ebfactVec));
#else
m_solve_op.reset(new MLTensorOp(

Check warning on line 970 in Source/DiffusionOp.cpp

View workflow job for this annotation

GitHub Actions / Lint-clang-tidy

use std::make_unique instead [modernize-make-unique]
m_pelelm->Geom(0, finest_level), m_pelelm->boxArray(0, finest_level),
m_pelelm->DistributionMap(0, finest_level), info_solve));
#endif
Expand All @@ -985,7 +985,7 @@
m_pelelm->Geom(0, finest_level), m_pelelm->boxArray(0, finest_level),
m_pelelm->DistributionMap(0, finest_level), info_apply, ebfactVec));
#else
m_apply_op.reset(new MLTensorOp(

Check warning on line 988 in Source/DiffusionOp.cpp

View workflow job for this annotation

GitHub Actions / Lint-clang-tidy

use std::make_unique instead [modernize-make-unique]
m_pelelm->Geom(0, finest_level), m_pelelm->boxArray(0, finest_level),
m_pelelm->DistributionMap(0, finest_level), info_apply));
#endif
Expand Down Expand Up @@ -1108,7 +1108,8 @@
#else
m_apply_op->setScalars(0.0, -scale);
for (int lev = 0; lev <= finest_level; ++lev) {
if (have_density) { // alpha being zero, not sure that this does anything.
if (have_density != 0) { // alpha being zero, not sure that this does
// anything.
m_apply_op->setACoeffs(lev, *a_density[lev]);
}
int doZeroVisc = 0;
Expand All @@ -1123,7 +1124,7 @@
mlmg.apply(a_divtau, GetVecOfPtrs(vel));
#endif

if (have_density) {
if (have_density != 0) {
for (int lev = 0; lev <= finest_level; ++lev) {
#ifdef AMREX_USE_OMP
#pragma omp parallel if (Gpu::notInLaunchRegion())
Expand Down Expand Up @@ -1163,7 +1164,7 @@

m_solve_op->setScalars(1.0, a_dt);
for (int lev = 0; lev <= finest_level; ++lev) {
if (have_density) {
if (have_density != 0) {
m_solve_op->setACoeffs(lev, *a_density[lev]);
} else {
m_solve_op->setACoeffs(lev, m_pelelm->m_rho);
Expand Down Expand Up @@ -1193,15 +1194,15 @@
Box const& bx = mfi.tilebox();
auto const& rhs_a = rhs[lev].array(mfi);
auto const& vel_a = a_vel[lev]->const_array(mfi);
auto const& rho_a = (have_density) ? a_density[lev]->const_array(mfi)
: Array4<const Real>{};
auto const& rho_a = (have_density) != 0 ? a_density[lev]->const_array(mfi)
: Array4<const Real>{};
amrex::ParallelFor(
bx, AMREX_SPACEDIM,
[=, rho_incomp = m_pelelm->m_rho,
is_incomp =
m_pelelm
->m_incompressible] AMREX_GPU_DEVICE(int i, int j, int k, int n) noexcept {
if (is_incomp) {
if (is_incomp != 0) {
rhs_a(i, j, k, n) = rho_incomp * vel_a(i, j, k, n);
} else {
rhs_a(i, j, k, n) = rho_a(i, j, k) * vel_a(i, j, k, n);
Expand Down
12 changes: 6 additions & 6 deletions Source/PeleLM.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ PeleLM::PeleLM() = default;

PeleLM::~PeleLM()
{
if (!m_incompressible) {
if (m_incompressible == 0) {
trans_parms.deallocate();
m_reactor->close();
}
Expand Down Expand Up @@ -47,7 +47,7 @@ PeleLM::getLevelDataPtr(
} else {
m_leveldata_floating.reset(new LevelData(
grids[lev], dmap[lev], *m_factory[lev], m_incompressible, m_has_divu,
m_nAux, m_nGrowState, m_use_soret, m_do_les));
m_nAux, m_nGrowState, m_use_soret, static_cast<int>(m_do_les)));
Real time = getTime(lev, a_time);
fillpatch_state(lev, time, m_leveldata_floating->state, m_nGrowState);
// if (useUMac) {
Expand All @@ -64,7 +64,7 @@ PeleLM::getLevelDataPtr(
PeleLM::LevelDataReact*
PeleLM::getLevelDataReactPtr(int lev)
{
if (m_do_react) {
if (m_do_react != 0) {
return m_leveldatareact[lev].get();
} else {
return nullptr;
Expand All @@ -77,7 +77,7 @@ PeleLM::getStateVect(const TimeStamp& a_time)
Vector<std::unique_ptr<MultiFab>> r;
r.reserve(finest_level + 1);
if (a_time == AmrOldTime) {
if (m_incompressible) {
if (m_incompressible != 0) {
for (int lev = 0; lev <= finest_level; ++lev) {
r.push_back(std::make_unique<MultiFab>(
m_leveldata_old[lev]->state, amrex::make_alias, 0, AMREX_SPACEDIM));
Expand All @@ -89,7 +89,7 @@ PeleLM::getStateVect(const TimeStamp& a_time)
}
}
} else {
if (m_incompressible) {
if (m_incompressible != 0) {
for (int lev = 0; lev <= finest_level; ++lev) {
r.push_back(std::make_unique<MultiFab>(
m_leveldata_new[lev]->state, amrex::make_alias, 0, AMREX_SPACEDIM));
Expand Down Expand Up @@ -279,7 +279,7 @@ PeleLM::getIRVect()
void
PeleLM::averageDownState(const PeleLM::TimeStamp& a_time)
{
int nCompState = (m_incompressible) ? AMREX_SPACEDIM : NVAR;
int nCompState = (m_incompressible) != 0 ? AMREX_SPACEDIM : NVAR;
for (int lev = finest_level; lev > 0; --lev) {
auto* ldataFine_p = getLevelDataPtr(lev, a_time);
auto* ldataCrse_p = getLevelDataPtr(lev - 1, a_time);
Expand Down
24 changes: 12 additions & 12 deletions Source/PeleLMAdvance.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -22,12 +22,12 @@ PeleLM::Advance(int is_initIter)
//----------------------------------------------------------------

// Deal with ambient pressure
if (m_closed_chamber) {
if (m_closed_chamber != 0) {
m_pNew = m_pOld;
}

// Put together new typical values
if (!is_initIter && m_nstep > 0 && m_nstep % m_resetTypValInt == 0) {
if ((is_initIter == 0) && m_nstep > 0 && m_nstep % m_resetTypValInt == 0) {
setTypicalValues(AmrNewTime);
}

Expand All @@ -54,7 +54,7 @@ PeleLM::Advance(int is_initIter)
}
//----------------------------------------------------------------

if (m_verbose) {
if (m_verbose != 0) {
amrex::Print() << " STEP [" << m_nstep << "] - Time: " << m_cur_time
<< ", dt " << m_dt << "\n";
}
Expand Down Expand Up @@ -85,7 +85,7 @@ PeleLM::Advance(int is_initIter)
initTemporals();

// Reset velocity flux on boundary faces if doing closed chamber
if (m_closed_chamber) {
if (m_closed_chamber != 0) {
for (int idim = 0; idim < AMREX_SPACEDIM; idim++) {
m_domainUmacFlux[2 * idim] = 0.0;
m_domainUmacFlux[2 * idim + 1] = 0.0;
Expand All @@ -98,7 +98,7 @@ PeleLM::Advance(int is_initIter)

// compute t^{n} data
calcViscosity(AmrOldTime);
if (!m_incompressible) {
if (m_incompressible == 0) {
calcDiffusivity(AmrOldTime);
#ifdef PELE_USE_EFIELD
poissonSolveEF(AmrOldTime);
Expand All @@ -120,7 +120,7 @@ PeleLM::Advance(int is_initIter)
}
#endif

if (!m_incompressible) {
if (m_incompressible == 0) {
floorSpecies(AmrOldTime);

//----------------------------------------------------------------
Expand All @@ -139,7 +139,7 @@ PeleLM::Advance(int is_initIter)
BL_PROFILE_VAR_START(PLM_SETUP);
//----------------------------------------------------------------
copyTransportOldToNew();
if (!m_incompressible) {
if (m_incompressible == 0) {
copyDiffusionOldToNew(diffData);
#ifdef PELE_USE_EFIELD
ionDriftVelocity(advData);
Expand All @@ -150,7 +150,7 @@ PeleLM::Advance(int is_initIter)

//----------------------------------------------------------------
// Scalar advance
if (m_incompressible) {
if (m_incompressible != 0) {
Real MACStart = 0.0;
if (m_verbose > 1) {
MACStart = ParallelDescriptor::second();
Expand Down Expand Up @@ -187,7 +187,7 @@ PeleLM::Advance(int is_initIter)
clipSootMoments();
}
#endif
if (m_has_divu) {
if (m_has_divu != 0) {
int is_initialization = 0; // Not here
int computeDiffusionTerm =
1; // Yes, re-evaluate the diffusion term after the last chemistry solve
Expand All @@ -207,7 +207,7 @@ PeleLM::Advance(int is_initIter)
VelAdvStart = ParallelDescriptor::second();
}
// Re-evaluate viscosity only if scalar updated
if (!m_incompressible) {
if (m_incompressible == 0) {
calcViscosity(AmrNewTime);
}

Expand Down Expand Up @@ -237,7 +237,7 @@ PeleLM::Advance(int is_initIter)
//----------------------------------------------------------------

// Deal with ambient pressure
if (m_closed_chamber && !is_initIter) {
if ((m_closed_chamber != 0) && (is_initIter == 0)) {
m_pOld = m_pNew;
}

Expand Down Expand Up @@ -281,7 +281,7 @@ PeleLM::oneSDC(

calcDiffusivity(AmrNewTime);
computeDifferentialDiffusionTerms(AmrNewTime, diffData);
if (m_has_divu) {
if (m_has_divu != 0) {
int is_initialization = 0; // Not here
int computeDiffusionTerm = 0; // Nope, we just did that
int do_avgDown = 1; // Always
Expand Down
Loading
Loading