]> https://gitweb.dealii.org/ - dealii-svn.git/commitdiff
fix assignment and reinit of PETScWrappers::MPI::Vector
authorheister <heister@0785d39b-7218-0410-832d-ea1e28bc413d>
Mon, 5 Aug 2013 15:29:22 +0000 (15:29 +0000)
committerheister <heister@0785d39b-7218-0410-832d-ea1e28bc413d>
Mon, 5 Aug 2013 15:29:22 +0000 (15:29 +0000)
git-svn-id: https://svn.dealii.org/trunk@30221 0785d39b-7218-0410-832d-ea1e28bc413d

deal.II/doc/news/changes.h
deal.II/include/deal.II/lac/petsc_parallel_vector.h
deal.II/source/lac/petsc_parallel_vector.cc

index b411a0066fa80810c003fbb6239560d8e332e759..be39ececbd3a0024ac17ec160c13f4e485b8f26b 100644 (file)
@@ -44,6 +44,12 @@ inconvenience this causes.
 <h3>Specific improvements</h3>
 
 <ol>
+  <li>
+  Fixed: various fixes with assignment and reinit of PETScWrappers::MPI::Vector.
+  <br>
+  (Timo Heister, 2013/08/05)
+  </li>
+
   <li>Fixed: An assertion wrongly triggered in
   DoFTools::make_hanging_node_constraints when used with a particular
   combination of FESystem elements containing FE_Nothing. This is now fixed.
index 95cdddc2145cdd955649f50d3c831b1b7932c940..0c0cf8ae63d6b4c89351d5b7817e37a6b4a2f86e 100644 (file)
@@ -588,10 +588,30 @@ namespace PETScWrappers
     Vector &
     Vector::operator = (const Vector &v)
     {
+      if (v.size()==0)
+        {
+          // this happens if v has not been initialized to something useful:
+          // Vector x,v;x=v;
+          // we skip the code below and create a simple serial vector of
+          // length 0
+          const int n = 0;
+          const int ierr
+                  = VecCreateSeq (PETSC_COMM_SELF, n, &vector);
+          AssertThrow (ierr == 0, ExcPETScError(ierr));
+          ghosted = false;
+          ghost_indices.clear();
+          return *this;
+        }
+
       // if the vectors have different sizes,
       // then first resize the present one
       if (size() != v.size())
-        reinit (v.communicator, v.size(), v.local_size(), true);
+        {
+          if (v.has_ghost_elements())
+            reinit( v.locally_owned_elements(), v.ghost_indices, v.communicator);
+          else
+            reinit (v.communicator, v.size(), v.local_size(), true);
+        }
 
       const int ierr = VecCopy (v.vector, vector);
       AssertThrow (ierr == 0, ExcPETScError(ierr));
index 7c4cc997ee4aadc034b73de53cde899cc936ba9c..3b06dbb0c889818fc8659cd4037cddc5c26b480d 100644 (file)
@@ -39,6 +39,7 @@ namespace PETScWrappers
       const int ierr
         = VecCreateSeq (PETSC_COMM_SELF, n, &vector);
       AssertThrow (ierr == 0, ExcPETScError(ierr));
+      ghosted = false;
     }
 
 

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.