From b96cd0083e794bb04b6895f1a3ae68247db01c25 Mon Sep 17 00:00:00 2001 From: Yaraslau Tamashevich Date: Fri, 19 Jul 2024 09:22:57 +0300 Subject: [PATCH] [clang-tidy] fix cppcoreguidelines-use-default-member-init check --- palace/fem/fespace.hpp | 4 ++-- palace/fem/libceed/integrator.hpp | 11 +++-------- palace/linalg/chebyshev.hpp | 4 ++-- palace/linalg/distrelaxation.cpp | 3 +-- palace/linalg/distrelaxation.hpp | 2 +- palace/linalg/iterative.hpp | 9 ++++----- palace/utils/iodata.cpp | 2 +- palace/utils/iodata.hpp | 6 +++--- 8 files changed, 17 insertions(+), 24 deletions(-) diff --git a/palace/fem/fespace.hpp b/palace/fem/fespace.hpp index ced53d63f..daa6b1c72 100644 --- a/palace/fem/fespace.hpp +++ b/palace/fem/fespace.hpp @@ -35,7 +35,7 @@ class FiniteElementSpace mutable ComplexVector tx, lx, ly; // Members for discrete interpolators from an auxiliary space to a primal space. - mutable const FiniteElementSpace *aux_fespace; + mutable const FiniteElementSpace *aux_fespace{nullptr}; mutable std::unique_ptr G; bool HasUniqueInterpRestriction(const mfem::FiniteElement &fe) const @@ -66,7 +66,7 @@ class FiniteElementSpace public: template FiniteElementSpace(Mesh &mesh, T &&...args) - : fespace(&mesh.Get(), std::forward(args)...), mesh(mesh), aux_fespace(nullptr) + : fespace(&mesh.Get(), std::forward(args)...), mesh(mesh) { ResetCeedObjects(); tx.UseDevice(true); diff --git a/palace/fem/libceed/integrator.hpp b/palace/fem/libceed/integrator.hpp index 6d5a5fe2f..ecf501ac7 100644 --- a/palace/fem/libceed/integrator.hpp +++ b/palace/fem/libceed/integrator.hpp @@ -26,23 +26,18 @@ enum EvalMode : unsigned int // NOLINT struct CeedQFunctionInfo { // QFunctions for operator construction and application. - CeedQFunctionUser apply_qf; + CeedQFunctionUser apply_qf{nullptr}; // Path and name of the QFunctions for operator construction and application. std::string apply_qf_path; // Evaluation modes for the test and trial basis. - unsigned int trial_ops, test_ops; + unsigned int trial_ops{0}, test_ops{0}; // Control whether or not to pre-assemble the quadrature data or compute it during // operator application in true matrix-free fashion. - bool assemble_q_data; + bool assemble_q_data{false}; - CeedQFunctionInfo() - : apply_qf(nullptr), apply_qf_path(""), trial_ops(0), test_ops(0), - assemble_q_data(false) - { - } }; // Helper function to get the geometry space dimension. diff --git a/palace/linalg/chebyshev.hpp b/palace/linalg/chebyshev.hpp index b43f6979d..3f817e67b 100644 --- a/palace/linalg/chebyshev.hpp +++ b/palace/linalg/chebyshev.hpp @@ -38,7 +38,7 @@ class ChebyshevSmoother : public Solver VecType dinv; // Maximum operator eigenvalue for Chebyshev polynomial smoothing. - double lambda_max, sf_max; + double lambda_max, sf_max; // NOLINT // Temporary vector for smoother application. mutable VecType d, r; @@ -102,7 +102,7 @@ class ChebyshevSmoother1stKind : public Solver // Parameters depending on maximum and minimum operator eigenvalue estimates for Chebyshev // polynomial smoothing. - double theta, delta, sf_max, sf_min; + double theta, delta, sf_max, sf_min; // NOLINT // Temporary vector for smoother application. mutable VecType d, r; diff --git a/palace/linalg/distrelaxation.cpp b/palace/linalg/distrelaxation.cpp index 172087cd3..e6eee4628 100644 --- a/palace/linalg/distrelaxation.cpp +++ b/palace/linalg/distrelaxation.cpp @@ -14,8 +14,7 @@ template DistRelaxationSmoother::DistRelaxationSmoother( MPI_Comm comm, const Operator &G, int smooth_it, int cheby_smooth_it, int cheby_order, double cheby_sf_max, double cheby_sf_min, bool cheby_4th_kind) - : Solver(), pc_it(smooth_it), G(&G), A(nullptr), A_G(nullptr), - dbc_tdof_list_G(nullptr) + : Solver(), pc_it(smooth_it), G(&G), A(nullptr), A_G(nullptr) { // Initialize smoothers. if (cheby_4th_kind) diff --git a/palace/linalg/distrelaxation.hpp b/palace/linalg/distrelaxation.hpp index a2a37d3b7..f97355560 100644 --- a/palace/linalg/distrelaxation.hpp +++ b/palace/linalg/distrelaxation.hpp @@ -40,7 +40,7 @@ class DistRelaxationSmoother : public Solver // System matrix and its projection Gáµ€AG (not owned). const OperType *A, *A_G; - const mfem::Array *dbc_tdof_list_G; + const mfem::Array *dbc_tdof_list_G{nullptr}; // Point smoother objects for each matrix. mutable std::unique_ptr> B; diff --git a/palace/linalg/iterative.hpp b/palace/linalg/iterative.hpp index 91ca0cee8..0db400c45 100644 --- a/palace/linalg/iterative.hpp +++ b/palace/linalg/iterative.hpp @@ -187,14 +187,14 @@ class GmresSolver : public IterativeSolver, GmresSolverBase using IterativeSolver::final_it; // Maximum subspace dimension for restarted GMRES. - mutable int max_dim; + mutable int max_dim{-1}; // Orthogonalization method for orthonormalizing a newly computed vector against a basis // at each iteration. - OrthogType orthog_type; + OrthogType orthog_type{OrthogType::MGS}; // Use left or right preconditioning. - PrecSide pc_side; + PrecSide pc_side{PrecSide::LEFT}; // Temporary workspace for solve. mutable std::vector V; @@ -209,8 +209,7 @@ class GmresSolver : public IterativeSolver, GmresSolverBase public: GmresSolver(MPI_Comm comm, int print) - : IterativeSolver(comm, print), max_dim(-1), orthog_type(OrthogType::MGS), - pc_side(PrecSide::LEFT) + : IterativeSolver(comm, print) { } diff --git a/palace/utils/iodata.cpp b/palace/utils/iodata.cpp index 4409abf69..98a5a2380 100644 --- a/palace/utils/iodata.cpp +++ b/palace/utils/iodata.cpp @@ -155,7 +155,7 @@ std::stringstream PreprocessFile(const char *filename) using json = nlohmann::json; -IoData::IoData(const char *filename, bool print) : Lc(1.0), tc(1.0), init(false) +IoData::IoData(const char *filename, bool print) { // Open configuration file and preprocess: strip whitespace, comments, and expand integer // ranges. diff --git a/palace/utils/iodata.hpp b/palace/utils/iodata.hpp index bbf7eb87c..21a22f940 100644 --- a/palace/utils/iodata.hpp +++ b/palace/utils/iodata.hpp @@ -32,8 +32,8 @@ class IoData private: // Characteristic reference length [m] and time [ns] for nondimensionalization. - double Lc, tc; - bool init; + double Lc{1.0}, tc{1.0}; + bool init{false}; // Check configuration file options and compatibility with requested problem type. void CheckConfiguration(); @@ -51,7 +51,7 @@ class IoData // Redimensionalize values for output. Outputs which depend on the fields assume a // characteristic reference magnetic field strength Hc such that Pc = 1 W, where Pc is the // characteristic reference power. - enum class ValueType : std::uint8_t + enum class ValueType : std::uint8_t { TIME, // [ns] FREQUENCY, // [GHz]