Skip to content

Commit

Permalink
Fix some readability (#254)
Browse files Browse the repository at this point in the history
fix readability-convert-member-functions-to-static, readability-make-member-function-const, readability-named-parameter, readability-inconsistent-declaration-parameter-name, readability-else-after-return, readability-redundant-smartptr-get, readability-simplify-boolean-expr, readability-container-data-pointer'
  • Loading branch information
marchdf authored Sep 19, 2023
1 parent e23761d commit 78e2284
Show file tree
Hide file tree
Showing 13 changed files with 41 additions and 41 deletions.
4 changes: 2 additions & 2 deletions Source/DiffusionOp.H
Original file line number Diff line number Diff line change
Expand Up @@ -108,13 +108,13 @@ public:
const amrex::Vector<amrex::MultiFab*>& a_laps,
const amrex::Vector<amrex::MultiFab const*>& a_phi,
const amrex::BCRec& a_bcrec,
int do_avgDown);
int do_avgDown) const;

void avgDownFluxes(
amrex::Vector<amrex::Array<amrex::MultiFab*, AMREX_SPACEDIM>> const&
a_fluxes,
int flux_comp,
int ncomp);
int ncomp) const;

void readParameters();

Expand Down
4 changes: 2 additions & 2 deletions Source/DiffusionOp.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -836,7 +836,7 @@ DiffusionOp::computeGradient(
const Vector<MultiFab*>& a_laps,
const Vector<MultiFab const*>& a_phi,
const BCRec& a_bcrec,
int do_avgDown)
int do_avgDown) const
{
BL_PROFILE("DiffusionOp::computeGradient()");

Expand Down Expand Up @@ -894,7 +894,7 @@ void
DiffusionOp::avgDownFluxes(
const Vector<Array<MultiFab*, AMREX_SPACEDIM>>& a_fluxes,
int flux_comp,
int ncomp)
int ncomp) const
{

int finest_level = m_pelelm->finestLevel();
Expand Down
4 changes: 2 additions & 2 deletions Source/PeleFlowControllerData.H
Original file line number Diff line number Diff line change
Expand Up @@ -25,15 +25,15 @@ struct hasFlowControllerData<T, decltype((void)T::FCData, void())>

template <typename T>
FlowControllerData*
getFCDataPtr(const T& a_t, std::false_type)
getFCDataPtr(const T& a_t, std::false_type /*unused*/)
{
amrex::ignore_unused(a_t);
return nullptr;
}

template <typename T>
FlowControllerData*
getFCDataPtr(T& a_t, std::true_type)
getFCDataPtr(T& a_t, std::true_type /*unused*/)
{
return &(a_t.FCData);
}
Expand Down
30 changes: 15 additions & 15 deletions Source/PeleLM.H
Original file line number Diff line number Diff line change
Expand Up @@ -941,11 +941,11 @@ public:
//-----------------------------------------------------------------------------
// I/O
void WritePlotFile();
bool writePlotNow();
bool checkMessage(const std::string& a_action);
bool writePlotNow() const;
bool checkMessage(const std::string& a_action) const;
void WriteCheckPointFile();
void ReadCheckPointFile();
bool writeCheckNow();
bool writeCheckNow() const;
void WriteJobInfo(const std::string& path) const;
void WriteHeader(const std::string& name, bool is_checkpoint) const;
void WriteDebugPlotFile(
Expand Down Expand Up @@ -982,7 +982,7 @@ public:
std::unique_ptr<AdvanceAdvData>& advData, const amrex::Geometry& a_geom);
void openTempFile();
void closeTempFile();
bool doTemporalsNow();
bool doTemporalsNow() const;
//-----------------------------------------------------------------------------

//-----------------------------------------------------------------------------
Expand Down Expand Up @@ -1244,9 +1244,9 @@ public:

amrex::Real
MFSum(const amrex::Vector<const amrex::MultiFab*>& a_MF, int comp);
amrex::Real
static amrex::Real
MFmax(const amrex::MultiFab* a_MF, const amrex::iMultiFab& a_mask, int comp);
amrex::Real
static amrex::Real
MFmin(const amrex::MultiFab* a_MF, const amrex::iMultiFab& a_mask, int comp);

amrex::Vector<amrex::Real> MLmax(
Expand Down Expand Up @@ -1291,15 +1291,15 @@ public:
void setTypicalValues(const PeleLM::TimeStamp& a_time, int is_init = 0);
void updateTypicalValuesChem();

void checkMemory(const std::string& a_message);
void checkMemory(const std::string& a_message) const;

// Mixture fraction & Progress variable
void initMixtureFraction();
void parseComposition(
static void parseComposition(
amrex::Vector<std::string> compositionIn,
std::string compositionType,
amrex::Real* massFrac);
void parseVars(
static void parseVars(
const amrex::Vector<std::string>& a_varNames,
const amrex::Vector<std::string>& a_stringIn,
amrex::Vector<amrex::Real>& a_rVars);
Expand Down Expand Up @@ -1529,9 +1529,9 @@ public:

//-----------------------------------------------------------------------------
// Accessors
std::string runMode() { return m_run_mode; }
std::string runMode() const { return m_run_mode; }

int nCompIR()
static int nCompIR()
{
#ifdef PELE_USE_EFIELD
return NUM_SPECIES + 1;
Expand All @@ -1540,7 +1540,7 @@ public:
#endif
}

int nCompForcing()
static int nCompForcing()
{
#ifdef PELE_USE_EFIELD
return NUM_SPECIES + 2;
Expand All @@ -1564,11 +1564,11 @@ public:
a_time == AmrOldTime || a_time == AmrNewTime || a_time == AmrHalfTime);
if (a_time == AmrOldTime) {
return m_t_old[lev];
} else if (a_time == AmrNewTime) {
}
if (a_time == AmrNewTime) {
return m_t_new[lev];
} else {
return 0.5 * (m_t_old[lev] + m_t_new[lev]);
}
return 0.5 * (m_t_old[lev] + m_t_new[lev]);
}

amrex::Vector<std::unique_ptr<amrex::MultiFab>>
Expand Down
8 changes: 4 additions & 4 deletions Source/PeleLM.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,8 @@ PeleLM::getLevelDataPtr(
a_time == AmrOldTime || a_time == AmrNewTime || a_time == AmrHalfTime);
if (a_time == AmrOldTime) {
return m_leveldata_old[lev].get();
} else if (a_time == AmrNewTime) {
}
if (a_time == AmrNewTime) {
return m_leveldata_new[lev].get();
} else {
m_leveldata_floating.reset(new LevelData(
Expand All @@ -66,9 +67,8 @@ PeleLM::getLevelDataReactPtr(int lev)
{
if (m_do_react != 0) {
return m_leveldatareact[lev].get();
} else {
return nullptr;
}
return nullptr;
}

Vector<std::unique_ptr<MultiFab>>
Expand Down Expand Up @@ -166,7 +166,7 @@ PeleLM::getDensityVect(const TimeStamp& a_time)
Real time = getTime(lev, a_time);
r.push_back(
std::make_unique<MultiFab>(grids[lev], dmap[lev], 1, m_nGrowState));
fillpatch_density(lev, time, *(r[lev].get()), 0, m_nGrowState);
fillpatch_density(lev, time, *(r[lev]), 0, m_nGrowState);
}
}
return r;
Expand Down
10 changes: 5 additions & 5 deletions Source/PeleLMDerive.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -129,13 +129,13 @@ PeleLMDeriveRec::variableComp(const std::string& a_name) const noexcept
{
if (n_derive == 1) {
return 0;
} else {
for (int comp = 0; comp < n_derive; comp++) {
if (variable_names[comp] == a_name) {
return comp;
}
}
for (int comp = 0; comp < n_derive; comp++) {
if (variable_names[comp] == a_name) {
return comp;
}
}

return -1;
}

Expand Down
2 changes: 1 addition & 1 deletion Source/PeleLMDiagnostics.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ PeleLM::doDiagnostics()
if (rec != nullptr) {
mf_idx = rec->variableComp(m_diagVars[v]);
}
MultiFab::Copy(*diagMFVec[lev].get(), *mf, mf_idx, v, 1, 1);
MultiFab::Copy(*diagMFVec[lev], *mf, mf_idx, v, 1, 1);
}
}

Expand Down
4 changes: 2 additions & 2 deletions Source/PeleLMDiffusion.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -417,7 +417,7 @@ PeleLM::addWbarTerm(
lev, 0, NUM_SPECIES, doZeroVisc, bcRecSpec, *a_beta[lev], addTurbContrib);

const Box& domain = geom[lev].Domain();
bool use_harmonic_avg = m_harm_avg_cen2edge != 0 ? true : false;
bool use_harmonic_avg = m_harm_avg_cen2edge != 0;

#ifdef AMREX_USE_OMP
#pragma omp parallel if (Gpu::notInLaunchRegion())
Expand Down Expand Up @@ -541,7 +541,7 @@ PeleLM::addSoretTerm(
lev, NUM_SPECIES + 2, NUM_SPECIES, doZeroVisc, bcRecSpec, *a_beta[lev]);

const Box& domain = geom[lev].Domain();
bool use_harmonic_avg = m_harm_avg_cen2edge != 0 ? true : false;
bool use_harmonic_avg = m_harm_avg_cen2edge != 0;

#ifdef AMREX_USE_OMP
#pragma omp parallel if (Gpu::notInLaunchRegion())
Expand Down
8 changes: 4 additions & 4 deletions Source/PeleLMEvolve.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,7 @@ PeleLM::Evolve()
}

bool
PeleLM::writePlotNow()
PeleLM::writePlotNow() const
{
bool write_now = false;

Expand Down Expand Up @@ -167,7 +167,7 @@ PeleLM::writePlotNow()
}

bool
PeleLM::writeCheckNow()
PeleLM::writeCheckNow() const
{
bool write_now = false;

Expand Down Expand Up @@ -209,7 +209,7 @@ PeleLM::writeCheckNow()
}

bool
PeleLM::doTemporalsNow()
PeleLM::doTemporalsNow() const
{
bool write_now = false;

Expand All @@ -221,7 +221,7 @@ PeleLM::doTemporalsNow()
}

bool
PeleLM::checkMessage(const std::string& a_action)
PeleLM::checkMessage(const std::string& a_action) const
{
bool take_action = false;

Expand Down
2 changes: 1 addition & 1 deletion Source/PeleLMFlowController.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ PeleLM::initActiveControl()
}

// Initialize flow controller
if (hasFlowControllerData<ProbParm>::value == false) {
if (!hasFlowControllerData<ProbParm>::value) {
Abort("ProbParm doesn't have a FCData FlowControllerData member variable");
}

Expand Down
2 changes: 1 addition & 1 deletion Source/PeleLMSetup.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1148,7 +1148,7 @@ PeleLM::taggingSetup()
Vector<Real> box_hi(AMREX_SPACEDIM);
ppr.getarr("in_box_lo", box_lo, 0, box_lo.size());
ppr.getarr("in_box_hi", box_hi, 0, box_hi.size());
realbox = RealBox(&(box_lo[0]), &(box_hi[0]));
realbox = RealBox(box_lo.data(), box_hi.data());
}

AMRErrorTagInfo info;
Expand Down
2 changes: 1 addition & 1 deletion Source/PeleLMTransportProp.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -387,7 +387,7 @@ PeleLM::getDiffusivity(
EB_set_covered_faces(GetArrOfPtrs(beta_ec), 1.234e40);
#else
// NON-EB : use cen2edg_cpp
bool use_harmonic_avg = m_harm_avg_cen2edge != 0 ? true : false;
bool use_harmonic_avg = m_harm_avg_cen2edge != 0;

#ifdef AMREX_USE_OMP
#pragma omp parallel if (Gpu::notInLaunchRegion())
Expand Down
2 changes: 1 addition & 1 deletion Source/PeleLMUtils.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1593,7 +1593,7 @@ PeleLM::MLmin(const Vector<const MultiFab*>& a_MF, int scomp, int ncomp)
}

void
PeleLM::checkMemory(const std::string& a_message)
PeleLM::checkMemory(const std::string& a_message) const
{
if (m_checkMem == 0) {
return;
Expand Down

0 comments on commit 78e2284

Please sign in to comment.