From: Sebastian Proell Date: Sat, 8 Oct 2022 15:19:18 +0000 (+0200) Subject: MatrixFree: add early check for ghosted dst vector X-Git-Tag: v9.5.0-rc1~901^2 X-Git-Url: https://gitweb.dealii.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=refs%2Fpull%2F14344%2Fhead;p=dealii.git MatrixFree: add early check for ghosted dst vector --- 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