From 07c4e95b2469eef846210bcfa835ebeb1ffbf602 Mon Sep 17 00:00:00 2001 From: Michael Zingale Date: Wed, 27 Mar 2024 16:44:52 -0400 Subject: [PATCH] address some clang-tidy warnings in gravity (#2801) --- Source/gravity/Castro_gravity.cpp | 2 +- Source/gravity/Gravity.H | 32 +++++++++++++++---------------- Source/gravity/Gravity.cpp | 25 ++++++++++++------------ Source/reactions/Castro_react.cpp | 4 ++-- 4 files changed, 31 insertions(+), 32 deletions(-) diff --git a/Source/gravity/Castro_gravity.cpp b/Source/gravity/Castro_gravity.cpp index ed8a2406e0..bf9dc4f6b7 100644 --- a/Source/gravity/Castro_gravity.cpp +++ b/Source/gravity/Castro_gravity.cpp @@ -388,7 +388,7 @@ void Castro::construct_old_gravity_source(MultiFab& source, MultiFab& state_in, Real SrE{}; - if (castro::grav_source_type == 1 || castro::grav_source_type == 2) { + if (castro::grav_source_type == 1 || castro::grav_source_type == 2) { // NOLINT(bugprone-branch-clone) // Src = rho u dot g, evaluated with all quantities at t^n diff --git a/Source/gravity/Gravity.H b/Source/gravity/Gravity.H index af7ff177fa..0f6aba88ac 100644 --- a/Source/gravity/Gravity.H +++ b/Source/gravity/Gravity.H @@ -127,7 +127,7 @@ public: /// @param time Current time /// @param multi_level boolean, do we iterate over all levels or mask off fine grids? /// - void set_mass_offset(amrex::Real time, bool multi_level=true); + void set_mass_offset(amrex::Real time, bool multi_level=true) const; /// /// Return ``grad_phi_prev`` at given level @@ -242,17 +242,17 @@ public: /// /// Compute the difference between level and composite solves /// -/// @param level level index -/// @param comp_phi MultiFab containing computed phi -/// @param comp_gphi Vector of MultiFabs containing computed grad phi -/// @param cml_phi MultiFab, computed minus level phi -/// @param cml_gphi Vector of MultiFabs, computed minus level grad phi +/// @param level level index +/// @param comp_phi MultiFab containing computed phi +/// @param comp_gphi Vector of MultiFabs containing computed grad phi +/// @param comp_minus_level_phi MultiFab, computed minus level phi +/// @param comp_minus_level_grad_phi Vector of MultiFabs, computed minus level grad phi /// void create_comp_minus_level_grad_phi(int level, amrex::MultiFab& comp_phi, const amrex::Vector& comp_gphi, - amrex::MultiFab& cml_phi, - amrex::Vector >& cml_gphi); + amrex::MultiFab& comp_minus_level_phi, + amrex::Vector >& comp_minus_level_grad_phi); /// @@ -348,7 +348,7 @@ public: /// @param radial_grav Radial gravity /// @param grav_vector Gravity vector /// - void interpolate_monopole_grav(int level, RealVector& radial_grav, amrex::MultiFab& grav_vector); + void interpolate_monopole_grav(int level, RealVector& radial_grav, amrex::MultiFab& grav_vector) const; /// /// Integrate radially outward to find radial mass distribution @@ -368,7 +368,7 @@ public: #ifdef GR_GRAV RealVector& radial_pres, #endif - int n1d, int level); + int n1d, int level) const; /// /// Implement multipole boundary conditions @@ -383,7 +383,7 @@ public: /// /// Initialize multipole gravity /// - void init_multipole_grav(); + void init_multipole_grav() const; #if (AMREX_SPACEDIM == 3) @@ -480,7 +480,7 @@ public: /// @param Rhs MultiFab /// @param coeffs Vector of MultiFabs /// - void applyMetricTerms(int level,amrex::MultiFab& Rhs, const amrex::Vector& coeffs); + void applyMetricTerms(int level,amrex::MultiFab& Rhs, const amrex::Vector& coeffs) const; /// /// @@ -488,7 +488,7 @@ public: /// @param level Index of level /// @param cc Cell-centered data /// - void unweight_cc(int level,amrex::MultiFab& cc); + void unweight_cc(int level,amrex::MultiFab& cc) const; /// /// @@ -496,7 +496,7 @@ public: /// @param level Index of level /// @param edges Edge-based data /// - void unweight_edges(int level, const amrex::Vector& edges); + void unweight_edges(int level, const amrex::Vector& edges) const; #endif /// @@ -504,7 +504,7 @@ public: /// @param phi Gravitational potential /// @param grav_vector Gravity vector /// - void add_pointmass_to_gravity (int level, amrex::MultiFab& phi, amrex::MultiFab& grav_vector); + void add_pointmass_to_gravity (int level, amrex::MultiFab& phi, amrex::MultiFab& grav_vector) const; /// /// Get the rhs @@ -546,7 +546,7 @@ public: const amrex::Vector >& grad_phi, const amrex::Vector& res, const amrex::MultiFab* const crse_bcdata, - amrex::Real rel_eps, amrex::Real abs_eps); + amrex::Real rel_eps, amrex::Real abs_eps) const; /// diff --git a/Source/gravity/Gravity.cpp b/Source/gravity/Gravity.cpp index 606562c843..02c02c0ea0 100644 --- a/Source/gravity/Gravity.cpp +++ b/Source/gravity/Gravity.cpp @@ -1318,7 +1318,7 @@ Gravity::test_composite_phi (int crse_level) } void -Gravity::interpolate_monopole_grav(int level, RealVector& radial_grav, MultiFab& grav_vector) +Gravity::interpolate_monopole_grav(int level, RealVector& radial_grav, MultiFab& grav_vector) const { BL_PROFILE("Gravity::interpolate_monopole_grav()"); @@ -1434,7 +1434,7 @@ Gravity::compute_radial_mass(const Box& bx, #ifdef GR_GRAV RealVector& radial_pres_local, #endif - int n1d, int level) + int n1d, int level) const { const Geometry& geom = parent->Geom(level); @@ -1599,7 +1599,7 @@ Gravity::compute_radial_mass(const Box& bx, } void -Gravity::init_multipole_grav() +Gravity::init_multipole_grav() const { if (gravity::lnum < 0) { amrex::Abort("lnum negative"); @@ -1691,7 +1691,7 @@ Gravity::init_multipole_grav() multipole::parity_q0(l) = 1.0_rt; if (l % 2 != 0) { - if (AMREX_SPACEDIM == 3 && (multipole::doReflectionLo(2) || multipole::doReflectionHi(2))) { + if (AMREX_SPACEDIM == 3 && (multipole::doReflectionLo(2) || multipole::doReflectionHi(2))) { // NOLINT(bugprone-branch-clone) multipole::parity_q0(l) = 0.0_rt; } else if (AMREX_SPACEDIM == 2 && parent->Geom(0).Coord() == 1) { @@ -1725,7 +1725,7 @@ Gravity::init_multipole_grav() if (AMREX_SPACEDIM == 3) { multipole::parity_qC_qS(l,m) = 1.0_rt; } - else if (AMREX_SPACEDIM == 2 && parent->Geom(0).Coord() == 1) { + else if (AMREX_SPACEDIM == 2 && parent->Geom(0).Coord() == 1) { // NOLINT(bugprone-branch-clone) multipole::parity_qC_qS(l,m) = 0.0_rt; } else if (AMREX_SPACEDIM == 1 && parent->Geom(0).Coord() == 2) { @@ -2847,7 +2847,7 @@ Gravity::fill_direct_sum_BCs(int crse_level, int fine_level, const Vector& coeffs) +Gravity::applyMetricTerms(int level, MultiFab& Rhs, const Vector& coeffs) const { BL_PROFILE("Gravity::applyMetricTerms()"); @@ -2877,7 +2877,7 @@ Gravity::applyMetricTerms(int level, MultiFab& Rhs, const Vector& coe } void -Gravity::unweight_cc(int level, MultiFab& cc) +Gravity::unweight_cc(int level, MultiFab& cc) const { BL_PROFILE("Gravity::unweight_cc()"); @@ -2896,7 +2896,7 @@ Gravity::unweight_cc(int level, MultiFab& cc) } void -Gravity::unweight_edges(int level, const Vector& edges) +Gravity::unweight_edges(int level, const Vector& edges) const { BL_PROFILE("Gravity::unweight_edges()"); @@ -2949,7 +2949,7 @@ Gravity::make_mg_bc () } void -Gravity::set_mass_offset (Real time, bool multi_level) +Gravity::set_mass_offset (Real time, bool multi_level) const { BL_PROFILE("Gravity::set_mass_offset()"); @@ -2999,7 +2999,7 @@ Gravity::set_mass_offset (Real time, bool multi_level) } void -Gravity::add_pointmass_to_gravity (int level, MultiFab& phi, MultiFab& grav_vector) +Gravity::add_pointmass_to_gravity (int level, MultiFab& phi, MultiFab& grav_vector) const { BL_PROFILE("Gravity::add_pointmass_to_gravity()"); @@ -3094,8 +3094,7 @@ Gravity::make_radial_gravity(int level, Real time, RealVector& radial_grav) // Create MultiFab with NUM_STATE components and no ghost cells MultiFab S(grids[lev],dmap[lev],NUM_STATE,0); - if ( eps == 0.0 ) - { + if ( eps == 0.0 ) { // NOLINT(bugprone-branch-clone,-warnings-as-errors) // Old and new time are identical; this should only happen if // dt is smaller than roundoff compared to the current time, // in which case we're probably in trouble anyway, @@ -3713,7 +3712,7 @@ Gravity::actual_solve_with_mlmg (int crse_level, int fine_level, const amrex::Vector >& grad_phi, const amrex::Vector& res, const amrex::MultiFab* const crse_bcdata, - amrex::Real rel_eps, amrex::Real abs_eps) + amrex::Real rel_eps, amrex::Real abs_eps) const { BL_PROFILE("Gravity::actual_solve_with_mlmg()"); diff --git a/Source/reactions/Castro_react.cpp b/Source/reactions/Castro_react.cpp index bc070c7359..3e6ff3949b 100644 --- a/Source/reactions/Castro_react.cpp +++ b/Source/reactions/Castro_react.cpp @@ -12,8 +12,8 @@ using namespace amrex; #ifndef TRUE_SDC advance_status -Castro::do_old_reactions (Real time, Real dt) -{ +Castro::do_old_reactions (Real time, Real dt) { // NOLINT(readability-convert-member-functions-to-static) + amrex::ignore_unused(time); amrex::ignore_unused(dt);