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

address some clang-tidy warnings in gravity #2801

Merged
merged 4 commits into from
Mar 27, 2024
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
2 changes: 1 addition & 1 deletion Source/gravity/Castro_gravity.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
32 changes: 16 additions & 16 deletions Source/gravity/Gravity.H
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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<amrex::MultiFab*>& comp_gphi,
amrex::MultiFab& cml_phi,
amrex::Vector<std::unique_ptr<amrex::MultiFab> >& cml_gphi);
amrex::MultiFab& comp_minus_level_phi,
amrex::Vector<std::unique_ptr<amrex::MultiFab> >& comp_minus_level_grad_phi);


///
Expand Down Expand Up @@ -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
Expand All @@ -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
Expand All @@ -383,7 +383,7 @@ public:
///
/// Initialize multipole gravity
///
void init_multipole_grav();
void init_multipole_grav() const;

#if (AMREX_SPACEDIM == 3)

Expand Down Expand Up @@ -480,31 +480,31 @@ public:
/// @param Rhs MultiFab
/// @param coeffs Vector of MultiFabs
///
void applyMetricTerms(int level,amrex::MultiFab& Rhs, const amrex::Vector<amrex::MultiFab*>& coeffs);
void applyMetricTerms(int level,amrex::MultiFab& Rhs, const amrex::Vector<amrex::MultiFab*>& coeffs) const;

///
///
///
/// @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;

///
///
///
/// @param level Index of level
/// @param edges Edge-based data
///
void unweight_edges(int level, const amrex::Vector<amrex::MultiFab*>& edges);
void unweight_edges(int level, const amrex::Vector<amrex::MultiFab*>& edges) const;
#endif

///
/// @param level Index of level
/// @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
Expand Down Expand Up @@ -546,7 +546,7 @@ public:
const amrex::Vector<std::array<amrex::MultiFab*,AMREX_SPACEDIM> >& grad_phi,
const amrex::Vector<amrex::MultiFab*>& res,
const amrex::MultiFab* const crse_bcdata,
amrex::Real rel_eps, amrex::Real abs_eps);
amrex::Real rel_eps, amrex::Real abs_eps) const;


///
Expand Down
25 changes: 12 additions & 13 deletions Source/gravity/Gravity.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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()");

Expand Down Expand Up @@ -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);

Expand Down Expand Up @@ -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");
Expand Down Expand Up @@ -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) {
Expand Down Expand Up @@ -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) {
Expand Down Expand Up @@ -2847,7 +2847,7 @@ Gravity::fill_direct_sum_BCs(int crse_level, int fine_level, const Vector<MultiF

#if (AMREX_SPACEDIM < 3)
void
Gravity::applyMetricTerms(int level, MultiFab& Rhs, const Vector<MultiFab*>& coeffs)
Gravity::applyMetricTerms(int level, MultiFab& Rhs, const Vector<MultiFab*>& coeffs) const
{
BL_PROFILE("Gravity::applyMetricTerms()");

Expand Down Expand Up @@ -2877,7 +2877,7 @@ Gravity::applyMetricTerms(int level, MultiFab& Rhs, const Vector<MultiFab*>& coe
}

void
Gravity::unweight_cc(int level, MultiFab& cc)
Gravity::unweight_cc(int level, MultiFab& cc) const
{
BL_PROFILE("Gravity::unweight_cc()");

Expand All @@ -2896,7 +2896,7 @@ Gravity::unweight_cc(int level, MultiFab& cc)
}

void
Gravity::unweight_edges(int level, const Vector<MultiFab*>& edges)
Gravity::unweight_edges(int level, const Vector<MultiFab*>& edges) const
{
BL_PROFILE("Gravity::unweight_edges()");

Expand Down Expand Up @@ -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()");

Expand Down Expand Up @@ -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()");

Expand Down Expand Up @@ -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,
Expand Down Expand Up @@ -3713,7 +3712,7 @@ Gravity::actual_solve_with_mlmg (int crse_level, int fine_level,
const amrex::Vector<std::array<amrex::MultiFab*,AMREX_SPACEDIM> >& grad_phi,
const amrex::Vector<amrex::MultiFab*>& 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()");

Expand Down
4 changes: 2 additions & 2 deletions Source/reactions/Castro_react.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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);

Expand Down