]> https://gitweb.dealii.org/ - dealii.git/commitdiff
Allow v=0.0 for ghosted PETSc and Trilinos vectors
authorTimo Heister <timo.heister@gmail.com>
Tue, 14 Oct 2014 20:19:34 +0000 (16:19 -0400)
committerTimo Heister <timo.heister@gmail.com>
Tue, 14 Oct 2014 20:20:42 +0000 (16:20 -0400)
doc/news/changes.h
include/deal.II/lac/trilinos_vector_base.h
source/lac/petsc_vector_base.cc

index 0665d082ae3f867faf50b7fa93c455371c6074fb..ce74a29e2bad79453a4d3e3f8cae3b1ed14e44d2 100644 (file)
@@ -307,6 +307,12 @@ inconvenience this causes.
 <h3>Specific improvements</h3>
 
 <ol>
+  <li> Changed: PETSc and Trilinos vectors with ghost entries can now be reset to zero
+  using = 0.0;
+  <br>
+  (Timo Heister, 2014/10/14)
+  </li>
+
   <li> New: The new function FiniteElement::get_associated_geometry_primitive() allows to
   query whether a given degree of freedom is associated with a vertex, line,
   quad, or hex.
index dd8fc22fc9ea349b09723472c0c8d0c7a6a010cd..449c4a5cf05cc573d3c586b229049fe369512601 100644 (file)
@@ -1227,10 +1227,6 @@ namespace TrilinosWrappers
   VectorBase &
   VectorBase::operator = (const TrilinosScalar s)
   {
-    // if we have ghost values, do not allow
-    // writing to this vector at all.
-    Assert (!has_ghost_elements(), ExcGhostsPresent());
-
     Assert (numbers::is_finite(s), ExcNumberNotFinite());
 
     const int ierr = vector->PutScalar(s);
index 4bb7c835ede5233815ed69edaabf86ce17ee6bad..007453082d1ddbd9d11ce2b097386b7b3f2a38fa 100644 (file)
@@ -213,14 +213,26 @@ namespace PETScWrappers
   VectorBase &
   VectorBase::operator = (const PetscScalar s)
   {
-    Assert (!has_ghost_elements(), ExcGhostsPresent());
     Assert (numbers::is_finite(s), ExcNumberNotFinite());
 
     //TODO[TH]: assert(is_compressed())
 
-    const int ierr = VecSet (vector, s);
+    int ierr = VecSet (vector, s);
     AssertThrow (ierr == 0, ExcPETScError(ierr));
 
+    if (has_ghost_elements())
+    {
+      Vec ghost = PETSC_NULL;
+      ierr = VecGhostGetLocalForm(vector, &ghost);
+      AssertThrow (ierr == 0, ExcPETScError(ierr));
+
+      ierr = VecSet (ghost, s);
+      AssertThrow (ierr == 0, ExcPETScError(ierr));
+
+      ierr = VecGhostRestoreLocalForm(vector, &ghost);
+      AssertThrow (ierr == 0, ExcPETScError(ierr));
+    }
+    
     return *this;
   }
 

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.