From: Wolfgang Bangerth Date: Fri, 16 Apr 2004 20:04:33 +0000 (+0000) Subject: Implement a function that computes the local range of a parallel vector. X-Git-Tag: v8.0.0~15320 X-Git-Url: https://gitweb.dealii.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=f3e59d87d49631e2dd96e87553f720b06dae327c;p=dealii.git Implement a function that computes the local range of a parallel vector. git-svn-id: https://svn.dealii.org/trunk@9029 0785d39b-7218-0410-832d-ea1e28bc413d --- diff --git a/deal.II/lac/include/lac/petsc_vector_base.h b/deal.II/lac/include/lac/petsc_vector_base.h index ff4c1a1a36..9cd8bcefcd 100644 --- a/deal.II/lac/include/lac/petsc_vector_base.h +++ b/deal.II/lac/include/lac/petsc_vector_base.h @@ -290,9 +290,31 @@ namespace PETScWrappers * this number is the same as size(), * but for parallel vectors it may be * smaller. + * + * To figure out which elements + * exactly are stored locally, + * use local_range(). */ unsigned int local_size () const; - + + /** + * Return a pair of indices + * indicating which elements of + * this vector are stored + * locally. The first number is + * the index of the first + * element stored, the second + * the index of the one past + * the last one 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(). + */ + std::pair local_range () const; + /** * Provide access to a given element, * both read and write. diff --git a/deal.II/lac/source/petsc_vector_base.cc b/deal.II/lac/source/petsc_vector_base.cc index 4ba8f84601..54707fdd8c 100644 --- a/deal.II/lac/source/petsc_vector_base.cc +++ b/deal.II/lac/source/petsc_vector_base.cc @@ -195,6 +195,19 @@ namespace PETScWrappers + std::pair + VectorBase::local_range () const + { + int begin, end; + const int ierr = VecGetOwnershipRange (static_cast(vector), + &begin, &end); + AssertThrow (ierr == 0, ExcPETScError(ierr)); + + return std::make_pair (begin, end); + } + + + PetscScalar VectorBase::operator * (const VectorBase &vec) const {