Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use simpler initialization of std::set #13676

Merged
merged 3 commits into from
May 6, 2022
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
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
3 changes: 1 addition & 2 deletions examples/step-37/step-37.cc
Original file line number Diff line number Diff line change
Expand Up @@ -841,8 +841,7 @@ 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 = {0};
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Since you're already in this patch, would you mind terribly changing the name for the variable to dirichlet_boundary_ids? Because it's really a set of ids, not of boundaries.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not at all - I fixed this here and in step-66.

mg_constrained_dofs.initialize(dof_handler);
mg_constrained_dofs.make_zero_boundary_constraints(dof_handler,
dirichlet_boundary);
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
3 changes: 1 addition & 2 deletions tests/matrix_free/copy_feevaluation.cc
Original file line number Diff line number Diff line change
Expand Up @@ -172,8 +172,7 @@ test()
stokes_sub_blocks[dim] = 1;
DoFRenumbering::component_wise(dof_handler, stokes_sub_blocks);

std::set<types::boundary_id> no_normal_flux_boundaries;
no_normal_flux_boundaries.insert(1);
std::set<types::boundary_id> no_normal_flux_boundaries = {1};
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
std::set<types::boundary_id> no_normal_flux_boundaries = {1};
const std::set<types::boundary_id> no_normal_flux_boundaries = {1};

I think const should work here, too.

It's just a test. I don't insist on this change :)

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I agree. I widened my search and found some more appearances.

DoFTools::make_hanging_node_constraints(dof_handler, constraints);
VectorTools::compute_no_normal_flux_constraints(
dof_handler, 0, no_normal_flux_boundaries, constraints, mapping);
Expand Down
4 changes: 1 addition & 3 deletions tests/matrix_free/matrix_vector_stokes_flux.cc
Original file line number Diff line number Diff line change
Expand Up @@ -158,9 +158,7 @@ test()
stokes_sub_blocks[dim] = 1;
DoFRenumbering::component_wise(dof_handler, stokes_sub_blocks);

std::set<types::boundary_id> no_normal_flux_boundaries;
no_normal_flux_boundaries.insert(0);
no_normal_flux_boundaries.insert(1);
const std::set<types::boundary_id> no_normal_flux_boundaries = {0, 1};
DoFTools::make_hanging_node_constraints(dof_handler, constraints);
VectorTools::compute_normal_flux_constraints(dof_handler,
0,
Expand Down
4 changes: 1 addition & 3 deletions tests/matrix_free/matrix_vector_stokes_noflux.cc
Original file line number Diff line number Diff line change
Expand Up @@ -166,9 +166,7 @@ test()
stokes_sub_blocks[dim] = 1;
DoFRenumbering::component_wise(dof_handler, stokes_sub_blocks);

std::set<types::boundary_id> no_normal_flux_boundaries;
no_normal_flux_boundaries.insert(0);
no_normal_flux_boundaries.insert(1);
const std::set<types::boundary_id> 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);
Expand Down
4 changes: 1 addition & 3 deletions tests/matrix_free/matrix_vector_stokes_noflux2.cc
Original file line number Diff line number Diff line change
Expand Up @@ -160,9 +160,7 @@ test()
stokes_sub_blocks[dim] = 1;
DoFRenumbering::component_wise(dof_handler, stokes_sub_blocks);

std::set<types::boundary_id> no_normal_flux_boundaries;
no_normal_flux_boundaries.insert(0);
no_normal_flux_boundaries.insert(1);
const std::set<types::boundary_id> 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);
Expand Down
4 changes: 1 addition & 3 deletions tests/matrix_free/matrix_vector_stokes_notempl.cc
Original file line number Diff line number Diff line change
Expand Up @@ -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<types::boundary_id> no_normal_flux_boundaries;
no_normal_flux_boundaries.insert(0);
no_normal_flux_boundaries.insert(1);
const std::set<types::boundary_id> 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);
Expand Down
4 changes: 1 addition & 3 deletions tests/matrix_free/matrix_vector_stokes_onedof.cc
Original file line number Diff line number Diff line change
Expand Up @@ -160,9 +160,7 @@ test(const FESystem<dim> &fe)

dof_handler.distribute_dofs(fe);

std::set<types::boundary_id> no_normal_flux_boundaries;
no_normal_flux_boundaries.insert(0);
no_normal_flux_boundaries.insert(1);
const std::set<types::boundary_id> 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(
Expand Down
3 changes: 1 addition & 2 deletions tests/matrix_free/parallel_multigrid.cc
Original file line number Diff line number Diff line change
Expand Up @@ -351,8 +351,7 @@ do_test(const DoFHandler<dim> &dof)

MappingQ<dim> mapping(fe_degree + 1);
LaplaceOperator<dim, fe_degree, n_q_points_1d, number> fine_matrix;
std::set<types::boundary_id> dirichlet_boundaries;
dirichlet_boundaries.insert(0);
const std::set<types::boundary_id> dirichlet_boundaries = {0};
fine_matrix.initialize(mapping, dof, dirichlet_boundaries);

LinearAlgebra::distributed::Vector<number> in, sol;
Expand Down
3 changes: 1 addition & 2 deletions tests/matrix_free/parallel_multigrid_fullydistributed.cc
Original file line number Diff line number Diff line change
Expand Up @@ -354,8 +354,7 @@ do_test(const DoFHandler<dim> &dof)

MappingQ<dim> mapping(fe_degree + 1);
LaplaceOperator<dim, fe_degree, n_q_points_1d, double> fine_matrix;
std::set<types::boundary_id> dirichlet_boundaries;
dirichlet_boundaries.insert(0);
const std::set<types::boundary_id> dirichlet_boundaries = {0};
fine_matrix.initialize(mapping, dof, dirichlet_boundaries);

LinearAlgebra::distributed::Vector<double> in, sol;
Expand Down
9 changes: 4 additions & 5 deletions tests/matrix_free/parallel_multigrid_interleave.cc
Original file line number Diff line number Diff line change
Expand Up @@ -342,11 +342,10 @@ do_test(const DoFHandler<dim> &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<dim> mapping(fe_degree + 1);
LaplaceOperator<dim, double> fine_matrix;
std::set<types::boundary_id> dirichlet_boundaries;
dirichlet_boundaries.insert(0);
const unsigned int fe_degree = dof.get_fe().degree;
MappingQ<dim> mapping(fe_degree + 1);
LaplaceOperator<dim, double> fine_matrix;
const std::set<types::boundary_id> dirichlet_boundaries = {0};
fine_matrix.initialize(mapping, dof, dirichlet_boundaries);

LinearAlgebra::distributed::Vector<double> in, sol;
Expand Down
9 changes: 4 additions & 5 deletions tests/matrix_free/parallel_multigrid_interleave_renumber.cc
Original file line number Diff line number Diff line change
Expand Up @@ -384,11 +384,10 @@ do_test(DoFHandler<dim> &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<dim> mapping(fe_degree + 1);
LaplaceOperator<dim, double> fine_matrix;
std::set<types::boundary_id> dirichlet_boundaries;
dirichlet_boundaries.insert(0);
const unsigned int fe_degree = dof.get_fe().degree;
MappingQ<dim> mapping(fe_degree + 1);
LaplaceOperator<dim, double> fine_matrix;
const std::set<types::boundary_id> dirichlet_boundaries = {0};
fine_matrix.initialize(mapping, dof, dirichlet_boundaries);

LinearAlgebra::distributed::Vector<double> in, sol;
Expand Down
3 changes: 1 addition & 2 deletions tests/matrix_free/parallel_multigrid_mf.cc
Original file line number Diff line number Diff line change
Expand Up @@ -349,8 +349,7 @@ do_test(const DoFHandler<dim> &dof)

MappingQ<dim> mapping(fe_degree + 1);
LaplaceOperator<dim, fe_degree, n_q_points_1d, double> fine_matrix;
std::set<types::boundary_id> dirichlet_boundaries;
dirichlet_boundaries.insert(0);
const std::set<types::boundary_id> dirichlet_boundaries = {0};
fine_matrix.initialize(mapping, dof, dirichlet_boundaries);

LinearAlgebra::distributed::Vector<double> in, sol;
Expand Down
3 changes: 1 addition & 2 deletions tests/matrix_free/step-37-inhomogeneous-1.cc
Original file line number Diff line number Diff line change
Expand Up @@ -434,8 +434,7 @@ 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 = {0};
mg_constrained_dofs.initialize(dof_handler);
mg_constrained_dofs.make_zero_boundary_constraints(dof_handler,
dirichlet_boundary);
Expand Down
3 changes: 1 addition & 2 deletions tests/matrix_free/stokes_computation.cc
Original file line number Diff line number Diff line change
Expand Up @@ -1102,8 +1102,7 @@ namespace StokesClass
mg_matrices.resize(0, n_levels - 1);

mg_constrained_dofs.clear();
std::set<types::boundary_id> dirichlet_boundary;
dirichlet_boundary.insert(0);
const std::set<types::boundary_id> dirichlet_boundary = {0};
mg_constrained_dofs.initialize(dof_handler_u);
mg_constrained_dofs.make_zero_boundary_constraints(dof_handler_u,
dirichlet_boundary);
Expand Down
6 changes: 2 additions & 4 deletions tests/performance/timing_step_37.cc
Original file line number Diff line number Diff line change
Expand Up @@ -419,8 +419,7 @@ LaplaceProblem<dim>::setup_dofs()
additional_data.tasks_parallel_scheme =
MatrixFree<dim, float>::AdditionalData::none;

std::set<types::boundary_id> dirichlet_boundary;
dirichlet_boundary.insert(0);
const std::set<types::boundary_id> dirichlet_boundary = {0};
mg_constrained_dofs.initialize(dof_handler);
mg_constrained_dofs.make_zero_boundary_constraints(dof_handler,
dirichlet_boundary);
Expand Down Expand Up @@ -471,8 +470,7 @@ LaplaceProblem<dim>::setup_matrix_free()
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 = {0};
mg_constrained_dofs.initialize(dof_handler);
mg_constrained_dofs.make_zero_boundary_constraints(dof_handler,
dirichlet_boundary);
Expand Down