From: Peter Munch Date: Thu, 20 Jun 2024 07:35:26 +0000 (+0200) Subject: MatrixFreeTools::compute_matrix(): specialize assembly of diagonal blocks X-Git-Tag: v9.6.0-rc1~166^2 X-Git-Url: https://gitweb.dealii.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=89985722b2116f119e5ea3809f42b707986c52e2;p=dealii.git MatrixFreeTools::compute_matrix(): specialize assembly of diagonal blocks --- diff --git a/include/deal.II/matrix_free/tools.h b/include/deal.II/matrix_free/tools.h index 92e3f83166..1afa1983af 100644 --- a/include/deal.II/matrix_free/tools.h +++ b/include/deal.II/matrix_free/tools.h @@ -2221,11 +2221,20 @@ namespace MatrixFreeTools for (unsigned int v = 0; v < n_filled_lanes; ++v) for (unsigned int bi = 0; bi < n_blocks; ++bi) - constraints.distribute_local_to_global( - matrices[bi][bj][v], - dof_indices_mf[bi][v], - dof_indices_mf[bj][v], - matrix); + if (bi == bj) + // specialization for blocks on the diagonal + // to writing into diagonal elements of the + // matrix if the corresponding degree of freedom + // is constrained, see also the documentation + // of AffineConstraints::distribute_local_to_global() + constraints.distribute_local_to_global( + matrices[bi][bi][v], dof_indices_mf[bi][v], matrix); + else + constraints.distribute_local_to_global( + matrices[bi][bj][v], + dof_indices_mf[bi][v], + dof_indices_mf[bj][v], + matrix); } } };