From 41bcc182bb7aca6d08bb38b6e16da4f418fca2a5 Mon Sep 17 00:00:00 2001 From: Arne Morten Kvarving Date: Fri, 16 Aug 2024 14:18:24 +0200 Subject: [PATCH] mark constructors explicit quells static analyzer warnings --- examples/known_answer_test.cpp | 2 +- opm/core/transport/implicit/ImplicitAssembly.hpp | 2 +- opm/core/transport/implicit/ImplicitTransport.hpp | 2 +- opm/core/transport/implicit/JacobianSystem.hpp | 2 +- opm/elasticity/applier.hpp | 2 +- opm/elasticity/asmhandler.hpp | 2 +- opm/elasticity/boundarygrid.hh | 6 +++--- opm/elasticity/elasticity.hpp | 2 +- opm/elasticity/meshcolorizer.hpp | 2 +- opm/elasticity/shapefunctions.hpp | 2 +- opm/porsol/common/BoundaryConditions.hpp | 6 +++--- opm/porsol/common/ImplicitTransportDefs.hpp | 4 ++-- opm/porsol/common/ReservoirPropertyFixedMobility.hpp | 2 +- opm/porsol/euler/EulerUpstreamResidual_impl.hpp | 4 ++-- opm/porsol/mimetic/IncompFlowSolverHybrid.hpp | 2 +- opm/porsol/mimetic/MimeticIPAnisoRelpermEvaluator.hpp | 2 +- opm/porsol/mimetic/MimeticIPEvaluator.hpp | 2 +- opm/upscaling/CornerpointChopper.hpp | 2 +- 18 files changed, 24 insertions(+), 24 deletions(-) diff --git a/examples/known_answer_test.cpp b/examples/known_answer_test.cpp index 6fbd277..c8f483e 100644 --- a/examples/known_answer_test.cpp +++ b/examples/known_answer_test.cpp @@ -99,7 +99,7 @@ namespace Opm class FunctionBoundaryConditions : public PeriodicConditionHandler { public: - FunctionBoundaryConditions(BoundaryFunc bfunc) + explicit FunctionBoundaryConditions(BoundaryFunc bfunc) : bfunc_(bfunc) { } diff --git a/opm/core/transport/implicit/ImplicitAssembly.hpp b/opm/core/transport/implicit/ImplicitAssembly.hpp index 705af10..b6facff 100644 --- a/opm/core/transport/implicit/ImplicitAssembly.hpp +++ b/opm/core/transport/implicit/ImplicitAssembly.hpp @@ -46,7 +46,7 @@ namespace Opm { enum { DofPerCell = Model::DofPerCell }; public: - ImplicitAssembly(Model& model) + explicit ImplicitAssembly(Model& model) : model_(model), nconn_(-1) , asm_buffer_() diff --git a/opm/core/transport/implicit/ImplicitTransport.hpp b/opm/core/transport/implicit/ImplicitTransport.hpp index b775575..fb2dd97 100644 --- a/opm/core/transport/implicit/ImplicitTransport.hpp +++ b/opm/core/transport/implicit/ImplicitTransport.hpp @@ -104,7 +104,7 @@ namespace Opm { template class VAsgn > class ImplicitTransport { public: - ImplicitTransport(Model& model) + explicit ImplicitTransport(Model& model) : model_(model), asm_ (model) {} diff --git a/opm/core/transport/implicit/JacobianSystem.hpp b/opm/core/transport/implicit/JacobianSystem.hpp index c472aa2..e60647b 100644 --- a/opm/core/transport/implicit/JacobianSystem.hpp +++ b/opm/core/transport/implicit/JacobianSystem.hpp @@ -126,7 +126,7 @@ namespace Opm { template class VectorSizeSetter { public: - VectorSizeSetter(BaseVec& v) : v_(v) {} + explicit VectorSizeSetter(BaseVec& v) : v_(v) {} void setSize(::std::size_t ndof, ::std::size_t m) { diff --git a/opm/elasticity/applier.hpp b/opm/elasticity/applier.hpp index 1b46ad0..db6f6f0 100644 --- a/opm/elasticity/applier.hpp +++ b/opm/elasticity/applier.hpp @@ -24,7 +24,7 @@ struct OperatorApplier { //! \brief Constructor //! \param[in] t The preconditioner or inverse operator - OperatorApplier(T& t) : A(t) + explicit OperatorApplier(T& t) : A(t) { } diff --git a/opm/elasticity/asmhandler.hpp b/opm/elasticity/asmhandler.hpp index b3cb055..0ef737b 100644 --- a/opm/elasticity/asmhandler.hpp +++ b/opm/elasticity/asmhandler.hpp @@ -45,7 +45,7 @@ class ASMHandler { //! \brief The default constructor //! \param[in] gv_ The grid the operator is assembled over - ASMHandler(const GridType& gv_) : gv(gv_), maxeqn(0) + explicit ASMHandler(const GridType& gv_) : gv(gv_), maxeqn(0) { } diff --git a/opm/elasticity/boundarygrid.hh b/opm/elasticity/boundarygrid.hh index 737fd70..fd74877 100644 --- a/opm/elasticity/boundarygrid.hh +++ b/opm/elasticity/boundarygrid.hh @@ -197,7 +197,7 @@ class BoundaryGrid { struct VertexLess { //! \brief Default constructor. //! \param[in] comp Direction to use for comparison. -1 to use index - VertexLess(int comp) : dir(comp) {} + explicit VertexLess(int comp) : dir(comp) {} //! \brief The comparison operator bool operator()(const Vertex& q1, const Vertex& q2) @@ -215,7 +215,7 @@ class BoundaryGrid { struct BoundedPredicate { //! \brief Default constructor //! \param[in] coord_ The coordinates to check - BoundedPredicate(const FaceCoord& coord_) : coord(coord_) {} + explicit BoundedPredicate(const FaceCoord& coord_) : coord(coord_) {} //! \brief The comparison operator bool operator()(const Quad& q) @@ -345,7 +345,7 @@ class HexGeometry<2, cdim, GridImp> //! \brief Construct integration element //! \param[in] q Quad describing element - HexGeometry(const BoundaryGrid::Quad& q) + explicit HexGeometry(const BoundaryGrid::Quad& q) { for (int i=0;i<4;++i) c[i] = q.v[i].c; diff --git a/opm/elasticity/elasticity.hpp b/opm/elasticity/elasticity.hpp index 1b4c6b0..182787a 100644 --- a/opm/elasticity/elasticity.hpp +++ b/opm/elasticity/elasticity.hpp @@ -29,7 +29,7 @@ class Elasticity { //! \brief Default constructor //! \param[in] gv_ The grid we are doing the calculations on - Elasticity(const GridType& gv_) : gv(gv_) {} + explicit Elasticity(const GridType& gv_) : gv(gv_) {} //! \brief Returns the B matrix in a quadrature point //! \param[in] point (Reference) coordinates of quadrature point diff --git a/opm/elasticity/meshcolorizer.hpp b/opm/elasticity/meshcolorizer.hpp index d7ffb9c..5370683 100644 --- a/opm/elasticity/meshcolorizer.hpp +++ b/opm/elasticity/meshcolorizer.hpp @@ -30,7 +30,7 @@ class MeshColorizer { public: //! \brief Default constructor //! \param[in] grid_ The grid to colorize - MeshColorizer(const GridType& grid_) : + explicit MeshColorizer(const GridType& grid_) : grid(grid_) { calcGroups(); diff --git a/opm/elasticity/shapefunctions.hpp b/opm/elasticity/shapefunctions.hpp index f7157d0..a09444b 100644 --- a/opm/elasticity/shapefunctions.hpp +++ b/opm/elasticity/shapefunctions.hpp @@ -150,7 +150,7 @@ class TensorProductFunction //! \brief Construct a tensor-product function //! \param[in] funcs_ The functions - TensorProductFunction(const Dune::FieldVector& funcs_) + explicit TensorProductFunction(const Dune::FieldVector& funcs_) : funcs(funcs_) {} //! \brief Evaluate the function diff --git a/opm/porsol/common/BoundaryConditions.hpp b/opm/porsol/common/BoundaryConditions.hpp index 93baa7f..e14cb37 100644 --- a/opm/porsol/common/BoundaryConditions.hpp +++ b/opm/porsol/common/BoundaryConditions.hpp @@ -248,7 +248,7 @@ namespace Opm { } - PeriodicConditionHandler(int num_different_boundary_ids) + explicit PeriodicConditionHandler(int num_different_boundary_ids) : periodic_partner_bid_(num_different_boundary_ids, 0), canonical_bid_(num_different_boundary_ids, 0) { @@ -333,7 +333,7 @@ namespace Opm { public: DummyVec() {} - DummyVec(int) {} + explicit DummyVec(int) {} void resize(int) {} void clear() {} }; @@ -356,7 +356,7 @@ namespace Opm { } - BasicBoundaryConditions(int num_different_boundary_ids) + explicit BasicBoundaryConditions(int num_different_boundary_ids) : PeriodicConditionHandler(num_different_boundary_ids), FlowConds(num_different_boundary_ids), SatConds(num_different_boundary_ids), diff --git a/opm/porsol/common/ImplicitTransportDefs.hpp b/opm/porsol/common/ImplicitTransportDefs.hpp index a7689b3..42cfc2c 100644 --- a/opm/porsol/common/ImplicitTransportDefs.hpp +++ b/opm/porsol/common/ImplicitTransportDefs.hpp @@ -51,7 +51,7 @@ namespace Opm { template class ReservoirState { public: - ReservoirState(const UnstructuredGrid* g) + explicit ReservoirState(const UnstructuredGrid* g) : press_ (g->number_of_cells), fpress_(g->number_of_faces), flux_ (g->number_of_faces), @@ -114,7 +114,7 @@ namespace Opm { class TwophaseFluidWrapper { public: - TwophaseFluidWrapper(const Opm::ReservoirPropertyCapillary<3>& r) + explicit TwophaseFluidWrapper(const Opm::ReservoirPropertyCapillary<3>& r) : r_(r) {} diff --git a/opm/porsol/common/ReservoirPropertyFixedMobility.hpp b/opm/porsol/common/ReservoirPropertyFixedMobility.hpp index 886df1a..62c9342 100644 --- a/opm/porsol/common/ReservoirPropertyFixedMobility.hpp +++ b/opm/porsol/common/ReservoirPropertyFixedMobility.hpp @@ -45,7 +45,7 @@ namespace Opm { template class ReservoirPropertyFixedMobility { public: - ReservoirPropertyFixedMobility(const std::vector& mobs) + explicit ReservoirPropertyFixedMobility(const std::vector& mobs) : mobs_(mobs) { } diff --git a/opm/porsol/euler/EulerUpstreamResidual_impl.hpp b/opm/porsol/euler/EulerUpstreamResidual_impl.hpp index 5aed240..3330cc3 100644 --- a/opm/porsol/euler/EulerUpstreamResidual_impl.hpp +++ b/opm/porsol/euler/EulerUpstreamResidual_impl.hpp @@ -289,7 +289,7 @@ namespace Opm struct IndirectRange { typedef Iter Iterator; - IndirectRange(const std::vector& iters) + explicit IndirectRange(const std::vector& iters) : iters_(iters), beg_(0), end_(iters_.size() - 1) { assert(iters_.size() >= 2); @@ -329,7 +329,7 @@ namespace Opm template struct UpdateLoopBody { - UpdateLoopBody(const Updater& upd) + explicit UpdateLoopBody(const Updater& upd) : updater(upd) { } diff --git a/opm/porsol/mimetic/IncompFlowSolverHybrid.hpp b/opm/porsol/mimetic/IncompFlowSolverHybrid.hpp index 911c949..17e26f0 100644 --- a/opm/porsol/mimetic/IncompFlowSolverHybrid.hpp +++ b/opm/porsol/mimetic/IncompFlowSolverHybrid.hpp @@ -699,7 +699,7 @@ namespace Opm { class FaceFluxes { public: - FaceFluxes(int sz) + explicit FaceFluxes(int sz) : fluxes_(sz, 0.0), visited_(sz, 0), max_modification_(0.0) { } diff --git a/opm/porsol/mimetic/MimeticIPAnisoRelpermEvaluator.hpp b/opm/porsol/mimetic/MimeticIPAnisoRelpermEvaluator.hpp index 1141513..cd697c1 100644 --- a/opm/porsol/mimetic/MimeticIPAnisoRelpermEvaluator.hpp +++ b/opm/porsol/mimetic/MimeticIPAnisoRelpermEvaluator.hpp @@ -111,7 +111,7 @@ namespace Opm { /// in the model. Used to set the size of certain internal /// working std::arrays. A cell with @f$n_f@f$ faces results in /// an inner product matrix of size @f$n_f \times n_f@f$. - MimeticIPAnisoRelpermEvaluator(const int max_nf) + explicit MimeticIPAnisoRelpermEvaluator(const int max_nf) : max_nf_ (max_nf ), fa_ (max_nf * max_nf), t1_ (max_nf * dim ), diff --git a/opm/porsol/mimetic/MimeticIPEvaluator.hpp b/opm/porsol/mimetic/MimeticIPEvaluator.hpp index 37e6c55..cbe3d11 100644 --- a/opm/porsol/mimetic/MimeticIPEvaluator.hpp +++ b/opm/porsol/mimetic/MimeticIPEvaluator.hpp @@ -115,7 +115,7 @@ namespace Opm { /// in the model. Used to set the size of certain internal /// working std::arrays. A cell with @f$n_f@f$ faces results in /// an inner product matrix of size @f$n_f \times n_f@f$. - MimeticIPEvaluator(const int max_nf) + explicit MimeticIPEvaluator(const int max_nf) : max_nf_(max_nf ), fa_ (max_nf * max_nf), t1_ (max_nf * dim ), diff --git a/opm/upscaling/CornerpointChopper.hpp b/opm/upscaling/CornerpointChopper.hpp index 4b7f932..a080638 100644 --- a/opm/upscaling/CornerpointChopper.hpp +++ b/opm/upscaling/CornerpointChopper.hpp @@ -39,7 +39,7 @@ namespace Opm class CornerPointChopper { public: - CornerPointChopper(const std::string& file) : + explicit CornerPointChopper(const std::string& file) : parser_(Parser{}), deck_(parser_.parseFile(file)), metricUnits_(Opm::UnitSystem::newMETRIC())