Skip to content

Commit

Permalink
some clang-tidy on radiation (#2950)
Browse files Browse the repository at this point in the history
  • Loading branch information
zingale committed Sep 3, 2024
1 parent 4cc8a33 commit 97555d4
Show file tree
Hide file tree
Showing 16 changed files with 99 additions and 109 deletions.
4 changes: 2 additions & 2 deletions Exec/radiation_tests/Rad2Tshock/problem_initialize.H
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down
3 changes: 3 additions & 0 deletions Exec/radiation_tests/Rad2Tshock/problem_initialize_rad_data.H
Original file line number Diff line number Diff line change
Expand Up @@ -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();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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<Real>(i) + 0.5_rt);
} else if (problem::idir == 2) {
Expand Down
4 changes: 2 additions & 2 deletions Source/driver/Castro.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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<RadSolve>(parent, level, grids, dmap);
}
#endif

Expand All @@ -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);
}
Expand Down
8 changes: 6 additions & 2 deletions Source/radiation/HypreABec.H
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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;
}

Expand Down
22 changes: 13 additions & 9 deletions Source/radiation/HypreExtMultiABec.H
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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


///
Expand All @@ -134,7 +138,7 @@ class HypreExtMultiABec : public HypreMultiABec {
amrex::Vector<std::unique_ptr<amrex::Array<amrex::MultiFab, AMREX_SPACEDIM> > > ccoefs; ///< face-based, 2 component
amrex::Vector<std::unique_ptr<amrex::Array<amrex::MultiFab, AMREX_SPACEDIM> > > d1coefs; ///< cell-based but directional
amrex::Vector<std::unique_ptr<amrex::Array<amrex::MultiFab, AMREX_SPACEDIM> > > d2coefs; ///< face-based
amrex::Real alpha2, gamma, delta1, delta2; ///< multipliers for the above
amrex::Real alpha2{}, gamma{}, delta1{}, delta2{}; ///< multipliers for the above
};

#endif
68 changes: 38 additions & 30 deletions Source/radiation/HypreMultiABec.H
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -63,16 +59,15 @@ class AuxVar {

public:

AuxVar() : secondary_flag(0) {
}
AuxVar() = default;


///
/// @param p
/// @param r
///
void push(AuxVar* p, amrex::Real r) {
a.push_back(Connex(p,r));
a.emplace_back(p, r);
}


Expand All @@ -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);
}


Expand All @@ -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;
}
}
Expand All @@ -104,7 +99,7 @@ class AuxVar {
return a.empty();
}

bool secondary() {
[[nodiscard]] bool secondary() const {
return secondary_flag;
}

Expand All @@ -128,7 +123,7 @@ class AuxVar {
protected:

std::list<Connex> a;
int secondary_flag;
int secondary_flag{};
};

///
Expand All @@ -149,21 +144,27 @@ class AuxVarBox {
/// @param bx
///
AuxVarBox(const amrex::Box& bx) : domain(bx) {
int numpts = domain.numPts();
auto numpts = domain.numPts();
dptr = new AuxVar[numpts];
}

~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;
}

Expand Down Expand Up @@ -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<int>(aux[ori][i].size());
}

AuxVarBox& operator() (const amrex::Orientation ori, int i, int j) {
return *aux[ori][i][j];
Expand Down Expand Up @@ -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
Expand All @@ -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;
}

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

Expand Down
17 changes: 7 additions & 10 deletions Source/radiation/MGRadBndry.H
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}


Expand Down Expand Up @@ -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
Expand Down
4 changes: 0 additions & 4 deletions Source/radiation/MGRadBndry.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Loading

0 comments on commit 97555d4

Please sign in to comment.