From b2180600184d1d32dc825e5dee66bff296435aaf Mon Sep 17 00:00:00 2001 From: Daniel Arndt Date: Wed, 21 Jun 2023 16:26:43 -0400 Subject: [PATCH] Fix clang-tidy complaints --- examples/step-36/step-36.cc | 8 ++++---- examples/step-71/step-71.cc | 6 +++--- .../sd/symengine_number_visitor_internal.h | 6 +++--- .../differentiation/sd/symengine_optimizer.h | 2 +- .../sd/symengine_number_types.cc | 2 +- .../differentiation/sd/symengine_utilities.cc | 4 ++-- source/opencascade/manifold_lib.cc | 18 +++++++++--------- source/sundials/ida.cc | 5 ++--- 8 files changed, 25 insertions(+), 26 deletions(-) diff --git a/examples/step-36/step-36.cc b/examples/step-36/step-36.cc index c72cd33c85..5032992fb5 100644 --- a/examples/step-36/step-36.cc +++ b/examples/step-36/step-36.cc @@ -211,8 +211,8 @@ namespace Step36 IndexSet eigenfunction_index_set = dof_handler.locally_owned_dofs(); eigenfunctions.resize( parameters.get_integer("Number of eigenvalues/eigenfunctions")); - for (unsigned int i = 0; i < eigenfunctions.size(); ++i) - eigenfunctions[i].reinit(eigenfunction_index_set, MPI_COMM_WORLD); + for (auto &eigenfunction : eigenfunctions) + eigenfunction.reinit(eigenfunction_index_set, MPI_COMM_WORLD); eigenvalues.resize(eigenfunctions.size()); } @@ -384,8 +384,8 @@ namespace Step36 // does not necessarily have to be attained at a node, and so // $\max_{\mathbf x}\phi_i(\mathbf x)\ge\max_j (\Phi_i)_j$ (although the // equality is usually nearly true). - for (unsigned int i = 0; i < eigenfunctions.size(); ++i) - eigenfunctions[i] /= eigenfunctions[i].linfty_norm(); + for (auto &eigenfunction : eigenfunctions) + eigenfunction /= eigenfunction.linfty_norm(); // Finally return the number of iterations it took to converge: return solver_control.last_step(); diff --git a/examples/step-71/step-71.cc b/examples/step-71/step-71.cc index da0f91306c..9c8310e330 100644 --- a/examples/step-71/step-71.cc +++ b/examples/step-71/step-71.cc @@ -3799,9 +3799,9 @@ namespace Step71 Coupled_Magnetomechanical_Constitutive_Law_Base &material_hand_calculated, Coupled_Magnetomechanical_Constitutive_Law_Base - & material_assisted_computation, - TimerOutput & timer, - const std::string filename) + & material_assisted_computation, + TimerOutput & timer, + const std::string &filename) { // We can take the hand-implemented constitutive law and compare the // results that we attain with it to those that we get using AD or SD. diff --git a/include/deal.II/differentiation/sd/symengine_number_visitor_internal.h b/include/deal.II/differentiation/sd/symengine_number_visitor_internal.h index 232a341cd1..4515c78cda 100644 --- a/include/deal.II/differentiation/sd/symengine_number_visitor_internal.h +++ b/include/deal.II/differentiation/sd/symengine_number_visitor_internal.h @@ -664,12 +664,12 @@ namespace Differentiation // ... followed by any intermediate evaluations due to the application // of CSE. These are fed directly back into the substitution map... - for (unsigned i = 0; i < intermediate_symbols_exprs.size(); ++i) + for (const auto &expression : intermediate_symbols_exprs) { const SymEngine::RCP &cse_symbol = - intermediate_symbols_exprs[i].first; + expression.first; const SymEngine::RCP &cse_expr = - intermediate_symbols_exprs[i].second; + expression.second; Assert(substitution_value_map.find(cse_symbol) == substitution_value_map.end(), ExcMessage( diff --git a/include/deal.II/differentiation/sd/symengine_optimizer.h b/include/deal.II/differentiation/sd/symengine_optimizer.h index 424bf78ec1..8bd56698d9 100644 --- a/include/deal.II/differentiation/sd/symengine_optimizer.h +++ b/include/deal.II/differentiation/sd/symengine_optimizer.h @@ -1484,7 +1484,7 @@ namespace Differentiation /** * Move constructor. */ - BatchOptimizer(BatchOptimizer &&) = default; + BatchOptimizer(BatchOptimizer &&) noexcept = default; /** * Destructor. diff --git a/source/differentiation/sd/symengine_number_types.cc b/source/differentiation/sd/symengine_number_types.cc index ce828f1d87..635f4521ff 100644 --- a/source/differentiation/sd/symengine_number_types.cc +++ b/source/differentiation/sd/symengine_number_types.cc @@ -104,7 +104,7 @@ namespace Differentiation {expression_otherwise.get_RCP(), SE::boolTrue}); // Initialize - expression = SE::piecewise(std::move(piecewise_function)); + expression = SE::piecewise(piecewise_function); } diff --git a/source/differentiation/sd/symengine_utilities.cc b/source/differentiation/sd/symengine_utilities.cc index 182520a8b1..b58dc67d3a 100644 --- a/source/differentiation/sd/symengine_utilities.cc +++ b/source/differentiation/sd/symengine_utilities.cc @@ -103,8 +103,8 @@ namespace Differentiation std::vector> symb_val_vec; symb_val_vec.reserve(symbol_value_vector.size()); for (const auto &entry : symbol_value_vector) - symb_val_vec.push_back(std::make_pair(SD::Expression(entry.first), - SD::Expression(entry.second))); + symb_val_vec.emplace_back(SD::Expression(entry.first), + SD::Expression(entry.second)); return symb_val_vec; } diff --git a/source/opencascade/manifold_lib.cc b/source/opencascade/manifold_lib.cc index c2640d373d..c3baa00875 100644 --- a/source/opencascade/manifold_lib.cc +++ b/source/opencascade/manifold_lib.cc @@ -236,13 +236,11 @@ namespace OpenCASCADE TopoDS_Shape out_shape; Tensor<1, spacedim> average_normal; # ifdef DEBUG - for (unsigned int i = 0; i < surrounding_points.size(); ++i) + for (const auto &point : surrounding_points) { - Assert(closest_point(sh, surrounding_points[i], tolerance) - .distance(surrounding_points[i]) < - std::max(tolerance * surrounding_points[i].norm(), - tolerance), - ExcPointNotOnManifold(surrounding_points[i])); + Assert(closest_point(sh, point, tolerance).distance(point) < + std::max(tolerance * point.norm(), tolerance), + ExcPointNotOnManifold(point)); } # endif @@ -250,11 +248,13 @@ namespace OpenCASCADE { case 2: { - for (unsigned int i = 0; i < surrounding_points.size(); ++i) + for (const auto &point : surrounding_points) { std::tuple, Tensor<1, 3>, double, double> - p_and_diff_forms = closest_point_and_differential_forms( - sh, surrounding_points[i], tolerance); + p_and_diff_forms = + closest_point_and_differential_forms(sh, + point, + tolerance); average_normal += std::get<1>(p_and_diff_forms); } diff --git a/source/sundials/ida.cc b/source/sundials/ida.cc index f05c6bdbdb..98b04474ca 100644 --- a/source/sundials/ida.cc +++ b/source/sundials/ida.cc @@ -278,9 +278,8 @@ namespace SUNDIALS { VectorType diff_comp_vector(solution); diff_comp_vector = 0.0; - auto dc = differential_components(); - for (auto i = dc.begin(); i != dc.end(); ++i) - diff_comp_vector[*i] = 1.0; + for (const auto &component : differential_components()) + diff_comp_vector[component] = 1.0; diff_comp_vector.compress(VectorOperation::insert); const auto diff_id = internal::make_nvector_view(diff_comp_vector -- 2.39.5