]> https://gitweb.dealii.org/ - dealii.git/commitdiff
MatrixFree: add early check for ghosted dst vector 14344/head
authorSebastian Proell <sebastian.proell@tum.de>
Sat, 8 Oct 2022 15:19:18 +0000 (17:19 +0200)
committerSebastian Proell <sebastian.proell@tum.de>
Mon, 10 Oct 2022 15:32:41 +0000 (17:32 +0200)
include/deal.II/matrix_free/matrix_free.h

index 39fa06c6b46c16a9efaf95f9bb5290aa88388a49..1a1b7319885c32f7ec2e788983e4f3f87e50145f 100644 (file)
@@ -3807,6 +3807,29 @@ namespace internal
 
 
 
+  template <typename VectorType,
+            std::enable_if_t<is_not_parallel_vector<VectorType>, VectorType> * =
+              nullptr>
+  bool
+  has_ghost_elements(const VectorType &vec)
+  {
+    (void)vec;
+    return false;
+  }
+
+
+
+  template <typename VectorType,
+            std::enable_if_t<!is_not_parallel_vector<VectorType>, VectorType>
+              * = nullptr>
+  bool
+  has_ghost_elements(const VectorType &vec)
+  {
+    return vec.has_ghost_elements();
+  }
+
+
+
   // --------------------------------------------------------------------------
   // below we have wrappers to distinguish between block and non-block vectors.
   // --------------------------------------------------------------------------
@@ -4435,7 +4458,11 @@ namespace internal
       , operation_before_loop(operation_before_loop)
       , operation_after_loop(operation_after_loop)
       , dof_handler_index_pre_post(dof_handler_index_pre_post)
-    {}
+    {
+      Assert(!has_ghost_elements(dst),
+             ExcMessage("The destination vector passed to the matrix-free "
+                        "loop is ghosted. This is not allowed."));
+    }
 
     // Runs the cell work. If no function is given, nothing is done
     virtual void

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.