From aa91f7189d7c9900aea627c8d8b8318fbb57148f Mon Sep 17 00:00:00 2001 From: Martin Kronbichler Date: Thu, 5 May 2022 21:29:55 +0200 Subject: [PATCH] Use simpler initialization of std::set --- examples/step-31/step-31.cc | 3 +-- examples/step-37/step-37.cc | 3 +-- examples/step-38/doc/results.dox | 3 +-- examples/step-38/step-38.cc | 3 +-- examples/step-56/step-56.cc | 3 +-- tests/matrix_free/copy_feevaluation.cc | 3 +-- tests/matrix_free/matrix_vector_stokes_flux.cc | 4 +--- tests/matrix_free/matrix_vector_stokes_noflux.cc | 4 +--- tests/matrix_free/matrix_vector_stokes_noflux2.cc | 4 +--- tests/matrix_free/matrix_vector_stokes_notempl.cc | 4 +--- tests/matrix_free/matrix_vector_stokes_onedof.cc | 4 +--- tests/matrix_free/parallel_multigrid.cc | 3 +-- tests/matrix_free/parallel_multigrid_fullydistributed.cc | 3 +-- tests/matrix_free/parallel_multigrid_interleave.cc | 9 ++++----- .../parallel_multigrid_interleave_renumber.cc | 9 ++++----- tests/matrix_free/parallel_multigrid_mf.cc | 3 +-- tests/matrix_free/step-37-inhomogeneous-1.cc | 3 +-- tests/matrix_free/stokes_computation.cc | 3 +-- tests/performance/timing_step_37.cc | 6 ++---- 19 files changed, 26 insertions(+), 51 deletions(-) diff --git a/examples/step-31/step-31.cc b/examples/step-31/step-31.cc index 27474bfa4e..2bd9d0a237 100644 --- a/examples/step-31/step-31.cc +++ b/examples/step-31/step-31.cc @@ -847,8 +847,7 @@ namespace Step31 stokes_constraints.clear(); DoFTools::make_hanging_node_constraints(stokes_dof_handler, stokes_constraints); - std::set no_normal_flux_boundaries; - no_normal_flux_boundaries.insert(0); + const std::set no_normal_flux_boundaries = {0}; VectorTools::compute_no_normal_flux_constraints(stokes_dof_handler, 0, no_normal_flux_boundaries, diff --git a/examples/step-37/step-37.cc b/examples/step-37/step-37.cc index ae500f3b7f..1669ff13ca 100644 --- a/examples/step-37/step-37.cc +++ b/examples/step-37/step-37.cc @@ -841,8 +841,7 @@ namespace Step37 const unsigned int nlevels = triangulation.n_global_levels(); mg_matrices.resize(0, nlevels - 1); - std::set dirichlet_boundary; - dirichlet_boundary.insert(0); + const std::set dirichlet_boundary = {0}; mg_constrained_dofs.initialize(dof_handler); mg_constrained_dofs.make_zero_boundary_constraints(dof_handler, dirichlet_boundary); diff --git a/examples/step-38/doc/results.dox b/examples/step-38/doc/results.dox index 169a4ed849..8ba06eb3ab 100644 --- a/examples/step-38/doc/results.dox +++ b/examples/step-38/doc/results.dox @@ -117,8 +117,7 @@ void LaplaceBeltrami::make_grid_and_dofs() volume_mesh.refine_global(4); - std::set boundary_ids; - boundary_ids.insert(0); + const std::set boundary_ids = {0}; GridGenerator::extract_boundary_mesh(volume_mesh, triangulation, boundary_ids); diff --git a/examples/step-38/step-38.cc b/examples/step-38/step-38.cc index d00baa161c..26503a9325 100644 --- a/examples/step-38/step-38.cc +++ b/examples/step-38/step-38.cc @@ -306,8 +306,7 @@ namespace Step38 Triangulation volume_mesh; GridGenerator::half_hyper_ball(volume_mesh); - std::set boundary_ids; - boundary_ids.insert(0); + const std::set boundary_ids = {0}; GridGenerator::extract_boundary_mesh(volume_mesh, triangulation, diff --git a/examples/step-56/step-56.cc b/examples/step-56/step-56.cc index 09509709bd..625b035d6b 100644 --- a/examples/step-56/step-56.cc +++ b/examples/step-56/step-56.cc @@ -525,8 +525,7 @@ namespace Step56 // sparsity patterns and matrices for each level. The resize() // function of MGLevelObject will destroy all existing contained // objects. - std::set zero_boundary_ids; - zero_boundary_ids.insert(0); + const std::set zero_boundary_ids = {0}; mg_constrained_dofs.clear(); mg_constrained_dofs.initialize(velocity_dof_handler); diff --git a/tests/matrix_free/copy_feevaluation.cc b/tests/matrix_free/copy_feevaluation.cc index f1805a2abc..42bbc64ab3 100644 --- a/tests/matrix_free/copy_feevaluation.cc +++ b/tests/matrix_free/copy_feevaluation.cc @@ -172,8 +172,7 @@ test() stokes_sub_blocks[dim] = 1; DoFRenumbering::component_wise(dof_handler, stokes_sub_blocks); - std::set no_normal_flux_boundaries; - no_normal_flux_boundaries.insert(1); + std::set no_normal_flux_boundaries = {1}; DoFTools::make_hanging_node_constraints(dof_handler, constraints); VectorTools::compute_no_normal_flux_constraints( dof_handler, 0, no_normal_flux_boundaries, constraints, mapping); diff --git a/tests/matrix_free/matrix_vector_stokes_flux.cc b/tests/matrix_free/matrix_vector_stokes_flux.cc index f340e19997..aa4b30922e 100644 --- a/tests/matrix_free/matrix_vector_stokes_flux.cc +++ b/tests/matrix_free/matrix_vector_stokes_flux.cc @@ -158,9 +158,7 @@ test() stokes_sub_blocks[dim] = 1; DoFRenumbering::component_wise(dof_handler, stokes_sub_blocks); - std::set no_normal_flux_boundaries; - no_normal_flux_boundaries.insert(0); - no_normal_flux_boundaries.insert(1); + const std::set no_normal_flux_boundaries = {0, 1}; DoFTools::make_hanging_node_constraints(dof_handler, constraints); VectorTools::compute_normal_flux_constraints(dof_handler, 0, diff --git a/tests/matrix_free/matrix_vector_stokes_noflux.cc b/tests/matrix_free/matrix_vector_stokes_noflux.cc index 0478bedac3..b58e0404e0 100644 --- a/tests/matrix_free/matrix_vector_stokes_noflux.cc +++ b/tests/matrix_free/matrix_vector_stokes_noflux.cc @@ -166,9 +166,7 @@ test() stokes_sub_blocks[dim] = 1; DoFRenumbering::component_wise(dof_handler, stokes_sub_blocks); - std::set no_normal_flux_boundaries; - no_normal_flux_boundaries.insert(0); - no_normal_flux_boundaries.insert(1); + const std::set no_normal_flux_boundaries = {0, 1}; DoFTools::make_hanging_node_constraints(dof_handler, constraints); VectorTools::compute_no_normal_flux_constraints( dof_handler, 0, no_normal_flux_boundaries, constraints, mapping); diff --git a/tests/matrix_free/matrix_vector_stokes_noflux2.cc b/tests/matrix_free/matrix_vector_stokes_noflux2.cc index c3d2ea5d69..103b272f6e 100644 --- a/tests/matrix_free/matrix_vector_stokes_noflux2.cc +++ b/tests/matrix_free/matrix_vector_stokes_noflux2.cc @@ -160,9 +160,7 @@ test() stokes_sub_blocks[dim] = 1; DoFRenumbering::component_wise(dof_handler, stokes_sub_blocks); - std::set no_normal_flux_boundaries; - no_normal_flux_boundaries.insert(0); - no_normal_flux_boundaries.insert(1); + const std::set no_normal_flux_boundaries = {0, 1}; DoFTools::make_hanging_node_constraints(dof_handler, constraints); VectorTools::compute_no_normal_flux_constraints( dof_handler, 0, no_normal_flux_boundaries, constraints, mapping); diff --git a/tests/matrix_free/matrix_vector_stokes_notempl.cc b/tests/matrix_free/matrix_vector_stokes_notempl.cc index 0ff0cbd884..2b5e257a59 100644 --- a/tests/matrix_free/matrix_vector_stokes_notempl.cc +++ b/tests/matrix_free/matrix_vector_stokes_notempl.cc @@ -162,9 +162,7 @@ test(const unsigned int fe_degree) stokes_sub_blocks[dim] = 1; DoFRenumbering::component_wise(dof_handler, stokes_sub_blocks); - std::set no_normal_flux_boundaries; - no_normal_flux_boundaries.insert(0); - no_normal_flux_boundaries.insert(1); + const std::set no_normal_flux_boundaries = {0, 1}; DoFTools::make_hanging_node_constraints(dof_handler, constraints); VectorTools::compute_no_normal_flux_constraints( dof_handler, 0, no_normal_flux_boundaries, constraints, mapping); diff --git a/tests/matrix_free/matrix_vector_stokes_onedof.cc b/tests/matrix_free/matrix_vector_stokes_onedof.cc index 1730e732d2..27f072b9ef 100644 --- a/tests/matrix_free/matrix_vector_stokes_onedof.cc +++ b/tests/matrix_free/matrix_vector_stokes_onedof.cc @@ -160,9 +160,7 @@ test(const FESystem &fe) dof_handler.distribute_dofs(fe); - std::set no_normal_flux_boundaries; - no_normal_flux_boundaries.insert(0); - no_normal_flux_boundaries.insert(1); + const std::set no_normal_flux_boundaries = {0, 1}; DoFTools::make_hanging_node_constraints(dof_handler, constraints); if (fe.dofs_per_vertex > 0) VectorTools::compute_no_normal_flux_constraints( diff --git a/tests/matrix_free/parallel_multigrid.cc b/tests/matrix_free/parallel_multigrid.cc index f0ab3f8a76..ebf825b9b7 100644 --- a/tests/matrix_free/parallel_multigrid.cc +++ b/tests/matrix_free/parallel_multigrid.cc @@ -351,8 +351,7 @@ do_test(const DoFHandler &dof) MappingQ mapping(fe_degree + 1); LaplaceOperator fine_matrix; - std::set dirichlet_boundaries; - dirichlet_boundaries.insert(0); + const std::set dirichlet_boundaries = {0}; fine_matrix.initialize(mapping, dof, dirichlet_boundaries); LinearAlgebra::distributed::Vector in, sol; diff --git a/tests/matrix_free/parallel_multigrid_fullydistributed.cc b/tests/matrix_free/parallel_multigrid_fullydistributed.cc index 9a48bf2ff2..dfe028a7b2 100644 --- a/tests/matrix_free/parallel_multigrid_fullydistributed.cc +++ b/tests/matrix_free/parallel_multigrid_fullydistributed.cc @@ -354,8 +354,7 @@ do_test(const DoFHandler &dof) MappingQ mapping(fe_degree + 1); LaplaceOperator fine_matrix; - std::set dirichlet_boundaries; - dirichlet_boundaries.insert(0); + const std::set dirichlet_boundaries = {0}; fine_matrix.initialize(mapping, dof, dirichlet_boundaries); LinearAlgebra::distributed::Vector in, sol; diff --git a/tests/matrix_free/parallel_multigrid_interleave.cc b/tests/matrix_free/parallel_multigrid_interleave.cc index 20b59fc2bc..37fd4f7d75 100644 --- a/tests/matrix_free/parallel_multigrid_interleave.cc +++ b/tests/matrix_free/parallel_multigrid_interleave.cc @@ -342,11 +342,10 @@ do_test(const DoFHandler &dof) deallog << std::endl; deallog << "Number of degrees of freedom: " << dof.n_dofs() << std::endl; - const unsigned int fe_degree = dof.get_fe().degree; - MappingQ mapping(fe_degree + 1); - LaplaceOperator fine_matrix; - std::set dirichlet_boundaries; - dirichlet_boundaries.insert(0); + const unsigned int fe_degree = dof.get_fe().degree; + MappingQ mapping(fe_degree + 1); + LaplaceOperator fine_matrix; + const std::set dirichlet_boundaries = {0}; fine_matrix.initialize(mapping, dof, dirichlet_boundaries); LinearAlgebra::distributed::Vector in, sol; diff --git a/tests/matrix_free/parallel_multigrid_interleave_renumber.cc b/tests/matrix_free/parallel_multigrid_interleave_renumber.cc index 24d882e517..507c0ed388 100644 --- a/tests/matrix_free/parallel_multigrid_interleave_renumber.cc +++ b/tests/matrix_free/parallel_multigrid_interleave_renumber.cc @@ -384,11 +384,10 @@ do_test(DoFHandler &dof) deallog << std::endl; deallog << "Number of degrees of freedom: " << dof.n_dofs() << std::endl; - const unsigned int fe_degree = dof.get_fe().degree; - MappingQ mapping(fe_degree + 1); - LaplaceOperator fine_matrix; - std::set dirichlet_boundaries; - dirichlet_boundaries.insert(0); + const unsigned int fe_degree = dof.get_fe().degree; + MappingQ mapping(fe_degree + 1); + LaplaceOperator fine_matrix; + const std::set dirichlet_boundaries = {0}; fine_matrix.initialize(mapping, dof, dirichlet_boundaries); LinearAlgebra::distributed::Vector in, sol; diff --git a/tests/matrix_free/parallel_multigrid_mf.cc b/tests/matrix_free/parallel_multigrid_mf.cc index 60467a8c65..0b76aa679f 100644 --- a/tests/matrix_free/parallel_multigrid_mf.cc +++ b/tests/matrix_free/parallel_multigrid_mf.cc @@ -349,8 +349,7 @@ do_test(const DoFHandler &dof) MappingQ mapping(fe_degree + 1); LaplaceOperator fine_matrix; - std::set dirichlet_boundaries; - dirichlet_boundaries.insert(0); + const std::set dirichlet_boundaries = {0}; fine_matrix.initialize(mapping, dof, dirichlet_boundaries); LinearAlgebra::distributed::Vector in, sol; diff --git a/tests/matrix_free/step-37-inhomogeneous-1.cc b/tests/matrix_free/step-37-inhomogeneous-1.cc index 31361fd8e1..801d908e21 100644 --- a/tests/matrix_free/step-37-inhomogeneous-1.cc +++ b/tests/matrix_free/step-37-inhomogeneous-1.cc @@ -434,8 +434,7 @@ namespace Step37 const unsigned int nlevels = triangulation.n_global_levels(); mg_matrices.resize(0, nlevels - 1); - std::set dirichlet_boundary; - dirichlet_boundary.insert(0); + const std::set dirichlet_boundary = {0}; mg_constrained_dofs.initialize(dof_handler); mg_constrained_dofs.make_zero_boundary_constraints(dof_handler, dirichlet_boundary); diff --git a/tests/matrix_free/stokes_computation.cc b/tests/matrix_free/stokes_computation.cc index d04f170ea9..061cf429d0 100644 --- a/tests/matrix_free/stokes_computation.cc +++ b/tests/matrix_free/stokes_computation.cc @@ -1102,8 +1102,7 @@ namespace StokesClass mg_matrices.resize(0, n_levels - 1); mg_constrained_dofs.clear(); - std::set dirichlet_boundary; - dirichlet_boundary.insert(0); + const std::set dirichlet_boundary = {0}; mg_constrained_dofs.initialize(dof_handler_u); mg_constrained_dofs.make_zero_boundary_constraints(dof_handler_u, dirichlet_boundary); diff --git a/tests/performance/timing_step_37.cc b/tests/performance/timing_step_37.cc index e63057b32a..ef35faec65 100644 --- a/tests/performance/timing_step_37.cc +++ b/tests/performance/timing_step_37.cc @@ -419,8 +419,7 @@ LaplaceProblem::setup_dofs() additional_data.tasks_parallel_scheme = MatrixFree::AdditionalData::none; - std::set dirichlet_boundary; - dirichlet_boundary.insert(0); + const std::set dirichlet_boundary = {0}; mg_constrained_dofs.initialize(dof_handler); mg_constrained_dofs.make_zero_boundary_constraints(dof_handler, dirichlet_boundary); @@ -471,8 +470,7 @@ LaplaceProblem::setup_matrix_free() const unsigned int nlevels = triangulation.n_global_levels(); mg_matrices.resize(0, nlevels - 1); - std::set dirichlet_boundary; - dirichlet_boundary.insert(0); + const std::set dirichlet_boundary = {0}; mg_constrained_dofs.initialize(dof_handler); mg_constrained_dofs.make_zero_boundary_constraints(dof_handler, dirichlet_boundary); -- 2.39.5