]> https://gitweb.dealii.org/ - dealii.git/commitdiff
Simplify the code a bit. 9203/head
authorWolfgang Bangerth <bangerth@colostate.edu>
Mon, 30 Dec 2019 18:24:06 +0000 (11:24 -0700)
committerWolfgang Bangerth <bangerth@colostate.edu>
Mon, 30 Dec 2019 18:57:28 +0000 (11:57 -0700)
In earlier versions of deal.II, the SparseDirectUMFPACK could deal
with block matrices but not block vectors, and so we needed to do some
copying around. This is no longer necessary.

tests/umfpack/umfpack_09.cc

index a161190fe2bff7d814b7b70b84b8989c84857c85..5ed20f4040ef96985d72bee8b0445a7b929d8d14 100644 (file)
@@ -129,21 +129,26 @@ test()
       solution.block(2).reinit(dof_handler.n_dofs() -
                                2 * (dof_handler.n_dofs() / 3));
       solution.collect_sizes();
+
+      // Pick a solution vector
+      for (unsigned int j = 0; j < dof_handler.n_dofs(); ++j)
+        solution(j) = j + j * (i + 1) * (i + 1);
+
+      // Then choose as rhs for the linear system the vector
+      //   b = B*solution
+      // so that later the solution of the linear system Bx=b
+      // is again
+      //   x = solution
       BlockVector<double> x;
       x.reinit(solution);
       BlockVector<double> b;
       b.reinit(solution);
 
-      for (unsigned int j = 0; j < dof_handler.n_dofs(); ++j)
-        solution(j) = j + j * (i + 1) * (i + 1);
-
       B.vmult(b, solution);
       x = b;
-      Vector<double> tmp(solution.size());
-      tmp = x;
-      SparseDirectUMFPACK().solve(B, tmp);
-      x = tmp;
+      SparseDirectUMFPACK().solve(B, x);
 
+      // Check that we really got what we expected
       x -= solution;
       deallog << "relative norm distance = " << x.l2_norm() / solution.l2_norm()
               << std::endl;

In the beginning the Universe was created. This has made a lot of people very angry and has been widely regarded as a bad move.

Douglas Adams


Typeset in Trocchi and Trocchi Bold Sans Serif.