From 1101ba6470e2fdc953a10075dd26e345b286efe9 Mon Sep 17 00:00:00 2001 From: Martin Kronbichler Date: Wed, 16 Aug 2023 13:23:25 +0200 Subject: [PATCH] Matrix-free diagonal: Ensure constant loop bounds --- include/deal.II/matrix_free/tools.h | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/include/deal.II/matrix_free/tools.h b/include/deal.II/matrix_free/tools.h index 54df1070c0..4869dcf557 100644 --- a/include/deal.II/matrix_free/tools.h +++ b/include/deal.II/matrix_free/tools.h @@ -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 -- 2.39.5