From: Wolfgang Bangerth Date: Mon, 23 Oct 2023 17:08:11 +0000 (-0600) Subject: Use constrain_dof_to_zero() in tests. X-Git-Tag: relicensing~369^2 X-Git-Url: https://gitweb.dealii.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=475a9ccf689e7da025f6af36a49371f92b131b36;p=dealii.git Use constrain_dof_to_zero() in tests. --- diff --git a/tests/multigrid/step-16-02.cc b/tests/multigrid/step-16-02.cc index f4553acb7c..734407342d 100644 --- a/tests/multigrid/step-16-02.cc +++ b/tests/multigrid/step-16-02.cc @@ -412,17 +412,20 @@ LaplaceProblem::assemble_multigrid(const bool &use_mw) triangulation.n_levels()); for (unsigned int level = 0; level < triangulation.n_levels(); ++level) { - boundary_constraints[level].add_lines( - mg_constrained_dofs.get_refinement_edge_indices(level)); - boundary_constraints[level].add_lines( - mg_constrained_dofs.get_boundary_indices(level)); - boundary_constraints[level].close(); - - IndexSet idx = + for (const types::global_dof_index dof_index : + mg_constrained_dofs.get_refinement_edge_indices(level)) + boundary_constraints[level].constrain_dof_to_zero(dof_index); + for (const types::global_dof_index dof_index : + mg_constrained_dofs.get_boundary_indices(level)) + boundary_constraints[level].constrain_dof_to_zero(dof_index); + + const IndexSet idx = mg_constrained_dofs.get_refinement_edge_indices(level) & mg_constrained_dofs.get_boundary_indices(level); - boundary_interface_constraints[level].add_lines(idx); + for (const types::global_dof_index idx : + mg_constrained_dofs.get_boundary_indices(level)) + boundary_constraints[level].constrain_dof_to_zero(idx); boundary_interface_constraints[level].close(); } diff --git a/tests/multigrid/step-16-03.cc b/tests/multigrid/step-16-03.cc index ecc6856481..d5625b7af7 100644 --- a/tests/multigrid/step-16-03.cc +++ b/tests/multigrid/step-16-03.cc @@ -293,10 +293,12 @@ LaplaceProblem::assemble_multigrid() for (unsigned int level = min_level; level < triangulation.n_levels(); ++level) { - boundary_constraints[level].add_lines( - mg_constrained_dofs.get_refinement_edge_indices(level)); - boundary_constraints[level].add_lines( - mg_constrained_dofs.get_boundary_indices(level)); + for (const types::global_dof_index dof_index : + mg_constrained_dofs.get_refinement_edge_indices(level)) + boundary_constraints[level].constrain_dof_to_zero(dof_index); + for (const types::global_dof_index dof_index : + mg_constrained_dofs.get_boundary_indices(level)) + boundary_constraints[level].constrain_dof_to_zero(dof_index); boundary_constraints[level].close(); } diff --git a/tests/multigrid/step-16-04.cc b/tests/multigrid/step-16-04.cc index 40d7f4c281..8bc1c8d45b 100644 --- a/tests/multigrid/step-16-04.cc +++ b/tests/multigrid/step-16-04.cc @@ -302,10 +302,12 @@ LaplaceProblem::assemble_multigrid() for (unsigned int level = min_level; level < triangulation.n_levels(); ++level) { - boundary_constraints[level].add_lines( - mg_constrained_dofs.get_refinement_edge_indices(level)); - boundary_constraints[level].add_lines( - mg_constrained_dofs.get_boundary_indices(level)); + for (const types::global_dof_index dof_index : + mg_constrained_dofs.get_refinement_edge_indices(level)) + boundary_constraints[level].constrain_dof_to_zero(dof_index); + for (const types::global_dof_index dof_index : + mg_constrained_dofs.get_boundary_indices(level)) + boundary_constraints[level].constrain_dof_to_zero(dof_index); boundary_constraints[level].close(); } diff --git a/tests/multigrid/step-16-05.cc b/tests/multigrid/step-16-05.cc index 3b78a566d7..fa7a177035 100644 --- a/tests/multigrid/step-16-05.cc +++ b/tests/multigrid/step-16-05.cc @@ -303,10 +303,12 @@ LaplaceProblem::assemble_multigrid() for (unsigned int level = min_level; level < triangulation.n_levels(); ++level) { - boundary_constraints[level].add_lines( - mg_constrained_dofs.get_refinement_edge_indices(level)); - boundary_constraints[level].add_lines( - mg_constrained_dofs.get_boundary_indices(level)); + for (const types::global_dof_index dof_index : + mg_constrained_dofs.get_refinement_edge_indices(level)) + boundary_constraints[level].constrain_dof_to_zero(dof_index); + for (const types::global_dof_index dof_index : + mg_constrained_dofs.get_boundary_indices(level)) + boundary_constraints[level].constrain_dof_to_zero(dof_index); boundary_constraints[level].close(); } diff --git a/tests/multigrid/step-16-06.cc b/tests/multigrid/step-16-06.cc index 3af78834c6..3540c34e49 100644 --- a/tests/multigrid/step-16-06.cc +++ b/tests/multigrid/step-16-06.cc @@ -303,10 +303,12 @@ LaplaceProblem::assemble_multigrid() for (unsigned int level = min_level; level < triangulation.n_levels(); ++level) { - boundary_constraints[level].add_lines( - mg_constrained_dofs.get_refinement_edge_indices(level)); - boundary_constraints[level].add_lines( - mg_constrained_dofs.get_boundary_indices(level)); + for (const types::global_dof_index dof_index : + mg_constrained_dofs.get_refinement_edge_indices(level)) + boundary_constraints[level].constrain_dof_to_zero(dof_index); + for (const types::global_dof_index dof_index : + mg_constrained_dofs.get_boundary_indices(level)) + boundary_constraints[level].constrain_dof_to_zero(dof_index); boundary_constraints[level].close(); } diff --git a/tests/multigrid/step-16-07.cc b/tests/multigrid/step-16-07.cc index c7fbba2a6c..55dda5ca02 100644 --- a/tests/multigrid/step-16-07.cc +++ b/tests/multigrid/step-16-07.cc @@ -298,10 +298,12 @@ LaplaceProblem::assemble_multigrid() AffineConstraints empty_constraints; for (unsigned int level = 0; level < triangulation.n_levels(); ++level) { - boundary_constraints[level].add_lines( - mg_constrained_dofs.get_refinement_edge_indices(level)); - boundary_constraints[level].add_lines( - mg_constrained_dofs.get_boundary_indices(level)); + for (const types::global_dof_index dof_index : + mg_constrained_dofs.get_refinement_edge_indices(level)) + boundary_constraints[level].constrain_dof_to_zero(dof_index); + for (const types::global_dof_index dof_index : + mg_constrained_dofs.get_boundary_indices(level)) + boundary_constraints[level].constrain_dof_to_zero(dof_index); boundary_constraints[level].close(); } diff --git a/tests/multigrid/step-16-08.cc b/tests/multigrid/step-16-08.cc index 0beff13198..c7f6d6a804 100644 --- a/tests/multigrid/step-16-08.cc +++ b/tests/multigrid/step-16-08.cc @@ -273,10 +273,12 @@ LaplaceProblem::assemble_multigrid() AffineConstraints empty_constraints; for (unsigned int level = 0; level < n_levels; ++level) { - boundary_constraints[level].add_lines( - mg_constrained_dofs.get_refinement_edge_indices(level)); - boundary_constraints[level].add_lines( - mg_constrained_dofs.get_boundary_indices(level)); + for (const types::global_dof_index dof_index : + mg_constrained_dofs.get_refinement_edge_indices(level)) + boundary_constraints[level].constrain_dof_to_zero(dof_index); + for (const types::global_dof_index dof_index : + mg_constrained_dofs.get_boundary_indices(level)) + boundary_constraints[level].constrain_dof_to_zero(dof_index); boundary_constraints[level].close(); DynamicSparsityPattern csp; diff --git a/tests/multigrid/step-16-50-mpi-linear-operator.cc b/tests/multigrid/step-16-50-mpi-linear-operator.cc index 5575a1dfe3..65130a8a91 100644 --- a/tests/multigrid/step-16-50-mpi-linear-operator.cc +++ b/tests/multigrid/step-16-50-mpi-linear-operator.cc @@ -350,11 +350,13 @@ namespace Step50 const IndexSet dofset = DoFTools::extract_locally_relevant_level_dofs(mg_dof_handler, level); boundary_constraints[level].reinit(dofset); - boundary_constraints[level].add_lines( - mg_constrained_dofs.get_refinement_edge_indices(level)); - boundary_constraints[level].add_lines( - mg_constrained_dofs.get_boundary_indices(level)); + for (const types::global_dof_index dof_index : + mg_constrained_dofs.get_refinement_edge_indices(level)) + boundary_constraints[level].constrain_dof_to_zero(dof_index); + for (const types::global_dof_index dof_index : + mg_constrained_dofs.get_boundary_indices(level)) + boundary_constraints[level].constrain_dof_to_zero(dof_index); boundary_constraints[level].close(); } diff --git a/tests/multigrid/step-16-50-mpi-smoother.cc b/tests/multigrid/step-16-50-mpi-smoother.cc index be074f5100..0a94ace9db 100644 --- a/tests/multigrid/step-16-50-mpi-smoother.cc +++ b/tests/multigrid/step-16-50-mpi-smoother.cc @@ -349,11 +349,13 @@ namespace Step50 const IndexSet dofset = DoFTools::extract_locally_relevant_level_dofs(mg_dof_handler, level); boundary_constraints[level].reinit(dofset); - boundary_constraints[level].add_lines( - mg_constrained_dofs.get_refinement_edge_indices(level)); - boundary_constraints[level].add_lines( - mg_constrained_dofs.get_boundary_indices(level)); + for (const types::global_dof_index dof_index : + mg_constrained_dofs.get_refinement_edge_indices(level)) + boundary_constraints[level].constrain_dof_to_zero(dof_index); + for (const types::global_dof_index dof_index : + mg_constrained_dofs.get_boundary_indices(level)) + boundary_constraints[level].constrain_dof_to_zero(dof_index); boundary_constraints[level].close(); } diff --git a/tests/multigrid/step-16-50-mpi.cc b/tests/multigrid/step-16-50-mpi.cc index 201dfd0212..a0bf09128f 100644 --- a/tests/multigrid/step-16-50-mpi.cc +++ b/tests/multigrid/step-16-50-mpi.cc @@ -350,11 +350,12 @@ namespace Step50 const IndexSet dofset = DoFTools::extract_locally_relevant_level_dofs(mg_dof_handler, level); boundary_constraints[level].reinit(dofset); - boundary_constraints[level].add_lines( - mg_constrained_dofs.get_refinement_edge_indices(level)); - boundary_constraints[level].add_lines( - mg_constrained_dofs.get_boundary_indices(level)); - + for (const types::global_dof_index dof_index : + mg_constrained_dofs.get_refinement_edge_indices(level)) + boundary_constraints[level].constrain_dof_to_zero(dof_index); + for (const types::global_dof_index dof_index : + mg_constrained_dofs.get_boundary_indices(level)) + boundary_constraints[level].constrain_dof_to_zero(dof_index); boundary_constraints[level].close(); } diff --git a/tests/multigrid/step-16-50-serial.cc b/tests/multigrid/step-16-50-serial.cc index 3f1cc457c2..c3947881c4 100644 --- a/tests/multigrid/step-16-50-serial.cc +++ b/tests/multigrid/step-16-50-serial.cc @@ -296,10 +296,12 @@ LaplaceProblem::assemble_multigrid() AffineConstraints empty_constraints; for (unsigned int level = 0; level < triangulation.n_levels(); ++level) { - boundary_constraints[level].add_lines( - mg_constrained_dofs.get_refinement_edge_indices(level)); - boundary_constraints[level].add_lines( - mg_constrained_dofs.get_boundary_indices(level)); + for (const types::global_dof_index dof_index : + mg_constrained_dofs.get_refinement_edge_indices(level)) + boundary_constraints[level].constrain_dof_to_zero(dof_index); + for (const types::global_dof_index dof_index : + mg_constrained_dofs.get_boundary_indices(level)) + boundary_constraints[level].constrain_dof_to_zero(dof_index); boundary_constraints[level].close(); } diff --git a/tests/multigrid/step-16-bdry1.cc b/tests/multigrid/step-16-bdry1.cc index 7812393609..f8ce456697 100644 --- a/tests/multigrid/step-16-bdry1.cc +++ b/tests/multigrid/step-16-bdry1.cc @@ -418,10 +418,12 @@ LaplaceProblem::assemble_multigrid(bool use_mw) for (unsigned int level = 0; level < triangulation.n_levels(); ++level) { - boundary_constraints[level].add_lines( - mg_constrained_dofs.get_refinement_edge_indices(level)); - boundary_constraints[level].add_lines( - mg_constrained_dofs.get_boundary_indices(level)); + for (const types::global_dof_index dof_index : + mg_constrained_dofs.get_refinement_edge_indices(level)) + boundary_constraints[level].constrain_dof_to_zero(dof_index); + for (const types::global_dof_index dof_index : + mg_constrained_dofs.get_boundary_indices(level)) + boundary_constraints[level].constrain_dof_to_zero(dof_index); boundary_constraints[level].close(); } diff --git a/tests/multigrid/step-16.cc b/tests/multigrid/step-16.cc index 9f1fe832a4..7bd3d6c025 100644 --- a/tests/multigrid/step-16.cc +++ b/tests/multigrid/step-16.cc @@ -298,10 +298,12 @@ LaplaceProblem::assemble_multigrid() AffineConstraints empty_constraints; for (unsigned int level = 0; level < triangulation.n_levels(); ++level) { - boundary_constraints[level].add_lines( - mg_constrained_dofs.get_refinement_edge_indices(level)); - boundary_constraints[level].add_lines( - mg_constrained_dofs.get_boundary_indices(level)); + for (const types::global_dof_index dof_index : + mg_constrained_dofs.get_refinement_edge_indices(level)) + boundary_constraints[level].constrain_dof_to_zero(dof_index); + for (const types::global_dof_index dof_index : + mg_constrained_dofs.get_boundary_indices(level)) + boundary_constraints[level].constrain_dof_to_zero(dof_index); boundary_constraints[level].close(); }