From a4e4d650b66a85c97c57ff6d25d426bed8c41e32 Mon Sep 17 00:00:00 2001 From: David Wells Date: Sun, 26 Aug 2018 13:28:39 -0400 Subject: [PATCH] step-37: Convert ConstraintMatrix to AffineConstraints. --- examples/step-37/doc/intro.dox | 2 +- examples/step-37/doc/results.dox | 18 +++++++++--------- examples/step-37/step-37.cc | 10 +++++----- 3 files changed, 15 insertions(+), 15 deletions(-) diff --git a/examples/step-37/doc/intro.dox b/examples/step-37/doc/intro.dox index 6541e07af5..ad5fb81454 100644 --- a/examples/step-37/doc/intro.dox +++ b/examples/step-37/doc/intro.dox @@ -147,7 +147,7 @@ Matrixfree::vmult (Vector &dst, Here we neglected boundary conditions as well as any hanging nodes we may have, though neither would be very difficult to include using the -ConstraintMatrix class. Note how we first generate the local matrix in the +AffineConstraints class. Note how we first generate the local matrix in the usual way as a sum over all quadrature points for each local matrix entry. To form the actual product as expressed in the above formula, we extract the values of src of the cell-related degrees of freedom diff --git a/examples/step-37/doc/results.dox b/examples/step-37/doc/results.dox index b1049dbaab..e35e05a950 100644 --- a/examples/step-37/doc/results.dox +++ b/examples/step-37/doc/results.dox @@ -483,7 +483,7 @@ constrained by Dirichlet conditions. In the implementation in deal.II, the integrals $(\nabla \varphi_i,\nabla \varphi_j)_\Omega$ on the right hand side are already contained in the local matrix contributions we assemble on each cell. When using -ConstraintMatrix::distributed_local_to_global() as first described in the +AffineConstraints::distributed_local_to_global() as first described in the step-6 and step-7 tutorial programs, we can account for the contribution of inhomogeneous constraints j by multiplying the columns j and rows i of the local matrix according to the integrals $(\varphi_i, @@ -507,10 +507,10 @@ unrelated to the real entries. In a matrix-free method, we need to take a different approach, since the @p LaplaceOperator class represents the matrix-vector product of a homogeneous operator (the left-hand side of the last formula). It does -not matter whether the ConstraintMatrix passed to the MatrixFree::reinit() -contains inhomogeneous constraints or not, the MatrixFree::cell_loop() call -will only resolve the homogeneous part of the constraints as long as it -represents a linear operator. +not matter whether the AffineConstraints object passed to the +MatrixFree::reinit() contains inhomogeneous constraints or not, the +MatrixFree::cell_loop() call will only resolve the homogeneous part of the +constraints as long as it represents a linear operator. In our matrix-free code, the right hand side computation where the contribution of inhomogeneous conditions ends up is completely decoupled from @@ -530,7 +530,7 @@ where we only set the Dirichlet values: solution(it->first) = it->second; @endcode or, equivalently, if we already had filled the inhomogeneous constraints into -a constraint matrix object, +an AffineConstraints object, @code solution = 0; constraints.distribute(solution); @@ -613,13 +613,13 @@ assemble_residual() that computes the (weak) form of the residual, whereas the @p LaplaceOperator::apply_add() function would get the linearization of the residual with respect to the solution variable. -
Use LaplaceOperator with a second ConstraintMatrix without Dirichlet conditions
+
Use LaplaceOperator with a second AffineConstraints object without Dirichlet conditions
A second alternative to get the right hand side that re-uses the @p LaplaceOperator::apply_add() function is to instead add a second constraint matrix that skips Dirichlet constraints on the read operation. To do this, we initialize a MatrixFree object in a more extended way with two different -DoFHandler / ConstraintMatrix combinations. The 0-th component includes +DoFHandler-AffineConstraints combinations. The 0-th component includes Dirichlet conditions for solving the linear system, whereas 1-st component does read also from Dirichlet-constrained degrees of freedom for the right hand side assembly: @@ -680,7 +680,7 @@ void LaplaceProblem::assemble_rhs () } @endcode -Instead of adding a second DoFHandler / ConstraintMatrix pair to the same +Instead of adding a second DoFHandler-AffineConstraints pair to the same MatrixFree::reinit() call, one could of course also construct an independent MatrixFree object that feeds the second @p LaplaceOperator instance, see also the discussion in MatrixFreeOperators::Base. diff --git a/examples/step-37/step-37.cc b/examples/step-37/step-37.cc index aeed9f0c40..a7ea2e6f79 100644 --- a/examples/step-37/step-37.cc +++ b/examples/step-37/step-37.cc @@ -415,7 +415,7 @@ namespace Step37 // $v_\mathrm{cell}$ as mentioned in the introduction need to be added into // the result vector (and constraints are applied). This is done with a call // to @p distribute_local_to_global, the same name as the corresponding - // function in the ConstraintMatrix (only that we now store the local vector + // function in the AffineConstraints (only that we now store the local vector // in the FEEvaluation object, as are the indices between local and global // degrees of freedom). template @@ -476,7 +476,7 @@ namespace Step37 // Note that after the cell loop, the constrained degrees of freedom need to // be touched once more for sensible vmult() operators: Since the assembly // loop automatically resolves constraints (just as the - // ConstraintMatrix::distribute_local_to_global call does), it does not + // AffineConstraints::distribute_local_to_global() call does), it does not // compute any contribution for constrained degrees of freedom, leaving the // respective entries zero. This would represent a matrix that had empty // rows and columns for constrained degrees of freedom. However, iterative @@ -552,7 +552,7 @@ namespace Step37 // unsigned int in place of the source vector to confirm with the // cell_loop interface. After the loop, we need to set the vector entries // subject to Dirichlet boundary conditions to one (either those on the - // boundary described by the ConstraintMatrix object inside MatrixFree or + // boundary described by the AffineConstraints object inside MatrixFree or // the indices at the interface between different grid levels in adaptive // multigrid). This is done through the function // MatrixFreeOperators::Base::set_constrained_entries_to_one() and matches @@ -718,7 +718,7 @@ namespace Step37 FE_Q fe; DoFHandler dof_handler; - ConstraintMatrix constraints; + AffineConstraints constraints; using SystemMatrixType = LaplaceOperator; SystemMatrixType system_matrix; @@ -885,7 +885,7 @@ namespace Step37 DoFTools::extract_locally_relevant_level_dofs(dof_handler, level, relevant_dofs); - ConstraintMatrix level_constraints; + AffineConstraints level_constraints; level_constraints.reinit(relevant_dofs); level_constraints.add_lines( mg_constrained_dofs.get_boundary_indices(level)); -- 2.39.5