From 913b6b2717100a278f02712e1dddfaf401420dd5 Mon Sep 17 00:00:00 2001 From: Timo Heister Date: Wed, 26 Jan 2011 14:25:45 +0000 Subject: [PATCH] introduce has_ghost_elements() for Trilinos and PETSc vectors. git-svn-id: https://svn.dealii.org/trunk@23265 0785d39b-7218-0410-832d-ea1e28bc413d --- deal.II/doc/news/changes.h | 5 +++ .../include/deal.II/lac/petsc_vector_base.h | 13 +++++++ .../deal.II/lac/trilinos_vector_base.h | 37 ++++++++++++------- 3 files changed, 41 insertions(+), 14 deletions(-) diff --git a/deal.II/doc/news/changes.h b/deal.II/doc/news/changes.h index 5c65bce5de..4eaf74addf 100644 --- a/deal.II/doc/news/changes.h +++ b/deal.II/doc/news/changes.h @@ -71,6 +71,11 @@ should be fixed now.

Specific improvements

    +
  1. New: Trilinos and PETSc vectors now have a function has_ghost_elements(). +
    +(Timo Heister, 2011/01/26) +
  2. +
  3. 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. diff --git a/deal.II/include/deal.II/lac/petsc_vector_base.h b/deal.II/include/deal.II/lac/petsc_vector_base.h index 41cfed6ab0..5686f44efa 100644 --- a/deal.II/include/deal.II/lac/petsc_vector_base.h +++ b/deal.II/include/deal.II/lac/petsc_vector_base.h @@ -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(end))); } + inline + bool + VectorBase::has_ghost_elements() const + { + return ghosted; + } + inline diff --git a/deal.II/include/deal.II/lac/trilinos_vector_base.h b/deal.II/include/deal.II/lac/trilinos_vector_base.h index 02f758e06e..585a517863 100644 --- a/deal.II/include/deal.II/lac/trilinos_vector_base.h +++ b/deal.II/include/deal.II/lac/trilinos_vector_base.h @@ -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; -- 2.39.5