From edbf7a5092b71a9bce6c800287ef3232a510c396 Mon Sep 17 00:00:00 2001 From: bangerth Date: Wed, 27 Mar 2013 14:22:53 +0000 Subject: [PATCH] Outlaw the use of local_range() and in_local_range() if the vector is not contiguous on the current processor. git-svn-id: https://svn.dealii.org/trunk@29072 0785d39b-7218-0410-832d-ea1e28bc413d --- .../deal.II/lac/trilinos_vector_base.h | 32 ++++++++++++++++--- 1 file changed, 28 insertions(+), 4 deletions(-) diff --git a/deal.II/include/deal.II/lac/trilinos_vector_base.h b/deal.II/include/deal.II/lac/trilinos_vector_base.h index fa32d9de6c..134bc47064 100644 --- a/deal.II/include/deal.II/lac/trilinos_vector_base.h +++ b/deal.II/include/deal.II/lac/trilinos_vector_base.h @@ -488,9 +488,24 @@ namespace TrilinosWrappers * that is stored locally. If * this is a sequential vector, * then the result will be the - * pair (0,N), otherwise it will - * be a pair (i,i+n), where - * n=local_size(). + * pair (0,N), otherwise it will + * be a pair (i,i+n), where + * n=local_size() and i is the first + * element of the vector stored on this processor, corresponding + * to the half open interval $[i,i+n)$ + * + * @note The description above is true most of the time, but + * not always. In particular, Trilinos vectors need not store + * contiguous ranges of elements such as $[i,i+n)$. Rather, it + * can store vectors where the elements are distributed in + * an arbitrary way across all processors and each processor + * simply stores a particular subset, not necessarily contiguous. + * In this case, this function clearly makes no sense since it + * could, at best, return a range that includes all elements + * that are stored locally. Thus, the function only succeeds + * if the locally stored range is indeed contiguous. It will + * trigger an assertion if the local portion of the vector + * is not contiguous. */ std::pair local_range () const; @@ -498,6 +513,9 @@ namespace TrilinosWrappers * Return whether @p index is in * the local range or not, see * also local_range(). + * + * @note The same limitation for the applicability of this + * function applies as listed in the documentation of local_range(). */ bool in_local_range (const unsigned int index) const; @@ -1172,7 +1190,7 @@ namespace TrilinosWrappers bool VectorBase::in_local_range (const unsigned int index) const { - std::pair range = local_range(); + const std::pair range = local_range(); return ((index >= range.first) && (index < range.second)); } @@ -1490,6 +1508,12 @@ namespace TrilinosWrappers int begin, end; begin = vector->Map().MinMyGID(); end = vector->Map().MaxMyGID()+1; + + Assert (end-begin == vector->Map().NumMyElements(), + ExcMessage ("This function only makes sense if the elements that this " + "vector stores on the current processor form a contiguous range. " + "This does not appear to be the case for the current vector.")); + return std::make_pair (begin, end); } -- 2.39.5