From: Wolfgang Bangerth Date: Thu, 21 Dec 2023 22:42:18 +0000 (-0700) Subject: Prohibit calling compress() on vectors with ghost elements. X-Git-Tag: relicensing~222^2~1 X-Git-Url: https://gitweb.dealii.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=56815c9e9151b9dbce1550c7e7e732be402140a0;p=dealii.git Prohibit calling compress() on vectors with ghost elements. --- diff --git a/source/lac/petsc_vector_base.cc b/source/lac/petsc_vector_base.cc index d3db0022dd..052af43735 100644 --- a/source/lac/petsc_vector_base.cc +++ b/source/lac/petsc_vector_base.cc @@ -540,6 +540,13 @@ namespace PETScWrappers void VectorBase::compress(const VectorOperation::values operation) { + Assert(has_ghost_elements() == false, + ExcMessage("Calling compress() is only useful if a vector " + "has been written into, but this is a vector with ghost " + "elements and consequently is read-only. It does " + "not make sense to call compress() for such " + "vectors.")); + { # ifdef DEBUG // Check that all processors agree that last_action is the same (or none!) diff --git a/source/lac/trilinos_vector.cc b/source/lac/trilinos_vector.cc index 0431f266b9..8d26487152 100644 --- a/source/lac/trilinos_vector.cc +++ b/source/lac/trilinos_vector.cc @@ -599,6 +599,14 @@ namespace TrilinosWrappers void Vector::compress(VectorOperation::values given_last_action) { + Assert(has_ghost_elements() == false, + ExcMessage( + "Calling compress() is only useful if a vector " + "has been written into, but this is a vector with ghost " + "elements and consequently is read-only. It does " + "not make sense to call compress() for such " + "vectors.")); + // Select which mode to send to Trilinos. Note that we use last_action if // available and ignore what the user tells us to detect wrongly mixed // operations. Typically given_last_action is only used on machines that