From c7ffc6377cf57a3e6f68d29f66cbac1c4dacc60f Mon Sep 17 00:00:00 2001 From: Sebastian Kinnewig Date: Wed, 23 Apr 2025 14:18:18 +0200 Subject: [PATCH] Check if the vector is compressed. --- .../deal.II/lac/affine_constraints.templates.h | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/include/deal.II/lac/affine_constraints.templates.h b/include/deal.II/lac/affine_constraints.templates.h index 7286b44179..2294f1bf60 100644 --- a/include/deal.II/lac/affine_constraints.templates.h +++ b/include/deal.II/lac/affine_constraints.templates.h @@ -2795,10 +2795,16 @@ namespace internal Assert(vec.n_blocks() > 0, ExcInternalError()); return vec.block(0).get_mpi_communicator(); } + + + + template + using is_compressed_op = decltype(std::declval().is_compressed()); } // namespace AffineConstraints } // namespace internal + template template void @@ -2806,6 +2812,18 @@ AffineConstraints::distribute(VectorType &vec) const { Assert(sorted == true, ExcMatrixNotClosed()); + if constexpr (internal::is_supported_operation< + internal::AffineConstraints::is_compressed_op, + VectorType>) + Assert( + vec.is_compressed(), + ExcMessage( + "To distribute a parallel vector, the vector must " + "not contain any previously written-to or added-to entries that " + "have not already been sent to these entries' owners. But " + "the vector you passed in has such entries. You need to call " + "compress() on the vector first, before passing it to this function.")); + // if the vector type supports parallel storage and if the vector actually // does store only part of the vector, distributing is slightly more // complicated. we might be able to skip the complicated part if one -- 2.39.5