From d5c61674f1f316e5d65eb6f4158ff1cbe982d5e4 Mon Sep 17 00:00:00 2001 From: Sebastian Proell Date: Sat, 8 Oct 2022 17:19:18 +0200 Subject: [PATCH] MatrixFree: add early check for ghosted dst vector --- include/deal.II/matrix_free/matrix_free.h | 29 ++++++++++++++++++++++- 1 file changed, 28 insertions(+), 1 deletion(-) diff --git a/include/deal.II/matrix_free/matrix_free.h b/include/deal.II/matrix_free/matrix_free.h index 39fa06c6b4..1a1b731988 100644 --- a/include/deal.II/matrix_free/matrix_free.h +++ b/include/deal.II/matrix_free/matrix_free.h @@ -3807,6 +3807,29 @@ namespace internal + template , VectorType> * = + nullptr> + bool + has_ghost_elements(const VectorType &vec) + { + (void)vec; + return false; + } + + + + template , 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 -- 2.39.5