From: Wolfgang Bangerth Date: Thu, 5 Oct 2023 22:30:22 +0000 (-0600) Subject: Convert some of the tutorials. X-Git-Tag: relicensing~423^2 X-Git-Url: https://gitweb.dealii.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=refs%2Fpull%2F16103%2Fhead;p=dealii.git Convert some of the tutorials. --- diff --git a/examples/step-11/step-11.cc b/examples/step-11/step-11.cc index e29f3aa4d4..f7a61397b7 100644 --- a/examples/step-11/step-11.cc +++ b/examples/step-11/step-11.cc @@ -151,16 +151,17 @@ namespace Step11 // Then generate a constraints object with just this one constraint. First // clear all previous content (which might reside there from the previous - // computation on a once coarser grid), then add this one line + // computation on a once coarser grid), then add this one constraint, // constraining the first_boundary_dof to the sum of other // boundary DoFs each with weight -1. Finally, close the constraints // object, i.e. do some internal bookkeeping on it for faster processing // of what is to come later: mean_value_constraints.clear(); - mean_value_constraints.add_line(first_boundary_dof); + std::vector> rhs; for (const types::global_dof_index i : boundary_dofs) if (i != first_boundary_dof) - mean_value_constraints.add_entry(first_boundary_dof, i, -1); + rhs.emplace_back(i, -1.); + mean_value_constraints.add_constraint(first_boundary_dof, rhs); mean_value_constraints.close(); // Next task is to generate a sparsity pattern. This is indeed a tricky diff --git a/examples/step-41/step-41.cc b/examples/step-41/step-41.cc index ea25fc378a..d3416259cf 100644 --- a/examples/step-41/step-41.cc +++ b/examples/step-41/step-41.cc @@ -479,8 +479,7 @@ namespace Step41 0) { active_set.add_index(dof_index); - constraints.add_line(dof_index); - constraints.set_inhomogeneity(dof_index, obstacle_value); + constraints.add_constraint(dof_index, {}, obstacle_value); solution(dof_index) = obstacle_value; diff --git a/examples/step-46/doc/intro.dox b/examples/step-46/doc/intro.dox index 190677cc5d..7f0386ce2d 100644 --- a/examples/step-46/doc/intro.dox +++ b/examples/step-46/doc/intro.dox @@ -494,21 +494,16 @@ 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; iconstraints.add_line(t) tells the -AffineConstraints to start a new constraint for degree of freedom -t of the form $x_t=\sum_{l=0}^{N-1} c_{tl} x_l + -b_t$. Typically, one would then proceed to set individual coefficients -$c_{tl}$ to nonzero values (using AffineConstraints::add_entry) or set -$b_t$ to something nonzero (using -AffineConstraints::set_inhomogeneity); doing nothing as above, funny as -it looks, simply leaves the constraint to be $x_t=0$, which is exactly +The last line calls +AffineConstraints::add_constraint() and adds the constraint +xlocal_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 +FiniteElement::face_system_to_component_index() makes sure that we only set boundary values to zero for velocity but not pressure components. Note that there are cases where this may yield incorrect results: diff --git a/examples/step-46/step-46.cc b/examples/step-46/step-46.cc index 23b7aaa44a..5cfc877bc7 100644 --- a/examples/step-46/step-46.cc +++ b/examples/step-46/step-46.cc @@ -385,7 +385,9 @@ namespace Step46 ++i) if (stokes_fe.face_system_to_component_index(i).first < dim) - constraints.add_line(local_face_dof_indices[i]); + constraints.add_constraint(local_face_dof_indices[i], + {}, + 0.); } } }