]> https://gitweb.dealii.org/ - dealii.git/commitdiff
Add an assertion. 698/head
authorWolfgang Bangerth <bangerth@math.tamu.edu>
Sat, 28 Mar 2015 03:21:25 +0000 (22:21 -0500)
committerWolfgang Bangerth <bangerth@math.tamu.edu>
Sat, 28 Mar 2015 04:49:04 +0000 (23:49 -0500)
Spencer Patty ran into this today: if you try to create a
Trilinos SparsityPattern class where the IndexSets do not
exactly add up, Trilinos somewhere deep down throws an
exception of a type that we do not catch in typical
main() functions (because it is not derived from std::exception).
This leads to impossible to debug problems if you don't happen
to still have the Trilinos sources around and know how to set
breakpoints on all 'throw' statements. Better catch stuff like
this ourselves.

include/deal.II/base/index_set.h
source/base/index_set.cc

index 759da23ad05eaa89f4b168cb78bd61655a49de82..5747faf03aa54864c0dc04079d2ccb67ab1dab80 100644 (file)
@@ -305,7 +305,7 @@ public:
    * The last argument only plays a role if the communicator is a parallel
    * one, distributing computations across multiple processors. In that case,
    * if the last argument is false, then it is assumed that the index sets
-   * this function is called on on all processors are mutually exclusive but
+   * this function is called with on all processors are mutually exclusive but
    * together enumerate each index exactly once. In other words, if you call
    * this function on two processors, then the index sets this function is
    * called with must together have all possible indices from zero to
index 9b9a23face6e4126d51231878c9d0b28054477db..16f67cf684b5c1f9d33ddb4756b393aaebaea7f4 100644 (file)
@@ -432,6 +432,30 @@ IndexSet::make_trilinos_map (const MPI_Comm &communicator,
 {
   compress ();
 
+#ifdef DEBUG
+  if (!overlapping)
+    {
+      const unsigned int n_global_elements
+        = Utilities::MPI::sum (n_elements(), communicator);
+      Assert (n_global_elements == size(),
+              ExcMessage ("You are trying to create an Epetra_Map object "
+                          "that partitions elements of an index set "
+                          "between processors. However, the union of the "
+                          "index sets on different processors does not "
+                          "contain all indices exactly once: the sum of "
+                          "the number of entries the various processors "
+                          "want to store locally is "
+                          + Utilities::int_to_string (n_global_elements) +
+                          " whereas the total size of the object to be "
+                          "allocated is "
+                          + Utilities::int_to_string (size()) +
+                          ". In other words, there are "
+                          "either indices that are not spoken for "
+                          "by any processor, or there are indices that are "
+                          "claimed by multiple processors."));
+    }
+#endif
+
   if ((is_contiguous() == true) && (!overlapping))
     return Epetra_Map (TrilinosWrappers::types::int_type(size()),
                        TrilinosWrappers::types::int_type(n_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.