]> https://gitweb.dealii.org/ - dealii-svn.git/commitdiff
Various small bug fixes etc.
authorwolf <wolf@0785d39b-7218-0410-832d-ea1e28bc413d>
Wed, 24 Mar 2004 23:24:14 +0000 (23:24 +0000)
committerwolf <wolf@0785d39b-7218-0410-832d-ea1e28bc413d>
Wed, 24 Mar 2004 23:24:14 +0000 (23:24 +0000)
git-svn-id: https://svn.dealii.org/trunk@8869 0785d39b-7218-0410-832d-ea1e28bc413d

deal.II/lac/include/lac/petsc_vector.h
deal.II/lac/source/petsc_parallel_vector.cc
deal.II/lac/source/petsc_vector.cc

index 65f0822a5c077b1ab9d9d0944cdb91016c9fd703..6ccee550b5808a4704a7ee97be08746b4ee835da 100644 (file)
@@ -22,6 +22,7 @@
 #ifdef DEAL_II_USE_PETSC
 
 #include <lac/petsc_vector_base.h>
+#include <lac/petsc_parallel_vector.h>
 
 
 namespace PETScWrappers
@@ -72,11 +73,16 @@ namespace PETScWrappers
       explicit Vector (const ::Vector<Number> &v);
 
                                        /**
-                                        * Copy-constructor the
-                                        * values from a PETSc wrapper vector
-                                        * class.
+                                        * Copy-constructor the values from a
+                                        * PETSc wrapper vector class.
                                         */
-      explicit Vector (const VectorBase &v);
+      explicit Vector (const Vector &v);
+
+                                       /**
+                                        * Copy-constructor the values from a
+                                        * PETSc wrapper parallel vector class.
+                                        */
+      explicit Vector (const MPI::Vector &v);
 
                                        /**
                                         * Copy the given vector. Resize the
@@ -84,6 +90,21 @@ namespace PETScWrappers
                                         */
       Vector & operator = (const Vector &v);
 
+                                       /**
+                                        * Copy all the elements of the
+                                        * parallel vector @arg v into this
+                                        * local vector. Note that due to the
+                                        * communication model of MPI, @em all
+                                        * processes have to actually perform
+                                        * this operation, even if they do not
+                                        * use the result. It is not sufficient
+                                        * if only one processor tries to copy
+                                        * the elements from the other
+                                        * processors over to its own process
+                                        * space.
+                                        */
+      Vector & operator = (const MPI::Vector &v);
+
                                        /**
                                         * Set all components of the vector to
                                         * the given number @p{s}. Simply pass
@@ -190,6 +211,26 @@ namespace PETScWrappers
 
 
 
+  inline
+  Vector &
+  Vector::operator = (const MPI::Vector &v)
+  {
+                                     // the petsc function we call wants to
+                                     // generate the vector itself, so destroy
+                                     // the old one first
+    int ierr = VecDestroy (vector);
+    AssertThrow (ierr == 0, ExcPETScError(ierr));
+
+                                     // then do the gather operation
+    ierr = VecConvertMPIToSeqAll (static_cast<const Vec &>(v),
+                                            &vector);
+    AssertThrow (ierr == 0, ExcPETScError(ierr));
+    
+    return *this;
+  }
+
+
+
   template <typename number>
   inline
   Vector &
index 9d6b77abba3d8a4e4704022ab182bea6b5a5f95b..89e24bb5d76a62b7918c9ac94ff2d4466f352cdb 100644 (file)
@@ -112,7 +112,7 @@ namespace PETScWrappers
     Vector::create_vector (const unsigned int  n,
                            const unsigned int  local_size)
     {
-      Assert (local_size < n, ExcIndexRange (local_size, 0, n));
+      Assert (local_size <= n, ExcIndexRange (local_size, 0, n));
 
       const int ierr
         = VecCreateMPI (PETSC_COMM_SELF, local_size, n, &vector);
index 29633938ddf7386d910d2ab37be290c31e64db21..a61c1387df99e0e5b8c16b3783092ebcc945da9a 100644 (file)
@@ -37,10 +37,24 @@ namespace PETScWrappers
 
   
 
-  Vector::Vector (const VectorBase &v)
+  Vector::Vector (const Vector &v)
+                  :
+                  VectorBase ()
   {
-    Vector::create_vector (v.size());
-    VectorBase::operator = (v);
+                                     // first create a dummy vector, then copy
+                                     // over the other one
+    Vector::create_vector (1);
+    Vector::operator = (v);
+  }
+
+
+
+  Vector::Vector (const MPI::Vector &v)
+  {
+                                     // first create a dummy vector, then copy
+                                     // over the other one
+    Vector::create_vector (1);
+    Vector::operator = (v);
   }
 
 

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.