]> https://gitweb.dealii.org/ - dealii.git/commitdiff
Matrix-free diagonal: Ensure constant loop bounds 15883/head
authorMartin Kronbichler <martin.kronbichler@uni-a.de>
Wed, 16 Aug 2023 11:23:25 +0000 (13:23 +0200)
committerMartin Kronbichler <martin.kronbichler@uni-a.de>
Wed, 16 Aug 2023 11:23:25 +0000 (13:23 +0200)
include/deal.II/matrix_free/tools.h

index 54df1070c0a969bcc91031d2bc0fd87477088477..4869dcf5578feae03b2a6664bd7cf17858782899 100644 (file)
@@ -861,9 +861,10 @@ namespace MatrixFreeTools
         // compute i-th column of element stiffness matrix:
         // this could be simply performed as done at the moment with
         // matrix-free operator evaluation applied to a ith-basis vector
-        for (unsigned int j = 0; j < phi->dofs_per_cell; ++j)
-          phi->begin_dof_values()[j] = VectorizedArrayType();
-        phi->begin_dof_values()[i] = Number(1);
+        VectorizedArrayType *dof_values = phi->begin_dof_values();
+        for (const unsigned int j : phi->dof_indices())
+          dof_values[j] = VectorizedArrayType();
+        dof_values[i] = Number(1);
       }
 
       void

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.