]> https://gitweb.dealii.org/ - dealii.git/commitdiff
Work on MatrixFreeTools::compute_matrix 11409/head
authorPeter Munch <peterrmuench@gmail.com>
Mon, 21 Dec 2020 12:52:31 +0000 (13:52 +0100)
committerPeter Munch <peterrmuench@gmail.com>
Mon, 21 Dec 2020 12:52:31 +0000 (13:52 +0100)
include/deal.II/matrix_free/tools.h

index 8bd19d735e9c669265ec767bd8baf41ee303ac95..d0b7f9d435a8ebdccb695c4a8682d705800c56a7 100644 (file)
@@ -99,8 +99,8 @@ namespace MatrixFreeTools
 
   /**
    * Compute the matrix representation of a linear operator (@p matrix), given
-   * @p matrix_free and the local cell integral operation @p local_vmult. The
-   * vector is initialized to the right size in the function.
+   * @p matrix_free and the local cell integral operation @p local_vmult.
+   * Constrained entries on the diagonal are set to one.
    *
    * The parameters @p dof_no, @p quad_no, and @p first_selected_component are
    * passed to the constructor of the FEEvaluation that is internally set up.
@@ -731,10 +731,12 @@ namespace MatrixFreeTools
 
     matrix.compress(VectorOperation::add);
 
-    for (unsigned int i = 0; i < matrix.m(); ++i)
-      if (matrix.get_row_length(i) > 0 && matrix(i, i) == 0.0 &&
-          constraints.is_constrained(i))
-        matrix.add(i, i, 1);
+    for (auto &entry : matrix)
+      if (entry.row() == entry.column() && entry.value() == 0.0)
+        {
+          Assert(constraints.is_constrained(entry.row()), ExcNotImplemented());
+          entry.value() = 1.0;
+        }
   }
 
   template <typename CLASS,

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.