From: Martin Kronbichler Date: Thu, 19 Oct 2017 10:17:58 +0000 (+0200) Subject: Simplify exception message. X-Git-Tag: v9.0.0-rc1~933^2~1 X-Git-Url: https://gitweb.dealii.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=6ef88f45fff337c91a0cb67b3bcd3ffffe9db5a0;p=dealii.git Simplify exception message. --- diff --git a/include/deal.II/base/partitioner.h b/include/deal.II/base/partitioner.h index 8f364aaa3a..52acda2b6f 100644 --- a/include/deal.II/base/partitioner.h +++ b/include/deal.II/base/partitioner.h @@ -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 diff --git a/include/deal.II/base/partitioner.templates.h b/include/deal.II/base/partitioner.templates.h index 1f34c60cc7..b42a1118ea 100644 --- a/include/deal.II/base/partitioner.templates.h +++ b/include/deal.II/base/partitioner.templates.h @@ -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; ifirst, 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)