From c404ba44d6a0b1855d1ecfe597a8ef1899084fe6 Mon Sep 17 00:00:00 2001 From: Wolfgang Bangerth Date: Thu, 19 Oct 2023 14:06:32 -0600 Subject: [PATCH] Use AffineConstraints::constrain_dof_to_zero(). --- examples/step-16/step-16.cc | 4 ++-- examples/step-37/step-37.cc | 2 +- examples/step-46/doc/intro.dox | 5 ++--- examples/step-46/step-46.cc | 5 ++--- examples/step-50/step-50.cc | 6 +++--- examples/step-56/step-56.cc | 6 +++--- examples/step-63/step-63.cc | 4 ++-- examples/step-66/step-66.cc | 2 +- include/deal.II/multigrid/mg_constrained_dofs.h | 4 ++-- source/dofs/dof_tools_constraints.cc | 7 +++---- 10 files changed, 21 insertions(+), 24 deletions(-) diff --git a/examples/step-16/step-16.cc b/examples/step-16/step-16.cc index a79e2f1fde..28491f00a2 100644 --- a/examples/step-16/step-16.cc +++ b/examples/step-16/step-16.cc @@ -439,10 +439,10 @@ namespace Step16 for (const types::global_dof_index dof_index : mg_constrained_dofs.get_refinement_edge_indices(level)) - boundary_constraints[level].add_constraint(dof_index, {}, 0.); + 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].add_constraint(dof_index, {}, 0.); + boundary_constraints[level].constrain_dof_to_zero(dof_index); boundary_constraints[level].close(); } diff --git a/examples/step-37/step-37.cc b/examples/step-37/step-37.cc index a4e98ab431..5293e4dd78 100644 --- a/examples/step-37/step-37.cc +++ b/examples/step-37/step-37.cc @@ -854,7 +854,7 @@ namespace Step37 DoFTools::extract_locally_relevant_level_dofs(dof_handler, level)); for (const types::global_dof_index dof_index : mg_constrained_dofs.get_boundary_indices(level)) - level_constraints.add_constraint(dof_index, {}, 0.); + level_constraints.constrain_dof_to_zero(dof_index); level_constraints.close(); typename MatrixFree::AdditionalData additional_data; diff --git a/examples/step-46/doc/intro.dox b/examples/step-46/doc/intro.dox index 7f0386ce2d..b76913b1df 100644 --- a/examples/step-46/doc/intro.dox +++ b/examples/step-46/doc/intro.dox @@ -494,13 +494,12 @@ for (const auto &cell: dof_handler.active_cell_iterators()) cell->face(f)->get_dof_indices (local_face_dof_indices, 0); for (unsigned int i=0; ixlocal_face_dof_indices[i]=0, which is exactly what we need in the current context. The call to FiniteElement::face_system_to_component_index() makes sure that we only set diff --git a/examples/step-46/step-46.cc b/examples/step-46/step-46.cc index 5cfc877bc7..1979ffd180 100644 --- a/examples/step-46/step-46.cc +++ b/examples/step-46/step-46.cc @@ -385,9 +385,8 @@ namespace Step46 ++i) if (stokes_fe.face_system_to_component_index(i).first < dim) - constraints.add_constraint(local_face_dof_indices[i], - {}, - 0.); + constraints.constrain_dof_to_zero( + local_face_dof_indices[i]); } } } diff --git a/examples/step-50/step-50.cc b/examples/step-50/step-50.cc index 30d0327651..7372929a3c 100644 --- a/examples/step-50/step-50.cc +++ b/examples/step-50/step-50.cc @@ -598,7 +598,7 @@ void LaplaceProblem::setup_multigrid() level)); for (const types::global_dof_index dof_index : mg_constrained_dofs.get_boundary_indices(level)) - level_constraints.add_constraint(dof_index, {}, 0.); + level_constraints.constrain_dof_to_zero(dof_index); level_constraints.close(); typename MatrixFree::AdditionalData additional_data; @@ -830,10 +830,10 @@ void LaplaceProblem::assemble_multigrid() for (const types::global_dof_index dof_index : mg_constrained_dofs.get_refinement_edge_indices(level)) - boundary_constraints[level].add_constraint(dof_index, {}, 0.); + 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].add_constraint(dof_index, {}, 0.); + boundary_constraints[level].constrain_dof_to_zero(dof_index); boundary_constraints[level].close(); } diff --git a/examples/step-56/step-56.cc b/examples/step-56/step-56.cc index 1dca4bc59e..188f297e8d 100644 --- a/examples/step-56/step-56.cc +++ b/examples/step-56/step-56.cc @@ -572,7 +572,7 @@ namespace Step56 // this here by marking the first pressure dof, which has index n_u as a // constrained dof. if (solver_type == SolverType::UMFPACK) - constraints.add_constraint(n_u, {}, 0.); + constraints.constrain_dof_to_zero(n_u); constraints.close(); } @@ -734,10 +734,10 @@ namespace Step56 { for (const types::global_dof_index dof_index : mg_constrained_dofs.get_refinement_edge_indices(level)) - boundary_constraints[level].add_constraint(dof_index, {}, 0.); + 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].add_constraint(dof_index, {}, 0.); + boundary_constraints[level].constrain_dof_to_zero(dof_index); boundary_constraints[level].close(); const IndexSet idx = diff --git a/examples/step-63/step-63.cc b/examples/step-63/step-63.cc index 81c59e9f64..68c031789a 100644 --- a/examples/step-63/step-63.cc +++ b/examples/step-63/step-63.cc @@ -820,10 +820,10 @@ namespace Step63 for (const types::global_dof_index dof_index : mg_constrained_dofs.get_refinement_edge_indices(level)) - boundary_constraints[level].add_constraint(dof_index, {}, 0.); + 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].add_constraint(dof_index, {}, 0.); + boundary_constraints[level].constrain_dof_to_zero(dof_index); boundary_constraints[level].close(); } diff --git a/examples/step-66/step-66.cc b/examples/step-66/step-66.cc index 504042a676..a4558476bb 100644 --- a/examples/step-66/step-66.cc +++ b/examples/step-66/step-66.cc @@ -596,7 +596,7 @@ namespace Step66 for (const types::global_dof_index dof_index : mg_constrained_dofs.get_boundary_indices(level)) - level_constraints.add_constraint(dof_index, {}, 0.); + level_constraints.constrain_dof_to_zero(dof_index); level_constraints.close(); typename MatrixFree::AdditionalData additional_data; diff --git a/include/deal.II/multigrid/mg_constrained_dofs.h b/include/deal.II/multigrid/mg_constrained_dofs.h index 84e55e9781..f96f72ecc3 100644 --- a/include/deal.II/multigrid/mg_constrained_dofs.h +++ b/include/deal.II/multigrid/mg_constrained_dofs.h @@ -626,11 +626,11 @@ MGConstrainedDoFs::merge_constraints(AffineConstraints &constraints, // merge constraints if (add_boundary_indices && this->have_boundary_indices()) for (const auto i : this->get_boundary_indices(level)) - constraints.add_constraint(i, {}, 0.); + constraints.constrain_dof_to_zero(i); if (add_refinement_edge_indices) for (const auto i : this->get_refinement_edge_indices(level)) - constraints.add_constraint(i, {}, 0.); + constraints.constrain_dof_to_zero(i); if (add_level_constraints) constraints.merge(this->get_level_constraints(level), diff --git a/source/dofs/dof_tools_constraints.cc b/source/dofs/dof_tools_constraints.cc index 635d4fb3e8..b6a0cb52f0 100644 --- a/source/dofs/dof_tools_constraints.cc +++ b/source/dofs/dof_tools_constraints.cc @@ -2199,7 +2199,7 @@ namespace DoFTools if (constraints_are_cyclic) { if (std::abs(cycle_constraint_factor - number(1.)) > eps) - affine_constraints.add_constraint(dof_left, {}, 0.); + affine_constraints.constrain_dof_to_zero(dof_left); } else { @@ -3594,9 +3594,8 @@ namespace DoFTools // inhomogeneity is zero: if (zero_boundary_constraints.is_constrained( face_dof) == false) - zero_boundary_constraints.add_constraint(face_dof, - {}, - 0.); + zero_boundary_constraints.constrain_dof_to_zero( + face_dof); else Assert(zero_boundary_constraints .is_inhomogeneously_constrained( -- 2.39.5