From: Peter Munch Date: Mon, 21 Dec 2020 12:52:31 +0000 (+0100) Subject: Work on MatrixFreeTools::compute_matrix X-Git-Tag: v9.3.0-rc1~731^2 X-Git-Url: https://gitweb.dealii.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=bda8bf8961cb28372f3c216c14b6a1b6207040af;p=dealii.git Work on MatrixFreeTools::compute_matrix --- 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