From 71dbd03fe8fb81a29efb912b4b96a40c9ad3c40a Mon Sep 17 00:00:00 2001 From: Wolfgang Bangerth Date: Tue, 21 May 2024 17:01:18 -0600 Subject: [PATCH] Do not compute residual by hand. --- examples/step-9/step-9.cc | 22 ++++++++++------------ 1 file changed, 10 insertions(+), 12 deletions(-) diff --git a/examples/step-9/step-9.cc b/examples/step-9/step-9.cc index 10b425390c..6db020dd8f 100644 --- a/examples/step-9/step-9.cc +++ b/examples/step-9/step-9.cc @@ -764,16 +764,12 @@ namespace Step9 preconditioner.initialize(system_matrix, 1.0); solver.solve(system_matrix, solution, system_rhs, preconditioner); - Vector residual(dof_handler.n_dofs()); + hanging_node_constraints.distribute(solution); - system_matrix.vmult(residual, solution); - residual -= system_rhs; std::cout << " Iterations required for convergence: " << solver_control.last_step() << '\n' - << " Max norm of residual: " - << residual.linfty_norm() << '\n'; - - hanging_node_constraints.distribute(solution); + << " Norm of residual at convergence: " + << solver_control.last_value() << '\n'; } // The following function refines the grid according to the quantity @@ -796,21 +792,23 @@ namespace Step9 triangulation.execute_coarsening_and_refinement(); } - // This function is similar to the one in step 6, but since we use a higher + // This function is similar to the one in step-6, but since we use a higher // degree finite element we save the solution in a different // way. Visualization programs like VisIt and Paraview typically only // understand data that is associated with nodes: they cannot plot // fifth-degree basis functions, which results in a very inaccurate picture // of the solution we computed. To get around this we save multiple - // patches per cell: in 2d we save 64 bilinear `cells' to the VTU - // file for each cell, and in 3d we save 512. The end result is that the + // patches per cell: in 2d we save $8\times 8=64$ bilinear + // `sub-cells' to the VTU file for each cell, and in 3d we save + // $8\times 8\times 8 = 512$. The end result is that the // visualization program will use a piecewise linear interpolation of the - // cubic basis functions: this captures the solution detail and, with most + // cubic basis functions on a 3 times refined mesh: + // This captures the solution detail and, with most // screen resolutions, looks smooth. We save the grid in a separate step // with no extra patches so that we have a visual representation of the cell // faces. // - // Version 9.1 of deal.II gained the ability to write higher degree + // @note Version 9.1 of deal.II gained the ability to write higher degree // polynomials (i.e., write piecewise bicubic visualization data for our // piecewise bicubic solution) VTK and VTU output: however, not all recent // versions of ParaView and VisIt (as of 2018) can read this format, so we -- 2.39.5