From ea3826463108f0f66f3f2a8c7f49a2e40ffb24eb Mon Sep 17 00:00:00 2001 From: Wolfgang Bangerth Date: Tue, 4 Apr 2023 14:06:31 -0600 Subject: [PATCH] Make step-29 marginally easier to understand. --- examples/step-29/step-29.cc | 30 +++++++++++++++--------------- 1 file changed, 15 insertions(+), 15 deletions(-) diff --git a/examples/step-29/step-29.cc b/examples/step-29/step-29.cc index 57f68cd6dd..4c806846f6 100644 --- a/examples/step-29/step-29.cc +++ b/examples/step-29/step-29.cc @@ -736,13 +736,15 @@ namespace Step29 // As already mentioned in the introduction, the system matrix is neither // symmetric nor definite, and so it is not quite obvious how to come up // with an iterative solver and a preconditioner that do a good job on this - // matrix. We chose instead to go a different way and solve the linear + // matrix. (For more on this topic, see also the + // Possibilities for extensions section below.) + // We chose instead to go a different way and solve the linear // system with the sparse LU decomposition provided by UMFPACK. This is // often a good first choice for 2d problems and works reasonably well even - // for a large number of DoFs. The deal.II interface to UMFPACK is given by - // the SparseDirectUMFPACK class, which is very easy to use and allows us to - // solve our linear system with just 3 lines of code. - + // for moderately large numbers of DoFs. The deal.II interface to UMFPACK + // is implemented in the SparseDirectUMFPACK class, which is very easy to + // use and allows us to solve our linear system with just 3 lines of code. + // // Note again that for compiling this example program, you need to have the // deal.II library built with UMFPACK support. template @@ -752,18 +754,16 @@ namespace Step29 Timer timer; // The code to solve the linear system is short: First, we allocate an - // object of the right type. The following initialize call - // provides the matrix that we would like to invert to the - // SparseDirectUMFPACK object, and at the same time kicks off the - // LU-decomposition. Hence, this is also the point where most of the - // computational work in this program happens. + // object of the right type. The following call to + // SparseDirectUMFPACK::solve() takes as argument the matrix to decompose, + // and a vector that upon input equals the right hand side of the linear + // system to be solved, and upon output contains the solution of the linear + // system. To satisfy this input/output requirement, we first assign the + // right hand side vector to the `solution` variable. SparseDirectUMFPACK A_direct; - A_direct.initialize(system_matrix); - // After the decomposition, we can use A_direct like a matrix - // representing the inverse of our system matrix, so to compute the - // solution we just have to multiply with the right hand side vector: - A_direct.vmult(solution, system_rhs); + solution = system_rhs; + A_direct.solve(system_matrix, solution); timer.stop(); std::cout << "done (" << timer.cpu_time() << "s)" << std::endl; -- 2.39.5