From 78e2284fb714941eae8f379d093fcdcea77f33ca Mon Sep 17 00:00:00 2001 From: "Marc T. Henry de Frahan" Date: Tue, 19 Sep 2023 14:47:43 -0600 Subject: [PATCH] Fix some readability (#254) 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' --- Source/DiffusionOp.H | 4 ++-- Source/DiffusionOp.cpp | 4 ++-- Source/PeleFlowControllerData.H | 4 ++-- Source/PeleLM.H | 30 +++++++++++++++--------------- Source/PeleLM.cpp | 8 ++++---- Source/PeleLMDerive.cpp | 10 +++++----- Source/PeleLMDiagnostics.cpp | 2 +- Source/PeleLMDiffusion.cpp | 4 ++-- Source/PeleLMEvolve.cpp | 8 ++++---- Source/PeleLMFlowController.cpp | 2 +- Source/PeleLMSetup.cpp | 2 +- Source/PeleLMTransportProp.cpp | 2 +- Source/PeleLMUtils.cpp | 2 +- 13 files changed, 41 insertions(+), 41 deletions(-) diff --git a/Source/DiffusionOp.H b/Source/DiffusionOp.H index 75b74314..a96d2f09 100644 --- a/Source/DiffusionOp.H +++ b/Source/DiffusionOp.H @@ -108,13 +108,13 @@ public: const amrex::Vector& a_laps, const amrex::Vector& a_phi, const amrex::BCRec& a_bcrec, - int do_avgDown); + int do_avgDown) const; void avgDownFluxes( amrex::Vector> const& a_fluxes, int flux_comp, - int ncomp); + int ncomp) const; void readParameters(); diff --git a/Source/DiffusionOp.cpp b/Source/DiffusionOp.cpp index 3387b8d8..b66f2992 100644 --- a/Source/DiffusionOp.cpp +++ b/Source/DiffusionOp.cpp @@ -836,7 +836,7 @@ DiffusionOp::computeGradient( const Vector& a_laps, const Vector& a_phi, const BCRec& a_bcrec, - int do_avgDown) + int do_avgDown) const { BL_PROFILE("DiffusionOp::computeGradient()"); @@ -894,7 +894,7 @@ void DiffusionOp::avgDownFluxes( const Vector>& a_fluxes, int flux_comp, - int ncomp) + int ncomp) const { int finest_level = m_pelelm->finestLevel(); diff --git a/Source/PeleFlowControllerData.H b/Source/PeleFlowControllerData.H index 9fc25cfc..56f3cac6 100644 --- a/Source/PeleFlowControllerData.H +++ b/Source/PeleFlowControllerData.H @@ -25,7 +25,7 @@ struct hasFlowControllerData template 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; @@ -33,7 +33,7 @@ getFCDataPtr(const T& a_t, std::false_type) template FlowControllerData* -getFCDataPtr(T& a_t, std::true_type) +getFCDataPtr(T& a_t, std::true_type /*unused*/) { return &(a_t.FCData); } diff --git a/Source/PeleLM.H b/Source/PeleLM.H index 5ad58745..43e1a201 100644 --- a/Source/PeleLM.H +++ b/Source/PeleLM.H @@ -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( @@ -982,7 +982,7 @@ public: std::unique_ptr& advData, const amrex::Geometry& a_geom); void openTempFile(); void closeTempFile(); - bool doTemporalsNow(); + bool doTemporalsNow() const; //----------------------------------------------------------------------------- //----------------------------------------------------------------------------- @@ -1244,9 +1244,9 @@ public: amrex::Real MFSum(const amrex::Vector& 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 MLmax( @@ -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 compositionIn, std::string compositionType, amrex::Real* massFrac); - void parseVars( + static void parseVars( const amrex::Vector& a_varNames, const amrex::Vector& a_stringIn, amrex::Vector& a_rVars); @@ -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; @@ -1540,7 +1540,7 @@ public: #endif } - int nCompForcing() + static int nCompForcing() { #ifdef PELE_USE_EFIELD return NUM_SPECIES + 2; @@ -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> diff --git a/Source/PeleLM.cpp b/Source/PeleLM.cpp index d52b2799..3cc1950a 100644 --- a/Source/PeleLM.cpp +++ b/Source/PeleLM.cpp @@ -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( @@ -66,9 +67,8 @@ PeleLM::getLevelDataReactPtr(int lev) { if (m_do_react != 0) { return m_leveldatareact[lev].get(); - } else { - return nullptr; } + return nullptr; } Vector> @@ -166,7 +166,7 @@ PeleLM::getDensityVect(const TimeStamp& a_time) Real time = getTime(lev, a_time); r.push_back( std::make_unique(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; diff --git a/Source/PeleLMDerive.cpp b/Source/PeleLMDerive.cpp index 696ebe05..a76a8ce2 100644 --- a/Source/PeleLMDerive.cpp +++ b/Source/PeleLMDerive.cpp @@ -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; } diff --git a/Source/PeleLMDiagnostics.cpp b/Source/PeleLMDiagnostics.cpp index ea6eb035..fe94b826 100644 --- a/Source/PeleLMDiagnostics.cpp +++ b/Source/PeleLMDiagnostics.cpp @@ -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); } } diff --git a/Source/PeleLMDiffusion.cpp b/Source/PeleLMDiffusion.cpp index 23213c94..bbdd448e 100644 --- a/Source/PeleLMDiffusion.cpp +++ b/Source/PeleLMDiffusion.cpp @@ -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()) @@ -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()) diff --git a/Source/PeleLMEvolve.cpp b/Source/PeleLMEvolve.cpp index f46e8cb7..23d19a44 100644 --- a/Source/PeleLMEvolve.cpp +++ b/Source/PeleLMEvolve.cpp @@ -119,7 +119,7 @@ PeleLM::Evolve() } bool -PeleLM::writePlotNow() +PeleLM::writePlotNow() const { bool write_now = false; @@ -167,7 +167,7 @@ PeleLM::writePlotNow() } bool -PeleLM::writeCheckNow() +PeleLM::writeCheckNow() const { bool write_now = false; @@ -209,7 +209,7 @@ PeleLM::writeCheckNow() } bool -PeleLM::doTemporalsNow() +PeleLM::doTemporalsNow() const { bool write_now = false; @@ -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; diff --git a/Source/PeleLMFlowController.cpp b/Source/PeleLMFlowController.cpp index 916c5d83..06b6e457 100644 --- a/Source/PeleLMFlowController.cpp +++ b/Source/PeleLMFlowController.cpp @@ -51,7 +51,7 @@ PeleLM::initActiveControl() } // Initialize flow controller - if (hasFlowControllerData::value == false) { + if (!hasFlowControllerData::value) { Abort("ProbParm doesn't have a FCData FlowControllerData member variable"); } diff --git a/Source/PeleLMSetup.cpp b/Source/PeleLMSetup.cpp index 91bc8849..14af31c2 100644 --- a/Source/PeleLMSetup.cpp +++ b/Source/PeleLMSetup.cpp @@ -1148,7 +1148,7 @@ PeleLM::taggingSetup() Vector 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; diff --git a/Source/PeleLMTransportProp.cpp b/Source/PeleLMTransportProp.cpp index 4c223143..11b03801 100644 --- a/Source/PeleLMTransportProp.cpp +++ b/Source/PeleLMTransportProp.cpp @@ -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()) diff --git a/Source/PeleLMUtils.cpp b/Source/PeleLMUtils.cpp index 1a672a52..0412ec1d 100644 --- a/Source/PeleLMUtils.cpp +++ b/Source/PeleLMUtils.cpp @@ -1593,7 +1593,7 @@ PeleLM::MLmin(const Vector& 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;