From 523e4b1d424923bb408ef83b3f195d13190d1efb Mon Sep 17 00:00:00 2001 From: Daniel Arndt Date: Mon, 9 Jan 2023 22:55:44 -0500 Subject: [PATCH] Fix a couple complaints --- examples/step-18/step-18.cc | 3 +- examples/step-68/step-68.cc | 2 +- examples/step-69/step-69.cc | 2 +- examples/step-70/step-70.cc | 4 +- .../fe/fe_tools_extrapolate.templates.h | 1 + .../lac/affine_constraints.templates.h | 1 + include/deal.II/lac/sparse_mic.h | 2 +- include/deal.II/lac/sparse_mic.templates.h | 9 ---- include/deal.II/matrix_free/constraint_info.h | 1 + .../matrix_free/matrix_free.templates.h | 1 + .../vector_tools_constraints.templates.h | 45 +++++++++---------- .../lac/petsc_parallel_block_sparse_matrix.cc | 4 +- source/lac/petsc_parallel_sparse_matrix.cc | 4 +- source/lac/petsc_precondition.cc | 2 +- source/lac/trilinos_sparsity_pattern.cc | 2 +- 15 files changed, 36 insertions(+), 47 deletions(-) diff --git a/examples/step-18/step-18.cc b/examples/step-18/step-18.cc index 3a1b65cac0..d10a7da413 100644 --- a/examples/step-18/step-18.cc +++ b/examples/step-18/step-18.cc @@ -1265,8 +1265,7 @@ namespace Step18 // times_and_names is declared static, so it will retain the entries // from the previous timesteps. static std::vector> times_and_names; - times_and_names.push_back( - std::pair(present_time, pvtu_filename)); + times_and_names.emplace_back(present_time, pvtu_filename); std::ofstream pvd_output("solution.pvd"); DataOutBase::write_pvd_record(pvd_output, times_and_names); } diff --git a/examples/step-68/step-68.cc b/examples/step-68/step-68.cc index d96ccb4032..7d0e031dbb 100644 --- a/examples/step-68/step-68.cc +++ b/examples/step-68/step-68.cc @@ -615,7 +615,7 @@ namespace Step68 Particles::DataOut particle_output; std::vector solution_names(dim, "velocity"); - solution_names.push_back("process_id"); + solution_names.emplace_back("process_id"); std::vector data_component_interpretation( diff --git a/examples/step-69/step-69.cc b/examples/step-69/step-69.cc index f3d6dc2783..e4a28b3c58 100644 --- a/examples/step-69/step-69.cc +++ b/examples/step-69/step-69.cc @@ -1639,7 +1639,7 @@ namespace Step69 /* We wire up the slot InitialValues::parse_parameters_callback to the ParameterAcceptor::parse_parameters_call_back signal: */ ParameterAcceptor::parse_parameters_call_back.connect( - std::bind(&InitialValues::parse_parameters_callback, this)); + [&]() { this->parse_parameters_callback(); }); initial_direction[0] = 1.; add_parameter("initial direction", diff --git a/examples/step-70/step-70.cc b/examples/step-70/step-70.cc index 879e5c1641..d2e6be3fc1 100644 --- a/examples/step-70/step-70.cc +++ b/examples/step-70/step-70.cc @@ -1721,7 +1721,7 @@ namespace Step70 mpi_communicator); static std::vector> times_and_names; - times_and_names.push_back(std::make_pair(time, filename)); + times_and_names.emplace_back(time, filename); std::ofstream ofile(par.output_directory + "/" + "solution.pvd"); DataOutBase::write_pvd_record(ofile, times_and_names); } @@ -1939,7 +1939,7 @@ int main(int argc, char *argv[]) StokesImmersedProblem<2, 3> problem(par); problem.run(); } - else if (prm_file.find("3") != std::string::npos) + else if (prm_file.find('3') != std::string::npos) { StokesImmersedProblemParameters<3> par; ParameterAcceptor::initialize(prm_file); diff --git a/include/deal.II/fe/fe_tools_extrapolate.templates.h b/include/deal.II/fe/fe_tools_extrapolate.templates.h index f7dec56da6..9bf3e705df 100644 --- a/include/deal.II/fe/fe_tools_extrapolate.templates.h +++ b/include/deal.II/fe/fe_tools_extrapolate.templates.h @@ -1128,6 +1128,7 @@ namespace FETools // the same process, so we have to only look at the unique set of // destinations: std::vector destinations; + destinations.reserve(cells_to_send.size()); for (const auto &cell : cells_to_send) destinations.emplace_back(cell.receiver); std::sort(destinations.begin(), destinations.end()); diff --git a/include/deal.II/lac/affine_constraints.templates.h b/include/deal.II/lac/affine_constraints.templates.h index 9b2c26cf73..e922a97d37 100644 --- a/include/deal.II/lac/affine_constraints.templates.h +++ b/include/deal.II/lac/affine_constraints.templates.h @@ -137,6 +137,7 @@ AffineConstraints::is_consistent_in_parallel( // We will send all locally active dofs that are not locally owned for // checking. Note that we allow constraints to differ on locally_relevant (and // not active) DoFs. + // NOLINTNEXTLINE(performance-unnecessary-copy-initialization) IndexSet non_owned = locally_active_dofs; non_owned.subtract_set(locally_owned_dofs[myid]); for (unsigned int owner = 0; owner < nproc; ++owner) diff --git a/include/deal.II/lac/sparse_mic.h b/include/deal.II/lac/sparse_mic.h index 8c3ba26fc7..35cf1500df 100644 --- a/include/deal.II/lac/sparse_mic.h +++ b/include/deal.II/lac/sparse_mic.h @@ -55,7 +55,7 @@ public: * Constructor. Does nothing, so you have to call @p decompose sometimes * afterwards. */ - SparseMIC(); + SparseMIC() = default; /** * Destructor. diff --git a/include/deal.II/lac/sparse_mic.templates.h b/include/deal.II/lac/sparse_mic.templates.h index 666fd27304..8fb32907f4 100644 --- a/include/deal.II/lac/sparse_mic.templates.h +++ b/include/deal.II/lac/sparse_mic.templates.h @@ -26,15 +26,6 @@ DEAL_II_NAMESPACE_OPEN -template -SparseMIC::SparseMIC() - : diag(0) - , inv_diag(0) - , inner_sums(0) -{} - - - template SparseMIC::~SparseMIC() { diff --git a/include/deal.II/matrix_free/constraint_info.h b/include/deal.II/matrix_free/constraint_info.h index 194afa3ebe..6bf150d581 100644 --- a/include/deal.II/matrix_free/constraint_info.h +++ b/include/deal.II/matrix_free/constraint_info.h @@ -182,6 +182,7 @@ namespace internal // ------------------------- inline functions -------------------------- + // NOLINTNEXTLINE(modernize-use-equals-default) template ConstraintValues::ConstraintValues() : constraints(FloatingPointComparator( diff --git a/include/deal.II/matrix_free/matrix_free.templates.h b/include/deal.II/matrix_free/matrix_free.templates.h index f5c1baf106..f2a8ce2f85 100644 --- a/include/deal.II/matrix_free/matrix_free.templates.h +++ b/include/deal.II/matrix_free/matrix_free.templates.h @@ -516,6 +516,7 @@ MatrixFree::internal_reinit( task_info.create_blocks_serial( dummy, 1, false, dummy, false, dummy, dummy, dummy2); + // NOLINTNEXTLINE(modernize-loop-convert) for (unsigned int i = 0; i < dof_info.size(); ++i) { Assert(dof_handler[i]->get_fe_collection().size() == 1, diff --git a/include/deal.II/numerics/vector_tools_constraints.templates.h b/include/deal.II/numerics/vector_tools_constraints.templates.h index 35f6e84b42..e1361b5195 100644 --- a/include/deal.II/numerics/vector_tools_constraints.templates.h +++ b/include/deal.II/numerics/vector_tools_constraints.templates.h @@ -520,8 +520,7 @@ namespace VectorTools hp::FEFaceValues & x_fe_face_values, const IndexSet & refinement_edge_indices, const unsigned int level, - std::map> - &dof_to_vector_dof) + std::map> &dof_to_vector_dof) { std::set::iterator b_id; for (const unsigned int face_no : cell->face_indices()) @@ -556,8 +555,8 @@ namespace VectorTools if (level == numbers::invalid_unsigned_int || !refinement_edge_indices.is_element(face_dofs[i])) { - local_vector_indices[0] = i; - const internal::FaceDoFInfo local_face_dof_info = { + local_vector_indices[0] = i; + const FaceDoFInfo local_face_dof_info = { {cell->active_fe_index(), face_no, i}}; for (unsigned int k = 0; k < fe.n_dofs_per_face(face_no); ++k) @@ -603,26 +602,23 @@ namespace VectorTools const IndexSet & refinement_edge_indices, const unsigned int level, std::multimap< - internal::VectorDoFTuple, + VectorDoFTuple, std::pair, typename DoFHandler::cell_iterator>> - &dof_to_normals_map, - std::map, Vector> - &dof_vector_to_b_values) + & dof_to_normals_map, + std::map, Vector> &dof_vector_to_b_values) { // mapping from (active_fe_index, face_no and local // dof index) to dim vector indices of the same // supporting point. - std::map> - dof_to_vector_dof; - internal::map_face_dof_to_vector_dof( - cell, - first_vector_component, - boundary_ids, - x_fe_face_values, - refinement_edge_indices, - level, - dof_to_vector_dof); + std::map> dof_to_vector_dof; + map_face_dof_to_vector_dof(cell, + first_vector_component, + boundary_ids, + x_fe_face_values, + refinement_edge_indices, + level, + dof_to_vector_dof); std::set::iterator b_id; @@ -660,7 +656,7 @@ namespace VectorTools if (level == numbers::invalid_unsigned_int || !refinement_edge_indices.is_element(face_dofs[i])) { - const internal::FaceDoFInfo face_dof_info = { + const FaceDoFInfo face_dof_info = { {cell->active_fe_index(), face_no, i}}; const auto it = dof_to_vector_dof.find(face_dof_info); Assert(it != dof_to_vector_dof.end(), ExcInternalError()); @@ -673,7 +669,7 @@ namespace VectorTools "Error: the finite element does not have enough components " "to define a normal direction.")); - internal::VectorDoFTuple vector_dofs; + VectorDoFTuple vector_dofs; for (unsigned int d = 0; d < dim; ++d) { vector_dofs.dof_indices[d] = @@ -845,11 +841,10 @@ namespace VectorTools // directions* we find). consequently, we also have to store which cell a // normal vector was computed on using DoFToNormalsMap = std::multimap< - internal::VectorDoFTuple, + VectorDoFTuple, std::pair, typename DoFHandler::cell_iterator>>; - std::map, Vector> - dof_vector_to_b_values; + std::map, Vector> dof_vector_to_b_values; DoFToNormalsMap dof_to_normals_map; @@ -861,7 +856,7 @@ namespace VectorTools for (const auto &cell : dof_handler.active_cell_iterators()) if (!cell->is_artificial()) { - internal::map_dofs_to_normal_vectors_and_normal_fluxes( + map_dofs_to_normal_vectors_and_normal_fluxes( cell, first_vector_component, boundary_ids, @@ -882,7 +877,7 @@ namespace VectorTools numbers::artificial_subdomain_id && cell->level_subdomain_id() != numbers::invalid_subdomain_id) { - internal::map_dofs_to_normal_vectors_and_normal_fluxes( + map_dofs_to_normal_vectors_and_normal_fluxes( cell, first_vector_component, boundary_ids, diff --git a/source/lac/petsc_parallel_block_sparse_matrix.cc b/source/lac/petsc_parallel_block_sparse_matrix.cc index a290cfb602..bee092b4f0 100644 --- a/source/lac/petsc_parallel_block_sparse_matrix.cc +++ b/source/lac/petsc_parallel_block_sparse_matrix.cc @@ -130,9 +130,9 @@ namespace PETScWrappers psub_objects[r * n + c] = this->sub_objects[r][c]->petsc_matrix(); ierr = MatCreateNest(get_mpi_communicator(), m, - NULL, + nullptr, n, - NULL, + nullptr, psub_objects.data(), &petsc_nest_matrix); AssertThrow(ierr == 0, ExcPETScError(ierr)); diff --git a/source/lac/petsc_parallel_sparse_matrix.cc b/source/lac/petsc_parallel_sparse_matrix.cc index 7bbd637180..8ecfb7e40f 100644 --- a/source/lac/petsc_parallel_sparse_matrix.cc +++ b/source/lac/petsc_parallel_sparse_matrix.cc @@ -508,7 +508,7 @@ namespace PETScWrappers ierr = ISDestroy(&is_glob_row); AssertThrow(ierr == 0, ExcPETScError(ierr)); ierr = - ISLocalToGlobalMappingViewFromOptions(l2gmap_row, NULL, "-view_map"); + ISLocalToGlobalMappingViewFromOptions(l2gmap_row, nullptr, "-view_map"); AssertThrow(ierr == 0, ExcPETScError(ierr)); // Create column index set @@ -524,7 +524,7 @@ namespace PETScWrappers ierr = ISDestroy(&is_glob_col); AssertThrow(ierr == 0, ExcPETScError(ierr)); ierr = - ISLocalToGlobalMappingViewFromOptions(l2gmap_col, NULL, "-view_map"); + ISLocalToGlobalMappingViewFromOptions(l2gmap_col, nullptr, "-view_map"); AssertThrow(ierr == 0, ExcPETScError(ierr)); // create the matrix with the IS constructor. diff --git a/source/lac/petsc_precondition.cc b/source/lac/petsc_precondition.cc index f79e7ac1db..a39d482ca4 100644 --- a/source/lac/petsc_precondition.cc +++ b/source/lac/petsc_precondition.cc @@ -1083,7 +1083,7 @@ namespace PETScWrappers else { set_option_value("-pc_bddc_corner_selection", "false"); - ierr = PCSetCoordinates(pc, 0, 0, NULL); + ierr = PCSetCoordinates(pc, 0, 0, nullptr); AssertThrow(ierr == 0, ExcPETScError(ierr)); } diff --git a/source/lac/trilinos_sparsity_pattern.cc b/source/lac/trilinos_sparsity_pattern.cc index b84c7bc78d..6e22d44d56 100644 --- a/source/lac/trilinos_sparsity_pattern.cc +++ b/source/lac/trilinos_sparsity_pattern.cc @@ -117,7 +117,7 @@ namespace TrilinosWrappers SparsityPattern::SparsityPattern(SparsityPattern &&other) noexcept - : SparsityPatternBase(other) + : SparsityPatternBase(std::move(other)) , column_space_map(std::move(other.column_space_map)) , graph(std::move(other.graph)) , nonlocal_graph(std::move(other.nonlocal_graph)) -- 2.39.5