Skip to content

Commit 5c45dc1

Browse files
committed
clang-tidy recommendations
1 parent aff9965 commit 5c45dc1

File tree

5 files changed

+28
-23
lines changed

5 files changed

+28
-23
lines changed

Source/FieldSolver/ImplicitSolvers/ImplicitSolver.H

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -91,7 +91,7 @@ public:
9191

9292
[[nodiscard]] int numAMRLevels () const { return m_num_amr_levels; }
9393

94-
[[nodiscard]] const amrex::Geometry& GetGeometry (const int) const;
94+
[[nodiscard]] const amrex::Geometry& GetGeometry (int) const;
9595
[[nodiscard]] const amrex::Array<FieldBoundaryType,AMREX_SPACEDIM>& GetFieldBoundaryLo () const;
9696
[[nodiscard]] const amrex::Array<FieldBoundaryType,AMREX_SPACEDIM>& GetFieldBoundaryHi () const;
9797
[[nodiscard]] const amrex::Array<amrex::LinOpBCType,AMREX_SPACEDIM> GetLinOpBCLo () const;
@@ -160,7 +160,7 @@ protected:
160160
/**
161161
* \brief Convert from WarpX FieldBoundaryType to amrex::LinOpBCType
162162
*/
163-
amrex::Array<amrex::LinOpBCType,AMREX_SPACEDIM> convertFieldBCToLinOpBC ( const amrex::Array<FieldBoundaryType,AMREX_SPACEDIM>& ) const;
163+
[[nodiscard]] amrex::Array<amrex::LinOpBCType,AMREX_SPACEDIM> convertFieldBCToLinOpBC ( const amrex::Array<FieldBoundaryType,AMREX_SPACEDIM>& ) const;
164164

165165
};
166166

Source/FieldSolver/ImplicitSolvers/ImplicitSolver.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@ const Array<LinOpBCType,AMREX_SPACEDIM> ImplicitSolver::GetLinOpBCHi () const
3232
Array<LinOpBCType,AMREX_SPACEDIM> ImplicitSolver::convertFieldBCToLinOpBC (const Array<FieldBoundaryType,AMREX_SPACEDIM>& a_fbc) const
3333
{
3434
Array<LinOpBCType, AMREX_SPACEDIM> lbc;
35+
for (auto& bc : lbc) { bc = LinOpBCType::interior; }
3536
for (int i = 0; i < AMREX_SPACEDIM; i++) {
3637
if (a_fbc[i] == FieldBoundaryType::PML) {
3738
WARPX_ABORT_WITH_MESSAGE("LinOpBCType not set for this FieldBoundaryType");

Source/NonlinearSolvers/CurlCurlMLMGPC.H

Lines changed: 13 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -68,15 +68,21 @@ class CurlCurlMLMGPC : public Preconditioner<T,Ops>
6868
*/
6969
~CurlCurlMLMGPC () override = default;
7070

71+
// Default move and copy operations
72+
CurlCurlMLMGPC(const CurlCurlMLMGPC&) = default;
73+
CurlCurlMLMGPC& operator=(const CurlCurlMLMGPC&) = default;
74+
CurlCurlMLMGPC(CurlCurlMLMGPC&&) noexcept = default;
75+
CurlCurlMLMGPC& operator=(CurlCurlMLMGPC&&) noexcept = default;
76+
7177
/**
7278
* \brief Define the preconditioner
7379
*/
74-
virtual void Define (const T&, Ops* const) override;
80+
void Define (const T&, Ops*) override;
7581

7682
/**
7783
* \brief Update the preconditioner
7884
*/
79-
virtual void Update (const T&) override;
85+
void Update (const T&) override;
8086

8187
/**
8288
* \brief Apply (solve) the preconditioner given a RHS
@@ -86,12 +92,12 @@ class CurlCurlMLMGPC : public Preconditioner<T,Ops>
8692
* where A is the linear operator, in this case, the curl-curl operator:
8793
* A x = curl (alpha * curl (x) ) + beta * x
8894
*/
89-
virtual void Apply (T&, const T&) override;
95+
void Apply (T&, const T&) override;
9096

9197
/**
9298
* \brief Print parameters
9399
*/
94-
virtual void printParameters() const override;
100+
void printParameters() const override;
95101

96102
/**
97103
* \brief Check if the nonlinear solver has been defined.
@@ -189,7 +195,7 @@ void CurlCurlMLMGPC<T,Ops>::printParameters() const
189195
template <class T, class Ops>
190196
void CurlCurlMLMGPC<T,Ops>::readParameters()
191197
{
192-
amrex::ParmParse pp(PreconditionerTypes::curl_curl_mlmg);
198+
const amrex::ParmParse pp(PreconditionerTypes::curl_curl_mlmg);
193199
pp.query("verbose", m_verbose);
194200
pp.query("bottom_verbose", m_bottom_verbose);
195201
pp.query("max_iter", m_max_iter);
@@ -200,8 +206,6 @@ void CurlCurlMLMGPC<T,Ops>::readParameters()
200206
pp.query("relative_tolerance", m_rtol);
201207
pp.query("use_gmres", m_use_gmres);
202208
pp.query("use_gmres_pc", m_use_gmres_pc);
203-
204-
return;
205209
}
206210

207211
template <class T, class Ops>
@@ -274,7 +278,6 @@ void CurlCurlMLMGPC<T,Ops>::Define ( const T& a_U,
274278
#endif
275279

276280
m_is_defined = true;
277-
return;
278281
}
279282

280283
template <class T, class Ops>
@@ -288,8 +291,8 @@ void CurlCurlMLMGPC<T,Ops>::Update (const T& a_U)
288291
amrex::ignore_unused(a_U);
289292

290293
// set the coefficients alpha and beta for curl-curl op
291-
RT alpha = (m_ops->theta()*this->m_dt*PhysConst::c) * (m_ops->theta()*this->m_dt*PhysConst::c);
292-
RT beta = RT(1.0);
294+
const RT alpha = (m_ops->theta()*this->m_dt*PhysConst::c) * (m_ops->theta()*this->m_dt*PhysConst::c);
295+
const RT beta = RT(1.0);
293296

294297
// currently not implemented in 1D
295298
#ifndef WARPX_DIM_1D_Z
@@ -303,8 +306,6 @@ void CurlCurlMLMGPC<T,Ops>::Update (const T& a_U)
303306
<< "alpha = " << alpha << ", "
304307
<< "beta = " << beta << "\n";
305308
}
306-
307-
return;
308309
}
309310

310311
template <class T, class Ops>
@@ -445,8 +446,6 @@ void CurlCurlMLMGPC<T,Ops>::Apply (T& a_x, const T& a_b)
445446
copyWarpXAMFFromMLCCAMF(x_mfarrvec[n], solution, IntVect::TheZeroVector());
446447

447448
}
448-
449-
return;
450449
}
451450

452451
#endif

Source/NonlinearSolvers/JacobianFunctionMF.H

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -158,7 +158,7 @@ class JacobianFunctionMF
158158
}
159159
}
160160

161-
void define( const T&, Ops* const, const std::string& );
161+
void define( const T&, Ops*, const std::string& );
162162

163163
private:
164164

@@ -172,8 +172,8 @@ class JacobianFunctionMF
172172
std::string m_pc_type = "none";
173173

174174
T m_Z, m_Y0, m_R0, m_R;
175-
Ops* m_ops;
176-
Preconditioner<T,Ops>* m_preCond;
175+
Ops* m_ops = nullptr;
176+
std::unique_ptr<Preconditioner<T,Ops>> m_preCond = nullptr;
177177
};
178178

179179
template <class T, class Ops>
@@ -188,12 +188,11 @@ void JacobianFunctionMF<T,Ops>::define ( const T& a_U,
188188

189189
m_ops = a_ops;
190190

191-
m_preCond = nullptr;
192191
m_usePreCond = (a_pc_type != "none");
193192
if (m_usePreCond) {
194193
m_pc_type = a_pc_type;
195194
if (m_pc_type == PreconditionerTypes::curl_curl_mlmg) {
196-
m_preCond = new CurlCurlMLMGPC<T,Ops>();
195+
m_preCond = std::make_unique<CurlCurlMLMGPC<T,Ops>>();
197196
} else {
198197
std::stringstream convergenceMsg;
199198
convergenceMsg << "JacobianFunctionMF::define(): " << m_pc_type <<

Source/NonlinearSolvers/Preconditioner.H

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -47,10 +47,16 @@ class Preconditioner
4747
*/
4848
virtual ~Preconditioner () = default;
4949

50+
// Default move and copy operations
51+
Preconditioner(const Preconditioner&) = default;
52+
Preconditioner& operator=(const Preconditioner&) = default;
53+
Preconditioner(Preconditioner&&) noexcept = default;
54+
Preconditioner& operator=(Preconditioner&&) noexcept = default;
55+
5056
/**
5157
* \brief Define the preconditioner
5258
*/
53-
virtual void Define (const T&, Ops* const) = 0;
59+
virtual void Define (const T&, Ops*) = 0;
5460

5561
/**
5662
* \brief Update the preconditioner
@@ -69,7 +75,7 @@ class Preconditioner
6975
/**
7076
* \brief Check if the nonlinear solver has been defined.
7177
*/
72-
virtual bool IsDefined () const = 0;
78+
[[nodiscard]] virtual bool IsDefined () const = 0;
7379

7480
/**
7581
* \brief Print parameters

0 commit comments

Comments
 (0)