From 97555d411c94334567e380bfe7180c3b69bd01af Mon Sep 17 00:00:00 2001 From: Michael Zingale Date: Tue, 3 Sep 2024 12:56:08 -0400 Subject: [PATCH] some clang-tidy on radiation (#2950) --- .../Rad2Tshock/problem_initialize.H | 4 +- .../Rad2Tshock/problem_initialize_rad_data.H | 3 + .../problem_initialize_state_data.H | 2 +- Source/driver/Castro.cpp | 4 +- Source/radiation/HypreABec.H | 8 ++- Source/radiation/HypreExtMultiABec.H | 22 +++--- Source/radiation/HypreMultiABec.H | 68 +++++++++++-------- Source/radiation/MGRadBndry.H | 17 ++--- Source/radiation/MGRadBndry.cpp | 4 -- Source/radiation/NGBndry.H | 17 +---- Source/radiation/RadBndry.H | 16 ++--- Source/radiation/RadBndry.cpp | 4 -- Source/radiation/RadSolve.H | 1 - Source/radiation/Radiation.H | 6 +- Source/radiation/_interpbndry/RadBndryData.H | 27 +++++--- .../radiation/_interpbndry/RadBndryData.cpp | 5 -- 16 files changed, 99 insertions(+), 109 deletions(-) diff --git a/Exec/radiation_tests/Rad2Tshock/problem_initialize.H b/Exec/radiation_tests/Rad2Tshock/problem_initialize.H index 1405a5d6c2..4cffa04c3a 100644 --- a/Exec/radiation_tests/Rad2Tshock/problem_initialize.H +++ b/Exec/radiation_tests/Rad2Tshock/problem_initialize.H @@ -14,8 +14,8 @@ void problem_initialize () eos_state.rho = problem::rho0; eos_state.T = problem::T0; - for (int n = 0; n < NumSpec; n++) { - eos_state.xn[n] = 0.0_rt; + for (auto & X : eos_state.xn) { + X = 0.0_rt; } eos_state.xn[0] = 1.0_rt; diff --git a/Exec/radiation_tests/Rad2Tshock/problem_initialize_rad_data.H b/Exec/radiation_tests/Rad2Tshock/problem_initialize_rad_data.H index 860d2dcd60..87b4721254 100644 --- a/Exec/radiation_tests/Rad2Tshock/problem_initialize_rad_data.H +++ b/Exec/radiation_tests/Rad2Tshock/problem_initialize_rad_data.H @@ -12,6 +12,9 @@ void problem_initialize_rad_data (int i, int j, int k, const GeometryData& geomdata) { + amrex::ignore_unused(nugroup); + amrex::ignore_unused(dnugroup); + const Real* dx = geomdata.CellSize(); const Real* problo = geomdata.ProbLo(); diff --git a/Exec/radiation_tests/Rad2Tshock/problem_initialize_state_data.H b/Exec/radiation_tests/Rad2Tshock/problem_initialize_state_data.H index 96fe4057e0..c5e67920a5 100644 --- a/Exec/radiation_tests/Rad2Tshock/problem_initialize_state_data.H +++ b/Exec/radiation_tests/Rad2Tshock/problem_initialize_state_data.H @@ -16,7 +16,7 @@ void problem_initialize_state_data (int i, int j, int k, // Provides the simulation to be run in the x,y,or z direction // where length direction is the length side in a square prism - Real length_cell; + Real length_cell{}; if (problem::idir == 1) { length_cell = problo[0] + dx[0] * (static_cast(i) + 0.5_rt); } else if (problem::idir == 2) { diff --git a/Source/driver/Castro.cpp b/Source/driver/Castro.cpp index 0600a16d1c..d3fe48b979 100644 --- a/Source/driver/Castro.cpp +++ b/Source/driver/Castro.cpp @@ -737,7 +737,7 @@ Castro::Castro (Amr& papa, } radiation->regrid(level, grids, dmap); - rad_solver.reset(new RadSolve(parent, level, grids, dmap)); + rad_solver = std::make_unique(parent, level, grids, dmap); } #endif @@ -751,7 +751,7 @@ Castro::Castro (Amr& papa, Castro::~Castro () // NOLINT(modernize-use-equals-default) { #ifdef RADIATION - if (radiation != 0) { + if (radiation != nullptr) { //radiation->cleanup(level); radiation->close(level); } diff --git a/Source/radiation/HypreABec.H b/Source/radiation/HypreABec.H index 10cc5e96f6..b41f641427 100644 --- a/Source/radiation/HypreABec.H +++ b/Source/radiation/HypreABec.H @@ -33,6 +33,10 @@ class HypreABec { ~HypreABec(); + HypreABec(const HypreABec& a) = delete; + HypreABec(const HypreABec&& a) = delete; + HypreABec& operator= (const HypreABec& a) = delete; + HypreABec& operator= (const HypreABec&& a) = delete; /// /// @param v @@ -48,10 +52,10 @@ class HypreABec { /// void setScalars(amrex::Real alpha, amrex::Real beta); - amrex::Real getAlpha() const { + [[nodiscard]] amrex::Real getAlpha() const { return alpha; } - amrex::Real getBeta() const { + [[nodiscard]] amrex::Real getBeta() const { return beta; } diff --git a/Source/radiation/HypreExtMultiABec.H b/Source/radiation/HypreExtMultiABec.H index 911b2ca657..ee217fc1e1 100644 --- a/Source/radiation/HypreExtMultiABec.H +++ b/Source/radiation/HypreExtMultiABec.H @@ -23,12 +23,16 @@ class HypreExtMultiABec : public HypreMultiABec { a2coefs(fine_level+1), ccoefs( fine_level+1), d1coefs(fine_level+1), - d2coefs(fine_level+1), - alpha2(0.0), gamma(0.0), delta1(0.0), delta2(0.0) - { - } + d2coefs(fine_level+1) + {} + + ~HypreExtMultiABec() override; + + HypreExtMultiABec(const HypreExtMultiABec& src) = delete; + HypreExtMultiABec(const HypreExtMultiABec&& src) = delete; - ~HypreExtMultiABec(); + HypreExtMultiABec& operator= (const HypreExtMultiABec& src) = delete; + HypreExtMultiABec& operator= (const HypreExtMultiABec&& src) = delete; amrex::Real& a2Multiplier() { return alpha2; @@ -109,12 +113,12 @@ class HypreExtMultiABec : public HypreMultiABec { amrex::MultiFab& dest, int icomp, amrex::MultiFab& rhs, ///< will not be altered - BC_Mode inhom); + BC_Mode inhom) override; void loadLevelVectorB(int level, amrex::MultiFab& rhs, ///< will not be altered - BC_Mode inhom); + BC_Mode inhom) override; - void loadMatrix(); ///< once all level coeffs and scalars have been set + void loadMatrix() override; ///< once all level coeffs and scalars have been set /// @@ -134,7 +138,7 @@ class HypreExtMultiABec : public HypreMultiABec { amrex::Vector > > ccoefs; ///< face-based, 2 component amrex::Vector > > d1coefs; ///< cell-based but directional amrex::Vector > > d2coefs; ///< face-based - amrex::Real alpha2, gamma, delta1, delta2; ///< multipliers for the above + amrex::Real alpha2{}, gamma{}, delta1{}, delta2{}; ///< multipliers for the above }; #endif diff --git a/Source/radiation/HypreMultiABec.H b/Source/radiation/HypreMultiABec.H index 0a39aec47f..4aec6e89b9 100644 --- a/Source/radiation/HypreMultiABec.H +++ b/Source/radiation/HypreMultiABec.H @@ -21,38 +21,34 @@ class AuxVar { class Connex { public: - Connex() { - other = NULL; - } + Connex() : + other(nullptr) + {} /// /// @param p /// @param r /// - Connex(AuxVar* p, amrex::Real r) { - val = r; - other = p; - } + Connex(AuxVar* p, amrex::Real r) : + val(r), other(p) + {} /// /// @param lev /// @param iv /// @param r /// - Connex(int lev, const amrex::IntVect& iv, amrex::Real r) { - val = r; - index = iv; - level = lev; - other = NULL; - } + Connex(int lev, const amrex::IntVect& iv, amrex::Real r) : + val(r), index(iv), level(lev), other(nullptr) + {} /// /// @param c /// - bool same_target(const Connex& c) { - return ((other != NULL) + [[nodiscard]] bool same_target(const Connex& c) const { + return ((other != nullptr) ? (other == c.other) - : (c.other == NULL && level == c.level && index == c.index)); + : (c.other == nullptr && level == c.level && index == c.index)); } amrex::Real val; @@ -63,8 +59,7 @@ class AuxVar { public: - AuxVar() : secondary_flag(0) { - } + AuxVar() = default; /// @@ -72,7 +67,7 @@ class AuxVar { /// @param r /// void push(AuxVar* p, amrex::Real r) { - a.push_back(Connex(p,r)); + a.emplace_back(p, r); } @@ -82,7 +77,7 @@ class AuxVar { /// @param r /// void push(int lev, const amrex::IntVect& iv, amrex::Real r) { - a.push_back(Connex(lev,iv,r)); + a.emplace_back(lev, iv, r); } @@ -95,7 +90,7 @@ class AuxVar { /// @param p->secondary_flag /// if (p->secondary_flag == 0) { // don't count the same secondary twice - a.push_back(Connex(p,1.0)); + a.emplace_back(p, 1.0); p->secondary_flag = 1; } } @@ -104,7 +99,7 @@ class AuxVar { return a.empty(); } - bool secondary() { + [[nodiscard]] bool secondary() const { return secondary_flag; } @@ -128,7 +123,7 @@ class AuxVar { protected: std::list a; - int secondary_flag; + int secondary_flag{}; }; /// @@ -149,7 +144,7 @@ class AuxVarBox { /// @param bx /// AuxVarBox(const amrex::Box& bx) : domain(bx) { - int numpts = domain.numPts(); + auto numpts = domain.numPts(); dptr = new AuxVar[numpts]; } @@ -157,13 +152,19 @@ class AuxVarBox { delete[] dptr; } + AuxVarBox(const AuxVarBox& src) = delete; + AuxVarBox(const AuxVarBox&& src) = delete; + + AuxVarBox& operator= (const AuxVarBox& src) = delete; + AuxVarBox& operator= (const AuxVarBox&& src) = delete; + AuxVar& operator()(const amrex::IntVect& p) { BL_ASSERT(!(dptr == 0)); BL_ASSERT(domain.contains(p)); return dptr[domain.index(p)]; } - const amrex::Box& box() const { + [[nodiscard]] const amrex::Box& box() const { return domain; } @@ -346,7 +347,9 @@ class CrseBndryAuxVar : public BndryAuxVarBase { /// @param ori /// @param i /// - int size (const amrex::Orientation ori, int i) const { return aux[ori][i].size(); } + int size (const amrex::Orientation ori, int i) const { + return static_cast(aux[ori][i].size()); + } AuxVarBox& operator() (const amrex::Orientation ori, int i, int j) { return *aux[ori][i][j]; @@ -408,6 +411,11 @@ class HypreMultiABec { virtual ~HypreMultiABec(); + HypreMultiABec(const HypreMultiABec& src) = delete; + HypreMultiABec(const HypreMultiABec&& src) = delete; + + HypreMultiABec operator=(const HypreMultiABec& src) = delete; + HypreMultiABec operator=(const HypreMultiABec&& src) = delete; /// /// @param level @@ -422,10 +430,10 @@ class HypreMultiABec { const amrex::DistributionMapping& _dmap, amrex::IntVect _crse_ratio); - int crseLevel() { + [[nodiscard]] int crseLevel() const { return crse_level; } - int fineLevel() { + [[nodiscard]] int fineLevel() const { return fine_level; } @@ -501,10 +509,10 @@ class HypreMultiABec { /// void setScalars(amrex::Real alpha, amrex::Real beta); - amrex::Real getAlpha() const { + [[nodiscard]] amrex::Real getAlpha() const { return alpha; } - amrex::Real getBeta() const { + [[nodiscard]] amrex::Real getBeta() const { return beta; } diff --git a/Source/radiation/MGRadBndry.H b/Source/radiation/MGRadBndry.H index 8b922323d4..a565e2eb43 100644 --- a/Source/radiation/MGRadBndry.H +++ b/Source/radiation/MGRadBndry.H @@ -22,31 +22,28 @@ public: const int _ngroups, const amrex::Geometry& _geom); - ~MGRadBndry(); - - /// /// @param phys_bc /// @param geom /// @param ratio /// - virtual void setBndryConds(const amrex::BCRec& phys_bc, - const amrex::Geometry& geom, amrex::IntVect& ratio); + void setBndryConds(const amrex::BCRec& phys_bc, + const amrex::Geometry& geom, amrex::IntVect& ratio) override; /// /// @param bc /// @param phys_bc_mode /// - virtual void setBndryFluxConds(const amrex::BCRec& bc, - const BC_Mode phys_bc_mode = Inhomogeneous_BC); + void setBndryFluxConds(const amrex::BCRec& bc, + const BC_Mode phys_bc_mode = Inhomogeneous_BC) override; /// /// @param _face /// - virtual int mixedBndry(const amrex::Orientation& _face) const { - return (bcflag[_face] > 1) ? 1 : 0; + int mixedBndry(const amrex::Orientation& _face) const override { + return (bcflag[_face] > 1) ? 1 : 0; } @@ -99,7 +96,7 @@ public: NGBndry* operator()(const amrex::BoxArray& _grids, const amrex::DistributionMapping& _dmap, int _ngroups, - const amrex::Geometry& _geom) const { + const amrex::Geometry& _geom) const override { /// /// @param _grids diff --git a/Source/radiation/MGRadBndry.cpp b/Source/radiation/MGRadBndry.cpp index 73c4abf41a..32ab3824c9 100644 --- a/Source/radiation/MGRadBndry.cpp +++ b/Source/radiation/MGRadBndry.cpp @@ -58,10 +58,6 @@ MGRadBndry::MGRadBndry(const BoxArray& _grids, } } -MGRadBndry::~MGRadBndry() -{ -} - void MGRadBndry::init(const int _ngroups) { // obsolete implementation of the Marshak boundary condition requires diff --git a/Source/radiation/NGBndry.H b/Source/radiation/NGBndry.H index 0fccdaa3c3..e90c1faef2 100644 --- a/Source/radiation/NGBndry.H +++ b/Source/radiation/NGBndry.H @@ -22,16 +22,10 @@ class NGBndry : public RadInterpBndryData public: NGBndry(const amrex::BoxArray& _grids, const amrex::DistributionMapping& _dmap, int _ncomp, const amrex::Geometry& _geom) : - -/// -/// @param _grids -/// @param _dmap -/// @param _ncomp -/// @param _geom -/// RadInterpBndryData(_grids,_dmap,_ncomp,_geom) { } + /// /// @param bc /// @param phys_bc_mode @@ -51,7 +45,7 @@ public: /// /// @param _face /// - virtual int mixedBndry(const amrex::Orientation& _face) const { + virtual int mixedBndry(const amrex::Orientation& /* _face */) const { return 0; } @@ -62,13 +56,6 @@ protected: /// amrex::Vector< std::unique_ptr > > bctypearray[2*AMREX_SPACEDIM]; - -/// -/// @param src -/// -private: - NGBndry(const NGBndry& src); - NGBndry& operator=(const NGBndry& src); }; /// diff --git a/Source/radiation/RadBndry.H b/Source/radiation/RadBndry.H index 2f137f4e72..4781ee6c11 100644 --- a/Source/radiation/RadBndry.H +++ b/Source/radiation/RadBndry.H @@ -28,30 +28,28 @@ public: RadBndry(const amrex::BoxArray& _grids, const amrex::DistributionMapping& _dmap, const amrex::Geometry& _geom, amrex::Real bv); - ~RadBndry(); - /// /// @param phys_bc /// @param geom /// @param ratio /// - virtual void setBndryConds(const amrex::BCRec& phys_bc, - const amrex::Geometry& geom, amrex::IntVect& ratio); + void setBndryConds(const amrex::BCRec& phys_bc, + const amrex::Geometry& geom, amrex::IntVect& ratio) override; /// /// @param bc /// @param phys_bc_mode /// - virtual void setBndryFluxConds(const amrex::BCRec& bc, - const BC_Mode phys_bc_mode = Inhomogeneous_BC); + void setBndryFluxConds(const amrex::BCRec& bc, + const BC_Mode phys_bc_mode = Inhomogeneous_BC) override; /// /// @param _face /// - virtual int mixedBndry(const amrex::Orientation& _face) const { + int mixedBndry(const amrex::Orientation& _face) const override { return (bcflag[_face] > 1) ? 1 : 0; } @@ -110,8 +108,8 @@ public: /// NGBndry* operator()(const amrex::BoxArray& _grids, const amrex::DistributionMapping& _dmap, - int _ncomp, - const amrex::Geometry& _geom) const { + int /* _ncomp */, + const amrex::Geometry& _geom) const override { return new RadBndry(_grids, _dmap, _geom); } }; diff --git a/Source/radiation/RadBndry.cpp b/Source/radiation/RadBndry.cpp index 3635f8a512..aebb5b39fc 100644 --- a/Source/radiation/RadBndry.cpp +++ b/Source/radiation/RadBndry.cpp @@ -65,10 +65,6 @@ RadBndry::RadBndry(const BoxArray& _grids, const DistributionMapping& _dmap, setBndryValues(bv); } -RadBndry::~RadBndry() -{ -} - void RadBndry::init() { // obsolete implementation of the Marshak boundary condition requires diff --git a/Source/radiation/RadSolve.H b/Source/radiation/RadSolve.H index d85c6dee43..2fb694ab03 100644 --- a/Source/radiation/RadSolve.H +++ b/Source/radiation/RadSolve.H @@ -29,7 +29,6 @@ class RadSolve { RadSolve (amrex::Amr* Parent, int level, const amrex::BoxArray& grids, const amrex::DistributionMapping& dmap); - ~RadSolve () {} /// /// query runtime parameters diff --git a/Source/radiation/Radiation.H b/Source/radiation/Radiation.H index 58be11061a..7aff7e5bc5 100644 --- a/Source/radiation/Radiation.H +++ b/Source/radiation/Radiation.H @@ -111,8 +111,6 @@ public: /// @param restart /// Radiation(amrex::Amr* Parent, class Castro* castro, int restart = 0); - ~Radiation() { } - /// /// @param level @@ -193,11 +191,11 @@ public: return delta_T_rat_level[lev]; } - amrex::Real deltaEnergyTol() { + [[nodiscard]] amrex::Real deltaEnergyTol() const { return delta_e_rat_dt_tol; } - amrex::Real deltaTTol() { + [[nodiscard]] amrex::Real deltaTTol() const { return delta_T_rat_dt_tol; } diff --git a/Source/radiation/_interpbndry/RadBndryData.H b/Source/radiation/_interpbndry/RadBndryData.H index 3df1041532..c58eab3d9b 100644 --- a/Source/radiation/_interpbndry/RadBndryData.H +++ b/Source/radiation/_interpbndry/RadBndryData.H @@ -94,11 +94,25 @@ public: //@ManMemo: administrative functions //@ManDoc: default constructor RadBndryData() : amrex::BndryRegister() {}; + + ~RadBndryData() = default; + + // + // Disabled! + // +//@ManDoc: copy constructor + RadBndryData(const RadBndryData& src) = delete; +//@ManDoc: copy operator + RadBndryData& operator = (const RadBndryData& src) = delete; +//@ManDoc: move constructor + RadBndryData(const RadBndryData&& src) = delete; +//@ManDoc: move operator + RadBndryData& operator = (const RadBndryData&& src) = delete; + //@ManDoc: constructor specifying number of components and box of physical domain (cell-centered) RadBndryData(const amrex::BoxArray& _grids, const amrex::DistributionMapping& _dmap, int _ncomp, const ProxyGeometry& geom); -//@ManDoc: destructor - virtual ~RadBndryData(); + //@ManDoc: allocate bndry fabs along given face void define(const amrex::BoxArray& _grids, const amrex::DistributionMapping& _dmap, int _ncomp, const ProxyGeometry& geom); @@ -168,15 +182,6 @@ public: } -private: - // - // Disabled! - // -//@ManDoc: copy constructor - RadBndryData(const RadBndryData& src); -//@ManDoc: copy operator - RadBndryData& operator = (const RadBndryData& src); }; #endif - diff --git a/Source/radiation/_interpbndry/RadBndryData.cpp b/Source/radiation/_interpbndry/RadBndryData.cpp index 850a36e797..0439f707dc 100644 --- a/Source/radiation/_interpbndry/RadBndryData.cpp +++ b/Source/radiation/_interpbndry/RadBndryData.cpp @@ -32,10 +32,6 @@ RadBndryData::RadBndryData(const BoxArray& _grids, const DistributionMapping& _d // (*this) = src; // } -RadBndryData::~RadBndryData() -{ -} - std::ostream& operator << (std::ostream& os, const RadBndryData &mgb) { const BoxArray& grds = mgb.boxes(); @@ -129,4 +125,3 @@ RadBndryData::define(const BoxArray& _grids, const DistributionMapping& _dmap, } } } -