Skip to content

Commit

Permalink
clang-tidy recommendations
Browse files Browse the repository at this point in the history
  • Loading branch information
debog committed Sep 19, 2024
1 parent aff9965 commit 7680f9d
Show file tree
Hide file tree
Showing 5 changed files with 28 additions and 23 deletions.
4 changes: 2 additions & 2 deletions Source/FieldSolver/ImplicitSolvers/ImplicitSolver.H
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ public:

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

[[nodiscard]] const amrex::Geometry& GetGeometry (const int) const;
[[nodiscard]] const amrex::Geometry& GetGeometry (int) const;
[[nodiscard]] const amrex::Array<FieldBoundaryType,AMREX_SPACEDIM>& GetFieldBoundaryLo () const;
[[nodiscard]] const amrex::Array<FieldBoundaryType,AMREX_SPACEDIM>& GetFieldBoundaryHi () const;
[[nodiscard]] const amrex::Array<amrex::LinOpBCType,AMREX_SPACEDIM> GetLinOpBCLo () const;
Expand Down Expand Up @@ -160,7 +160,7 @@ protected:
/**
* \brief Convert from WarpX FieldBoundaryType to amrex::LinOpBCType
*/
amrex::Array<amrex::LinOpBCType,AMREX_SPACEDIM> convertFieldBCToLinOpBC ( const amrex::Array<FieldBoundaryType,AMREX_SPACEDIM>& ) const;
[[nodiscard]] amrex::Array<amrex::LinOpBCType,AMREX_SPACEDIM> convertFieldBCToLinOpBC ( const amrex::Array<FieldBoundaryType,AMREX_SPACEDIM>& ) const;

};

Expand Down
1 change: 1 addition & 0 deletions Source/FieldSolver/ImplicitSolvers/ImplicitSolver.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ const Array<LinOpBCType,AMREX_SPACEDIM> ImplicitSolver::GetLinOpBCHi () const
Array<LinOpBCType,AMREX_SPACEDIM> ImplicitSolver::convertFieldBCToLinOpBC (const Array<FieldBoundaryType,AMREX_SPACEDIM>& a_fbc) const
{
Array<LinOpBCType, AMREX_SPACEDIM> lbc;
for (auto bc : lbc) { bc = LinOpBCType::interior; }
for (int i = 0; i < AMREX_SPACEDIM; i++) {
if (a_fbc[i] == FieldBoundaryType::PML) {
WARPX_ABORT_WITH_MESSAGE("LinOpBCType not set for this FieldBoundaryType");
Expand Down
27 changes: 13 additions & 14 deletions Source/NonlinearSolvers/CurlCurlMLMGPC.H
Original file line number Diff line number Diff line change
Expand Up @@ -68,15 +68,21 @@ class CurlCurlMLMGPC : public Preconditioner<T,Ops>
*/
~CurlCurlMLMGPC () override = default;

// Default move and copy operations
CurlCurlMLMGPC(const CurlCurlMLMGPC&) = default;
CurlCurlMLMGPC& operator=(const CurlCurlMLMGPC&) = default;
CurlCurlMLMGPC(CurlCurlMLMGPC&&) noexcept = default;
CurlCurlMLMGPC& operator=(CurlCurlMLMGPC&&) noexcept = default;

/**
* \brief Define the preconditioner
*/
virtual void Define (const T&, Ops* const) override;
void Define (const T&, Ops*) override;

/**
* \brief Update the preconditioner
*/
virtual void Update (const T&) override;
void Update (const T&) override;

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

/**
* \brief Print parameters
*/
virtual void printParameters() const override;
void printParameters() const override;

/**
* \brief Check if the nonlinear solver has been defined.
Expand Down Expand Up @@ -189,7 +195,7 @@ void CurlCurlMLMGPC<T,Ops>::printParameters() const
template <class T, class Ops>
void CurlCurlMLMGPC<T,Ops>::readParameters()
{
amrex::ParmParse pp(PreconditionerTypes::curl_curl_mlmg);
const amrex::ParmParse pp(PreconditionerTypes::curl_curl_mlmg);
pp.query("verbose", m_verbose);
pp.query("bottom_verbose", m_bottom_verbose);
pp.query("max_iter", m_max_iter);
Expand All @@ -200,8 +206,6 @@ void CurlCurlMLMGPC<T,Ops>::readParameters()
pp.query("relative_tolerance", m_rtol);
pp.query("use_gmres", m_use_gmres);
pp.query("use_gmres_pc", m_use_gmres_pc);

return;
}

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

m_is_defined = true;
return;
}

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

// set the coefficients alpha and beta for curl-curl op
RT alpha = (m_ops->theta()*this->m_dt*PhysConst::c) * (m_ops->theta()*this->m_dt*PhysConst::c);
RT beta = RT(1.0);
const RT alpha = (m_ops->theta()*this->m_dt*PhysConst::c) * (m_ops->theta()*this->m_dt*PhysConst::c);
const RT beta = RT(1.0);

// currently not implemented in 1D
#ifndef WARPX_DIM_1D_Z
Expand All @@ -303,8 +306,6 @@ void CurlCurlMLMGPC<T,Ops>::Update (const T& a_U)
<< "alpha = " << alpha << ", "
<< "beta = " << beta << "\n";
}

return;
}

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

}

return;
}

#endif
9 changes: 4 additions & 5 deletions Source/NonlinearSolvers/JacobianFunctionMF.H
Original file line number Diff line number Diff line change
Expand Up @@ -158,7 +158,7 @@ class JacobianFunctionMF
}
}

void define( const T&, Ops* const, const std::string& );
void define( const T&, Ops*, const std::string& );

private:

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

T m_Z, m_Y0, m_R0, m_R;
Ops* m_ops;
Preconditioner<T,Ops>* m_preCond;
Ops* m_ops = nullptr;
std::unique_ptr<Preconditioner<T,Ops>> m_preCond = nullptr;
};

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

m_ops = a_ops;

m_preCond = nullptr;
m_usePreCond = (a_pc_type != "none");
if (m_usePreCond) {
m_pc_type = a_pc_type;
if (m_pc_type == PreconditionerTypes::curl_curl_mlmg) {
m_preCond = new CurlCurlMLMGPC<T,Ops>();
m_preCond = std::make_unique<CurlCurlMLMGPC<T,Ops>>();
} else {
std::stringstream convergenceMsg;
convergenceMsg << "JacobianFunctionMF::define(): " << m_pc_type <<
Expand Down
10 changes: 8 additions & 2 deletions Source/NonlinearSolvers/Preconditioner.H
Original file line number Diff line number Diff line change
Expand Up @@ -47,10 +47,16 @@ class Preconditioner
*/
virtual ~Preconditioner () = default;

// Default move and copy operations
Preconditioner(const Preconditioner&) = default;
Preconditioner& operator=(const Preconditioner&) = default;
Preconditioner(Preconditioner&&) noexcept = default;
Preconditioner& operator=(Preconditioner&&) noexcept = default;

/**
* \brief Define the preconditioner
*/
virtual void Define (const T&, Ops* const) = 0;
virtual void Define (const T&, Ops*) = 0;

/**
* \brief Update the preconditioner
Expand All @@ -69,7 +75,7 @@ class Preconditioner
/**
* \brief Check if the nonlinear solver has been defined.
*/
virtual bool IsDefined () const = 0;
[[nodiscard]] virtual bool IsDefined () const = 0;

/**
* \brief Print parameters
Expand Down

0 comments on commit 7680f9d

Please sign in to comment.