]> https://gitweb.dealii.org/ - dealii-svn.git/commitdiff
Implement a function that computes the local range of a parallel vector.
authorwolf <wolf@0785d39b-7218-0410-832d-ea1e28bc413d>
Fri, 16 Apr 2004 20:04:33 +0000 (20:04 +0000)
committerwolf <wolf@0785d39b-7218-0410-832d-ea1e28bc413d>
Fri, 16 Apr 2004 20:04:33 +0000 (20:04 +0000)
git-svn-id: https://svn.dealii.org/trunk@9029 0785d39b-7218-0410-832d-ea1e28bc413d

deal.II/lac/include/lac/petsc_vector_base.h
deal.II/lac/source/petsc_vector_base.cc

index ff4c1a1a366db05de4350fcf96e7a4834a80d9df..9cd8bcefcd8de5b022b2f1119869a146c7597164 100644 (file)
@@ -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
+                                       * <tt>n=local_size()</tt>.
+                                       */
+      std::pair<unsigned int, unsigned int> local_range () const;
+
                                        /**
                                         * Provide access to a given element,
                                         * both read and write.
index 4ba8f8460162ab77afcfb78d9af06957e1b89f63..54707fdd8c42c4ddca9be22b2462efbc6212214f 100644 (file)
@@ -195,6 +195,19 @@ namespace PETScWrappers
 
 
 
+  std::pair<unsigned int, unsigned int>
+  VectorBase::local_range () const
+  {
+    int begin, end;
+    const int ierr = VecGetOwnershipRange (static_cast<const Vec &>(vector),
+                                          &begin, &end);
+    AssertThrow (ierr == 0, ExcPETScError(ierr));
+
+    return std::make_pair (begin, end);
+  }
+
+
+
   PetscScalar
   VectorBase::operator * (const VectorBase &vec) const
   {

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.