From: Martin Kronbichler Date: Wed, 16 Aug 2023 11:23:25 +0000 (+0200) Subject: Matrix-free diagonal: Ensure constant loop bounds X-Git-Tag: relicensing~588^2 X-Git-Url: https://gitweb.dealii.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=1101ba6470e2fdc953a10075dd26e345b286efe9;p=dealii.git Matrix-free diagonal: Ensure constant loop bounds --- 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