]> https://gitweb.dealii.org/ - dealii.git/commitdiff
Check if the vector is compressed. 18382/head
authorSebastian Kinnewig <sebastian@kinnewig.org>
Wed, 23 Apr 2025 12:18:18 +0000 (14:18 +0200)
committerSebastian Kinnewig <sebastian@kinnewig.org>
Fri, 2 May 2025 07:37:18 +0000 (09:37 +0200)
include/deal.II/lac/affine_constraints.templates.h

index 7286b441792586e6e4e397763f45debc9774263b..2294f1bf602592ec6f47c0885f3d9d82a6e01178 100644 (file)
@@ -2795,10 +2795,16 @@ namespace internal
       Assert(vec.n_blocks() > 0, ExcInternalError());
       return vec.block(0).get_mpi_communicator();
     }
+
+
+
+    template <typename V>
+    using is_compressed_op = decltype(std::declval<V>().is_compressed());
   } // namespace AffineConstraints
 } // namespace internal
 
 
+
 template <typename number>
 template <typename VectorType>
 void
@@ -2806,6 +2812,18 @@ AffineConstraints<number>::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

In the beginning the Universe was created. This has made a lot of people very angry and has been widely regarded as a bad move.

Douglas Adams


Typeset in Trocchi and Trocchi Bold Sans Serif.