]> https://gitweb.dealii.org/ - dealii.git/commitdiff
More assertions in AffineConstraints. 16059/head
authorWolfgang Bangerth <bangerth@colostate.edu>
Thu, 28 Sep 2023 16:38:48 +0000 (10:38 -0600)
committerWolfgang Bangerth <bangerth@colostate.edu>
Thu, 28 Sep 2023 22:33:06 +0000 (16:33 -0600)
include/deal.II/lac/affine_constraints.templates.h

index cefa2962aab4097f0cbe392dd381f50f95c6364e..69dacd5f6c49b1418a35e1753786cc2689b50017 100644 (file)
@@ -2635,18 +2635,32 @@ AffineConstraints<number>::distribute(VectorType &vec) const
           // or the reinit() functions:
           if (Utilities::MPI::n_mpi_processes(
                 internal::AffineConstraints::get_mpi_communicator(vec)) > 1)
-            Assert(local_lines != IndexSet(),
-                   ExcMessage(
-                     "You are using the AffineConstraints class in a "
-                     "program that is running in parallel. In this case, "
-                     "it is inefficient to store all constraints: This class "
-                     "should really only store constraints for those degrees "
-                     "of freedom that are locally relevant. It is considered "
-                     "a bug not to do that. Please call either the "
-                     "constructor of this class, or one of its reinit() "
-                     "functions that provide this class with index sets "
-                     "of the locally owned and the locally relevant "
-                     "degrees of freedom."));
+            {
+              Assert(local_lines != IndexSet(),
+                     ExcMessage(
+                       "You are using the AffineConstraints class in a "
+                       "program that is running in parallel. In this case, "
+                       "it is inefficient to store all constraints: This class "
+                       "should really only store constraints for those degrees "
+                       "of freedom that are locally relevant. It is considered "
+                       "a bug not to do that. Please call either the "
+                       "constructor of this class, or one of its reinit() "
+                       "functions that provide this class with index sets "
+                       "of the locally owned and the locally relevant "
+                       "degrees of freedom."));
+
+              Assert(vec_owned_elements.size() == locally_owned_dofs.size(),
+                     ExcMessage("You have previously initialized this "
+                                "AffineConstraints object with an index set "
+                                "that stated that vectors have size " +
+                                std::to_string(locally_owned_dofs.size()) +
+                                " entries, but you are now calling "
+                                "AffineConstraints::distribute() with a vector "
+                                "of size " +
+                                std::to_string(vec_owned_elements.size()) +
+                                "."));
+            }
+
 
             // Check that the set of indices we will import is a superset of
             // the locally-owned ones. This *should* be the case if, as one
@@ -2676,6 +2690,10 @@ AffineConstraints<number>::distribute(VectorType &vec) const
           // simply import the *entire* vector.
           if (local_lines != IndexSet())
             {
+              Assert(vec_owned_elements.size() ==
+                       needed_elements_for_distribute.size(),
+                     ExcInternalError());
+
               Assert(needed_elements_for_distribute != IndexSet(),
                      ExcInternalError());
               internal::import_vector_with_ghost_elements(

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.