]> https://gitweb.dealii.org/ - dealii.git/commitdiff
Simplify exception message.
authorMartin Kronbichler <kronbichler@lnm.mw.tum.de>
Thu, 19 Oct 2017 10:17:58 +0000 (12:17 +0200)
committerMartin Kronbichler <kronbichler@lnm.mw.tum.de>
Thu, 19 Oct 2017 12:32:11 +0000 (14:32 +0200)
include/deal.II/base/partitioner.h
include/deal.II/base/partitioner.templates.h

index 8f364aaa3acc6eb3eb6f97f51e6ab09ebd93f233..52acda2b6fc91ebbbc44e264613ead2a840e248b 100644 (file)
@@ -170,7 +170,7 @@ namespace Utilities
        * indirect addressing into a larger set of ghost indices. This setup is
        * useful if a distributed vector is based on that larger ghost index
        * set but only a tighter subset should be communicated according to
-       * @p larger_ghost_index_set.
+       * @p ghost_indices.
        */
       void set_ghost_indices (const IndexSet &ghost_indices,
                               const IndexSet &larger_ghost_index_set = IndexSet());
@@ -377,7 +377,10 @@ namespace Utilities
        * i.e., the entries that a remote processor sent to the calling
        * process. Its size must either be n_ghost_indices() or equal the
        * number of ghost indices in the larger index set that was given as
-       * second argument to set_ghost_indices().
+       * second argument to set_ghost_indices(). In case only selected indices
+       * are sent, no guarantee is made regarding the entries that do not get
+       * set. Some of them might be used to organize the transfer and later
+       * reset to zero, so make sure you do not use them in computations.
        *
        * @param requests The list of MPI requests for the ongoing non-blocking
        * communication that will be finalized in the
@@ -517,6 +520,20 @@ namespace Utilities
                       << "Global index " << arg1
                       << " neither owned nor ghost on proc " << arg2 << ".");
 
+      /**
+       * Exception
+       */
+      DeclException3 (ExcGhostIndexArrayHasWrongSize,
+                      unsigned int,
+                      unsigned int,
+                      unsigned int,
+                      << "The size of the ghost index array (" << arg1
+                      << ") must either equal the number of ghost in the "
+                      << "partitioner (" << arg2
+                      << ") or be equal in size to a more comprehensive index"
+                      << "set which contains " << arg3
+                      << " elements for this partitioner.");
+
     private:
       /**
        * The global size of the vector over all processors
index 1f34c60cc78da697bfa995b7907477d1992ebc9f..b42a1118eade9e4f1a591f4842c028c1d59840aa 100644 (file)
@@ -44,21 +44,8 @@ namespace Utilities
       AssertDimension(temporary_storage.size(), n_import_indices());
       Assert(ghost_array.size() == n_ghost_indices() ||
              ghost_array.size() == n_ghost_indices_in_larger_set,
-             ExcMessage(std::string("The size of the ghost index array (")
-                        +
-                        std::to_string(ghost_array.size())
-                        +
-                        ") must either equal the number of ghost in the "
-                        "partitioner ("
-                        +
-                        std::to_string(n_ghost_indices())
-                        +
-                        ") or be equal in size to a more comprehensive index"
-                        "set which contains "
-                        +
-                        std::to_string(n_ghost_indices_in_larger_set)
-                        +
-                        " elements for this partitioner."));
+             ExcGhostIndexArrayHasWrongSize(ghost_array.size(), n_ghost_indices(),
+                                            n_ghost_indices_in_larger_set));
 
       const unsigned int n_import_targets = import_targets_data.size();
       const unsigned int n_ghost_targets = ghost_targets_data.size();
@@ -74,12 +61,15 @@ namespace Utilities
 
       // as a ghost array pointer, put the data at the end of the given ghost
       // array in case we want to fill only a subset of the ghosts so that we
-      // can get move data to the right position in a forward loop in the
-      // _finish function.
+      // can move data to the right position in a forward loop in the _finish
+      // function.
       AssertIndexRange(n_ghost_indices(), n_ghost_indices_in_larger_set+1);
-      Number *ghost_array_ptr = ghost_array.begin()+
-                                n_ghost_indices_in_larger_set-
-                                n_ghost_indices();
+      const bool use_larger_set = (n_ghost_indices_in_larger_set > n_ghost_indices() &&
+                                   ghost_array.size() == n_ghost_indices_in_larger_set);
+      Number *ghost_array_ptr = use_larger_set ?
+                                ghost_array.begin()+
+                                n_ghost_indices_in_larger_set-n_ghost_indices()
+                                : ghost_array.begin();
 
       for (unsigned int i=0; i<n_ghost_targets; i++)
         {
@@ -131,21 +121,8 @@ namespace Utilities
     {
       Assert(ghost_array.size() == n_ghost_indices() ||
              ghost_array.size() == n_ghost_indices_in_larger_set,
-             ExcMessage(std::string("The size of the ghost index array (")
-                        +
-                        std::to_string(ghost_array.size())
-                        +
-                        ") must either equal the number of ghost in the "
-                        "partitioner ("
-                        +
-                        std::to_string(n_ghost_indices())
-                        +
-                        ") or be equal in size to a more comprehensive index"
-                        "set which contains "
-                        +
-                        std::to_string(n_ghost_indices_in_larger_set)
-                        +
-                        " elements for this partitioner."));
+             ExcGhostIndexArrayHasWrongSize(ghost_array.size(), n_ghost_indices(),
+                                            n_ghost_indices_in_larger_set));
 
       // wait for both sends and receives to complete, even though only
       // receives are really necessary. this gives (much) better performance
@@ -178,7 +155,10 @@ namespace Utilities
                   ghost_array[offset] = Number();
                 }
             else
-              Assert(offset == my_ghosts->first, ExcInternalError());
+              {
+                AssertDimension(offset, my_ghosts->first);
+                break;
+              }
         }
     }
 
@@ -195,21 +175,8 @@ namespace Utilities
       AssertDimension(temporary_storage.size(), n_import_indices());
       Assert(ghost_array.size() == n_ghost_indices() ||
              ghost_array.size() == n_ghost_indices_in_larger_set,
-             ExcMessage(std::string("The size of the ghost index array (")
-                        +
-                        std::to_string(ghost_array.size())
-                        +
-                        ") must either equal the number of ghost in the "
-                        "partitioner ("
-                        +
-                        std::to_string(n_ghost_indices())
-                        +
-                        ") or be equal in size to a more comprehensive index"
-                        "set which contains "
-                        +
-                        std::to_string(n_ghost_indices_in_larger_set)
-                        +
-                        " elements for this partitioner."));
+             ExcGhostIndexArrayHasWrongSize(ghost_array.size(), n_ghost_indices(),
+                                            n_ghost_indices_in_larger_set));
 
       (void)vector_operation;
 
@@ -326,21 +293,8 @@ namespace Utilities
       AssertDimension(temporary_storage.size(), n_import_indices());
       Assert(ghost_array.size() == n_ghost_indices() ||
              ghost_array.size() == n_ghost_indices_in_larger_set,
-             ExcMessage(std::string("The size of the ghost index array (")
-                        +
-                        std::to_string(ghost_array.size())
-                        +
-                        ") must either equal the number of ghost in the "
-                        "partitioner ("
-                        +
-                        std::to_string(n_ghost_indices())
-                        +
-                        ") or be equal in size to a more comprehensive index"
-                        "set which contains "
-                        +
-                        std::to_string(n_ghost_indices_in_larger_set)
-                        +
-                        " elements for this partitioner."));
+             ExcGhostIndexArrayHasWrongSize(ghost_array.size(), n_ghost_indices(),
+                                            n_ghost_indices_in_larger_set));
 
       // in optimized mode, no communication was started, so leave the
       // function directly (and only clear ghosts)

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.