]> https://gitweb.dealii.org/ - dealii.git/commitdiff
introduce has_ghost_elements() for Trilinos and PETSc vectors.
authorTimo Heister <timo.heister@gmail.com>
Wed, 26 Jan 2011 14:25:45 +0000 (14:25 +0000)
committerTimo Heister <timo.heister@gmail.com>
Wed, 26 Jan 2011 14:25:45 +0000 (14:25 +0000)
git-svn-id: https://svn.dealii.org/trunk@23265 0785d39b-7218-0410-832d-ea1e28bc413d

deal.II/doc/news/changes.h
deal.II/include/deal.II/lac/petsc_vector_base.h
deal.II/include/deal.II/lac/trilinos_vector_base.h

index 5c65bce5de1555bef77b9e4e97200f83f9f5c5d1..4eaf74addf357918cff45df5b0c2005e4256f0ff 100644 (file)
@@ -71,6 +71,11 @@ should be fixed now.
 <h3>Specific improvements</h3>
 
 <ol>
+<li> New: Trilinos and PETSc vectors now have a function has_ghost_elements().
+<br>
+(Timo Heister, 2011/01/26)
+</li>
+
 <li> Changed: The TrilinosWrappers::MPI::BlockVector::compress function now takes an
 argument (with a default value) in exactly the same way as the
 TrilinosWrappers::MPI::Vector::compress function already did.
index 41cfed6ab0954197d3896537015d4cfbc25e01f1..5686f44efab15dc9eb32f1f451f6fbe70605e4b6 100644 (file)
@@ -372,6 +372,12 @@ namespace PETScWrappers
                                        */
       bool in_local_range (const unsigned int index) const;
 
+                                      /**
+                                       * Return if the vector contains ghost
+                                       * elements.
+                                       */
+      bool has_ghost_elements() const;
+       
                                        /**
                                         * Provide access to a given element,
                                         * both read and write.
@@ -1120,6 +1126,13 @@ namespace PETScWrappers
             (index < static_cast<unsigned int>(end)));
   }
 
+  inline
+  bool
+  VectorBase::has_ghost_elements() const
+  {
+    return ghosted;
+  }
+  
 
 
   inline
index 02f758e06e02d34cad2807b0f5969e1d7d435012..585a517863e194bd4be481e0607baea26715a4c7 100644 (file)
@@ -477,6 +477,12 @@ namespace TrilinosWrappers
                                        */
       bool in_local_range (const unsigned int index) const;
 
+                                      /**
+                                       * Return if the vector contains ghost
+                                       * elements.
+                                       */
+      bool has_ghost_elements() const;
+      
                                        /**
                                         * Return the scalar (inner)
                                         * product of two vectors. The
@@ -1102,8 +1108,17 @@ namespace TrilinosWrappers
     return ((index >= range.first) && (index <  range.second));
   }
 
+  
 
+  inline
+  bool
+  VectorBase::has_ghost_elements() const
+  {
+    return vector->Map().UniqueGIDs()==false;
+  }
 
+  
+  
   inline
   internal::VectorReference
   VectorBase::operator () (const unsigned int index)
@@ -1112,7 +1127,7 @@ namespace TrilinosWrappers
   }
 
 
-
+  
   inline
   void
   VectorBase::reinit (const VectorBase &v,
@@ -1212,8 +1227,7 @@ namespace TrilinosWrappers
   {
                                     // if we have ghost values, do not allow
                                     // writing to this vector at all.
-    Assert (vector->Map().UniqueGIDs()==true,
-           ExcGhostsPresent());    
+    Assert (!has_ghost_elements(), ExcGhostsPresent());    
     
     if (last_action == Add)
       vector->GlobalAssemble(Add);
@@ -1274,8 +1288,7 @@ namespace TrilinosWrappers
   {
                                     // if we have ghost values, do not allow
                                     // writing to this vector at all.
-    Assert (vector->Map().UniqueGIDs()==true,
-           ExcGhostsPresent());    
+    Assert (!has_ghost_elements(), ExcGhostsPresent());    
 
     if (last_action != Add)
       {
@@ -1340,8 +1353,7 @@ namespace TrilinosWrappers
   {
     Assert (vector->Map().SameAs(vec.vector->Map()),
            ExcDifferentParallelPartitioning());
-    Assert (vector->Map().UniqueGIDs()==true,
-           ExcGhostsPresent());
+    Assert (!has_ghost_elements(), ExcGhostsPresent());    
 
     TrilinosScalar result;
 
@@ -1367,7 +1379,7 @@ namespace TrilinosWrappers
   TrilinosScalar
   VectorBase::mean_value () const
   {
-    Assert (vector->Map().UniqueGIDs()==true, ExcGhostsPresent());
+    Assert (!has_ghost_elements(), ExcGhostsPresent());    
 
     TrilinosScalar mean;
     const int ierr = vector->MeanValue (&mean);
@@ -1382,8 +1394,7 @@ namespace TrilinosWrappers
   VectorBase::real_type
   VectorBase::l1_norm () const
   {
-    Assert (vector->Map().UniqueGIDs()==true,
-           ExcGhostsPresent());
+    Assert (!has_ghost_elements(), ExcGhostsPresent());    
 
     TrilinosScalar d;
     const int ierr = vector->Norm1 (&d);
@@ -1398,8 +1409,7 @@ namespace TrilinosWrappers
   VectorBase::real_type
   VectorBase::l2_norm () const
   {
-    Assert (vector->Map().UniqueGIDs()==true,
-           ExcGhostsPresent());
+    Assert (!has_ghost_elements(), ExcGhostsPresent());    
 
     TrilinosScalar d;
     const int ierr = vector->Norm2 (&d);
@@ -1414,8 +1424,7 @@ namespace TrilinosWrappers
   VectorBase::real_type
   VectorBase::lp_norm (const TrilinosScalar p) const
   {
-    Assert (vector->Map().UniqueGIDs()==true,
-           ExcGhostsPresent());
+    Assert (!has_ghost_elements(), ExcGhostsPresent());    
 
     TrilinosScalar norm = 0;
     TrilinosScalar sum=0;

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.