From bda8bf8961cb28372f3c216c14b6a1b6207040af Mon Sep 17 00:00:00 2001 From: Peter Munch Date: Mon, 21 Dec 2020 13:52:31 +0100 Subject: [PATCH] Work on MatrixFreeTools::compute_matrix --- include/deal.II/matrix_free/tools.h | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/include/deal.II/matrix_free/tools.h b/include/deal.II/matrix_free/tools.h index 8bd19d735e..d0b7f9d435 100644 --- a/include/deal.II/matrix_free/tools.h +++ b/include/deal.II/matrix_free/tools.h @@ -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