From 35dcd8337a37dd7a22c1318c2517a3a096af0dd2 Mon Sep 17 00:00:00 2001 From: Reza Rastak Date: Sun, 19 Apr 2020 21:09:36 -0700 Subject: [PATCH] several improvements done based on clang-tidy 9.0 suggestions --- examples/step-69/step-69.cc | 10 ++++++---- include/deal.II/lac/qr.h | 6 +++--- include/deal.II/optimization/solver_bfgs.h | 2 +- source/base/parameter_handler.cc | 2 +- source/lac/trilinos_precondition_ml.cc | 4 ++-- source/opencascade/utilities.cc | 15 +++++---------- 6 files changed, 18 insertions(+), 21 deletions(-) diff --git a/examples/step-69/step-69.cc b/examples/step-69/step-69.cc index b61f6cf74c..6e43d71be6 100644 --- a/examples/step-69/step-69.cc +++ b/examples/step-69/step-69.cc @@ -945,12 +945,14 @@ namespace Step69 // primarily used to write the updated nodal values, stored as // Tensor<1,problem_dimension>, into the global objects. - template + template DEAL_II_ALWAYS_INLINE inline void scatter(std::array, k> &U, - const Tensor<1, ((identity::type)k)> & tensor, + const Tensor<1, k2> & tensor, const unsigned int i) { + static_assert(k == k2, + "The dimensions of the input arguments must agree"); for (unsigned int j = 0; j < k; ++j) U[j].local_element(i) = tensor[j]; } @@ -2530,8 +2532,8 @@ namespace Step69 namespace { void print_head(ConditionalOStream &pcout, - std::string header, - std::string secondary = "") + const std::string & header, + const std::string & secondary = "") { const auto header_size = header.size(); const auto padded_header = std::string((34 - header_size) / 2, ' ') + diff --git a/include/deal.II/lac/qr.h b/include/deal.II/lac/qr.h index 19adeed3d1..04ddcf67ea 100644 --- a/include/deal.II/lac/qr.h +++ b/include/deal.II/lac/qr.h @@ -46,7 +46,7 @@ class BaseQR /** * Number type for R matrix. */ - typedef typename VectorType::value_type Number; + using Number = typename VectorType::value_type; protected: /** @@ -243,7 +243,7 @@ public: /** * Number type for R matrix. */ - typedef typename VectorType::value_type Number; + using Number = typename VectorType::value_type; /** * Default constructor. @@ -352,7 +352,7 @@ public: /** * Number type for R matrix. */ - typedef typename VectorType::value_type Number; + using Number = typename VectorType::value_type; /** * Default constructor. diff --git a/include/deal.II/optimization/solver_bfgs.h b/include/deal.II/optimization/solver_bfgs.h index 5a72b7c87d..549dd51eeb 100644 --- a/include/deal.II/optimization/solver_bfgs.h +++ b/include/deal.II/optimization/solver_bfgs.h @@ -61,7 +61,7 @@ public: /** * Number type. */ - typedef typename VectorType::value_type Number; + using Number = typename VectorType::value_type; /** diff --git a/source/base/parameter_handler.cc b/source/base/parameter_handler.cc index 4fc7deca58..f072e83c22 100644 --- a/source/base/parameter_handler.cc +++ b/source/base/parameter_handler.cc @@ -2007,7 +2007,7 @@ ParameterHandler::get_entries_wrongly_not_set() const { std::set entries_wrongly_not_set; - for (auto it : entries_set_status) + for (const auto &it : entries_set_status) if (it.second.first == true && it.second.second == false) entries_wrongly_not_set.insert(it.first); diff --git a/source/lac/trilinos_precondition_ml.cc b/source/lac/trilinos_precondition_ml.cc index 38855b1346..435ea9f848 100644 --- a/source/lac/trilinos_precondition_ml.cc +++ b/source/lac/trilinos_precondition_ml.cc @@ -133,8 +133,8 @@ namespace TrilinosWrappers const Epetra_Map &domain_map = matrix.OperatorDomainMap(); const size_type constant_modes_dimension = constant_modes.size(); - ptr_distributed_constant_modes.reset(new Epetra_MultiVector( - domain_map, constant_modes_dimension > 0 ? constant_modes_dimension : 1)); + ptr_distributed_constant_modes = std_cxx14::make_unique( + domain_map, constant_modes_dimension > 0 ? constant_modes_dimension : 1); Assert(ptr_distributed_constant_modes, ExcNotInitialized()); Epetra_MultiVector &distributed_constant_modes = *ptr_distributed_constant_modes; diff --git a/source/opencascade/utilities.cc b/source/opencascade/utilities.cc index 4c5872724e..f2468ae15f 100644 --- a/source/opencascade/utilities.cc +++ b/source/opencascade/utilities.cc @@ -301,17 +301,12 @@ namespace OpenCASCADE std::vector edges; std::vector faces; OpenCASCADE::extract_geometrical_shapes(shape, faces, edges, vertices); - bool mesh_is_present = true; - for (unsigned int i = 0; i < faces.size(); ++i) - { + const bool mesh_is_present = + std::none_of(faces.begin(), faces.end(), [&Loc](const TopoDS_Face &face) { Handle(Poly_Triangulation) theTriangulation = - BRep_Tool::Triangulation(faces[i], Loc); - if (theTriangulation.IsNull()) - { - mesh_is_present = false; - break; - } - } + BRep_Tool::Triangulation(face, Loc); + return theTriangulation.IsNull(); + }); TopoDS_Shape shape_to_be_written = shape; if (!mesh_is_present) { -- 2.39.5