Skip to content

Commit

Permalink
Merge pull request #13676 from kronbichler/simplify_set_init
Browse files Browse the repository at this point in the history
Use simpler initialization of std::set
  • Loading branch information
marcfehling committed May 6, 2022
2 parents d7e2f62 + 96bc741 commit 1857f60
Show file tree
Hide file tree
Showing 69 changed files with 162 additions and 245 deletions.
3 changes: 1 addition & 2 deletions examples/step-31/step-31.cc
Original file line number Diff line number Diff line change
Expand Up @@ -847,8 +847,7 @@ namespace Step31
stokes_constraints.clear();
DoFTools::make_hanging_node_constraints(stokes_dof_handler,
stokes_constraints);
std::set<types::boundary_id> no_normal_flux_boundaries;
no_normal_flux_boundaries.insert(0);
const std::set<types::boundary_id> no_normal_flux_boundaries = {0};
VectorTools::compute_no_normal_flux_constraints(stokes_dof_handler,
0,
no_normal_flux_boundaries,
Expand Down
5 changes: 2 additions & 3 deletions examples/step-37/step-37.cc
Original file line number Diff line number Diff line change
Expand Up @@ -841,11 +841,10 @@ namespace Step37
const unsigned int nlevels = triangulation.n_global_levels();
mg_matrices.resize(0, nlevels - 1);

std::set<types::boundary_id> dirichlet_boundary;
dirichlet_boundary.insert(0);
const std::set<types::boundary_id> dirichlet_boundary_ids = {0};
mg_constrained_dofs.initialize(dof_handler);
mg_constrained_dofs.make_zero_boundary_constraints(dof_handler,
dirichlet_boundary);
dirichlet_boundary_ids);

for (unsigned int level = 0; level < nlevels; ++level)
{
Expand Down
3 changes: 1 addition & 2 deletions examples/step-38/doc/results.dox
Original file line number Diff line number Diff line change
Expand Up @@ -117,8 +117,7 @@ void LaplaceBeltrami<spacedim>::make_grid_and_dofs()

volume_mesh.refine_global(4);

std::set<types::boundary_id> boundary_ids;
boundary_ids.insert(0);
const std::set<types::boundary_id> boundary_ids = {0};

GridGenerator::extract_boundary_mesh(volume_mesh, triangulation,
boundary_ids);
Expand Down
3 changes: 1 addition & 2 deletions examples/step-38/step-38.cc
Original file line number Diff line number Diff line change
Expand Up @@ -306,8 +306,7 @@ namespace Step38
Triangulation<spacedim> volume_mesh;
GridGenerator::half_hyper_ball(volume_mesh);

std::set<types::boundary_id> boundary_ids;
boundary_ids.insert(0);
const std::set<types::boundary_id> boundary_ids = {0};

GridGenerator::extract_boundary_mesh(volume_mesh,
triangulation,
Expand Down
3 changes: 1 addition & 2 deletions examples/step-56/step-56.cc
Original file line number Diff line number Diff line change
Expand Up @@ -525,8 +525,7 @@ namespace Step56
// sparsity patterns and matrices for each level. The resize()
// function of MGLevelObject<T> will destroy all existing contained
// objects.
std::set<types::boundary_id> zero_boundary_ids;
zero_boundary_ids.insert(0);
const std::set<types::boundary_id> zero_boundary_ids = {0};

mg_constrained_dofs.clear();
mg_constrained_dofs.initialize(velocity_dof_handler);
Expand Down
5 changes: 2 additions & 3 deletions examples/step-66/step-66.cc
Original file line number Diff line number Diff line change
Expand Up @@ -582,11 +582,10 @@ namespace Step66
mg_matrices.resize(0, nlevels - 1);
mg_solution.resize(0, nlevels - 1);

std::set<types::boundary_id> dirichlet_boundary;
dirichlet_boundary.insert(0);
const std::set<types::boundary_id> dirichlet_boundary_ids = {0};
mg_constrained_dofs.initialize(dof_handler);
mg_constrained_dofs.make_zero_boundary_constraints(dof_handler,
dirichlet_boundary);
dirichlet_boundary_ids);

mg_transfer.initialize_constraints(mg_constrained_dofs);
mg_transfer.build(dof_handler);
Expand Down
3 changes: 1 addition & 2 deletions source/grid/grid_generator.cc
Original file line number Diff line number Diff line change
Expand Up @@ -5479,8 +5479,7 @@ namespace GridGenerator
{
Triangulation<spacedim> volume_mesh;
GridGenerator::hyper_ball(volume_mesh, p, radius);
std::set<types::boundary_id> boundary_ids;
boundary_ids.insert(0);
const std::set<types::boundary_id> boundary_ids = {0};
GridGenerator::extract_boundary_mesh(volume_mesh, tria, boundary_ids);
tria.set_all_manifold_ids(0);
tria.set_manifold(0, SphericalManifold<spacedim - 1, spacedim>(p));
Expand Down
5 changes: 2 additions & 3 deletions tests/bits/anna_4.cc
Original file line number Diff line number Diff line change
Expand Up @@ -189,9 +189,8 @@ FindBug<dim>::dirichlet_conditions()
component_mask);


std::vector<bool> fixed_dofs(dof_handler.n_dofs());
std::set<types::boundary_id> boundary_ids;
boundary_ids.insert(0);
std::vector<bool> fixed_dofs(dof_handler.n_dofs());
const std::set<types::boundary_id> boundary_ids = {0};

// get a list of those boundary DoFs which
// we want to be fixed:
Expand Down
10 changes: 4 additions & 6 deletions tests/bits/anna_6.cc
Original file line number Diff line number Diff line change
Expand Up @@ -180,9 +180,8 @@ ImposeBC<dim>::test_extract_boundary_DoFs()
bc_component_select[1] = true;
bc_component_select[2] = false;

std::vector<bool> ned_boundary_dofs(dof_handler.n_dofs());
std::set<types::boundary_id> boundary_ids;
boundary_ids.insert(0);
std::vector<bool> ned_boundary_dofs(dof_handler.n_dofs());
const std::set<types::boundary_id> boundary_ids = {0};
DoFTools::extract_boundary_dofs(dof_handler,
bc_component_select,
ned_boundary_dofs,
Expand Down Expand Up @@ -219,9 +218,8 @@ ImposeBC<dim>::test_interpolate_BC()
// check
// (the pressure is assumed to be set to 1
// on the boundary)
std::vector<bool> p_boundary_dofs(dof_handler.n_dofs());
std::set<types::boundary_id> boundary_ids;
boundary_ids.insert(0);
std::vector<bool> p_boundary_dofs(dof_handler.n_dofs());
const std::set<types::boundary_id> boundary_ids = {0};
DoFTools::extract_boundary_dofs(dof_handler,
bc_component_select,
p_boundary_dofs,
Expand Down
3 changes: 1 addition & 2 deletions tests/codim_one/boundary_indicator_01.cc
Original file line number Diff line number Diff line change
Expand Up @@ -90,8 +90,7 @@ main()

// now extract a mesh of the 5
// surface faces
std::set<types::boundary_id> boundary_ids;
boundary_ids.insert(0);
const std::set<types::boundary_id> boundary_ids = {0};
GridGenerator::extract_boundary_mesh(volume_mesh,
boundary_mesh,
boundary_ids);
Expand Down
4 changes: 1 addition & 3 deletions tests/codim_one/data_out_03.cc
Original file line number Diff line number Diff line change
Expand Up @@ -90,9 +90,7 @@ main()
tria.set_manifold(1, surface_description);
tria.set_manifold(0, surface_description);

std::set<types::boundary_id> boundary_ids;
boundary_ids.insert(0);

const std::set<types::boundary_id> boundary_ids = {0};
GridGenerator::extract_boundary_mesh(volume_mesh, tria, boundary_ids);

// test for the position
Expand Down
5 changes: 2 additions & 3 deletions tests/codim_one/extract_boundary_mesh_00.cc
Original file line number Diff line number Diff line change
Expand Up @@ -115,9 +115,8 @@ main()

save_mesh(volume_mesh);

Triangulation<dim - 1, dim> boundary_mesh;
set<types::boundary_id> boundary_ids;
boundary_ids.insert(0);
Triangulation<dim - 1, dim> boundary_mesh;
const set<types::boundary_id> boundary_ids = {0};

surface_to_volume_mapping =
GridGenerator::extract_boundary_mesh(volume_mesh,
Expand Down
3 changes: 1 addition & 2 deletions tests/codim_one/extract_boundary_mesh_07.cc
Original file line number Diff line number Diff line change
Expand Up @@ -81,8 +81,7 @@ namespace Step38
Extract_Mesh_Test<spacedim>::run()
{
GridGenerator::hyper_cube(volume_mesh_triangulation);
std::set<types::boundary_id> boundary_ids;
boundary_ids.insert(0);
const std::set<types::boundary_id> boundary_ids = {0};

space_dof_handler.distribute_dofs(space_fe);

Expand Down
3 changes: 1 addition & 2 deletions tests/codim_one/hanging_nodes_01.cc
Original file line number Diff line number Diff line change
Expand Up @@ -55,8 +55,7 @@ main()
volume_mesh.begin_active();

cell->face(0)->set_all_boundary_ids(1);
std::set<types::boundary_id> boundary_ids;
boundary_ids.insert(0);
const std::set<types::boundary_id> boundary_ids = {0};
GridGenerator::extract_boundary_mesh(volume_mesh,
boundary_mesh,
boundary_ids);
Expand Down
3 changes: 1 addition & 2 deletions tests/codim_one/hanging_nodes_02.cc
Original file line number Diff line number Diff line change
Expand Up @@ -52,8 +52,7 @@ main()
volume_mesh.begin_active();

cell->face(0)->set_all_boundary_ids(1);
std::set<types::boundary_id> boundary_ids;
boundary_ids.insert(0);
const std::set<types::boundary_id> boundary_ids = {0};
GridGenerator::extract_boundary_mesh(volume_mesh,
boundary_mesh,
boundary_ids);
Expand Down
3 changes: 1 addition & 2 deletions tests/codim_one/hanging_nodes_03.cc
Original file line number Diff line number Diff line change
Expand Up @@ -46,8 +46,7 @@ main()
volume_mesh.begin_active();

cell->face(0)->set_all_boundary_ids(1);
std::set<types::boundary_id> boundary_ids;
boundary_ids.insert(0);
const std::set<types::boundary_id> boundary_ids = {0};
GridGenerator::extract_boundary_mesh(volume_mesh,
boundary_mesh,
boundary_ids);
Expand Down
4 changes: 1 addition & 3 deletions tests/codim_one/interpolate_boundary_values_03.cc
Original file line number Diff line number Diff line change
Expand Up @@ -43,9 +43,7 @@ test()
Triangulation<dim, spacedim> tria;
Triangulation<spacedim> volume_mesh;
GridGenerator::half_hyper_ball(volume_mesh);
std::set<types::boundary_id> boundary_ids;
boundary_ids.insert(0);

const std::set<types::boundary_id> boundary_ids = {0};
GridGenerator::extract_boundary_mesh(volume_mesh, tria, boundary_ids);

deallog << tria.n_active_cells() << " active cells" << std::endl;
Expand Down
4 changes: 1 addition & 3 deletions tests/codim_one/transform_01.cc
Original file line number Diff line number Diff line change
Expand Up @@ -70,9 +70,7 @@ main()
static SphericalManifold<3 - 1, 3> surface_description;
triangulation.set_manifold(0, surface_description);

std::set<types::boundary_id> boundary_ids;
boundary_ids.insert(0);

const std::set<types::boundary_id> boundary_ids = {0};
GridGenerator::extract_boundary_mesh(volume_mesh,
triangulation,
boundary_ids);
Expand Down
3 changes: 1 addition & 2 deletions tests/dofs/dof_tools_05.cc
Original file line number Diff line number Diff line change
Expand Up @@ -52,8 +52,7 @@ check_this(const DoFHandler<dim> &dof_handler)
// third further restrict to
// boundary indicator 0
{
std::set<types::boundary_id> boundary_ids;
boundary_ids.insert(0);
const std::set<types::boundary_id> boundary_ids = {0};
DoFTools::extract_boundary_dofs(dof_handler,
component_select,
boundary_dofs,
Expand Down
9 changes: 4 additions & 5 deletions tests/dofs/dof_tools_09.cc
Original file line number Diff line number Diff line change
Expand Up @@ -30,11 +30,10 @@ void
check_this(const DoFHandler<dim> &dof_handler)
{
std::vector<types::global_dof_index> map(dof_handler.n_dofs());
std::set<types::boundary_id> boundary_ids;

// check for boundary id 0 alone
boundary_ids.insert(0);
DoFTools::map_dof_to_boundary_indices(dof_handler, map);
std::set<types::boundary_id> boundary_ids = {0};

DoFTools::map_dof_to_boundary_indices(dof_handler, boundary_ids, map);
for (unsigned int i = 0; i < map.size(); ++i)
deallog << (map[i] == numbers::invalid_dof_index ?
-1 :
Expand All @@ -44,7 +43,7 @@ check_this(const DoFHandler<dim> &dof_handler)

// check for boundary id 0 and 1
boundary_ids.insert(1);
DoFTools::map_dof_to_boundary_indices(dof_handler, map);
DoFTools::map_dof_to_boundary_indices(dof_handler, boundary_ids, map);
for (unsigned int i = 0; i < map.size(); ++i)
deallog << (map[i] == numbers::invalid_dof_index ?
-1 :
Expand Down

0 comments on commit 1857f60

Please sign in to comment.