From: heister Date: Thu, 1 Aug 2013 20:56:18 +0000 (+0000) Subject: add *::MPI::BlockVector::has_ghost_elements() and a missing constructor X-Git-Url: https://gitweb.dealii.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=f891863b5d6430aabaa0c170a6437b91b6ee1c97;p=dealii-svn.git add *::MPI::BlockVector::has_ghost_elements() and a missing constructor git-svn-id: https://svn.dealii.org/trunk@30209 0785d39b-7218-0410-832d-ea1e28bc413d --- diff --git a/deal.II/doc/news/changes.h b/deal.II/doc/news/changes.h index 9ba000d174..401a70d3ae 100644 --- a/deal.II/doc/news/changes.h +++ b/deal.II/doc/news/changes.h @@ -44,6 +44,13 @@ inconvenience this causes.

Specific improvements

    +
  1. + add has_ghost_elements() for PETScWrappers::MPI::BlockVector and + TrilinosWrappers::MPI::BlockVector. +
    + (Timo Heister, 2013/08/01) +
  2. +
  3. SparsityTools::distribute_sparsity_pattern did not work correctly for block systems, this has been fixed (function has a different signature). diff --git a/deal.II/include/deal.II/lac/petsc_parallel_block_vector.h b/deal.II/include/deal.II/lac/petsc_parallel_block_vector.h index 7d52ee3792..f7e5a4f1db 100644 --- a/deal.II/include/deal.II/lac/petsc_parallel_block_vector.h +++ b/deal.II/include/deal.II/lac/petsc_parallel_block_vector.h @@ -313,6 +313,11 @@ namespace PETScWrappers */ void reinit (const unsigned int num_blocks); + /** + * Returns if this vector is a ghosted vector (and thus read-only). + */ + bool has_ghost_elements() const; + /** * Return a reference to the MPI * communicator object in use with @@ -543,6 +548,17 @@ namespace PETScWrappers return block(0).get_mpi_communicator(); } + inline + bool + BlockVector::has_ghost_elements() const + { + bool ghosted=block(0).has_ghost_elements(); +#ifdef DEBUG + for (unsigned int i=0; in_blocks(); ++i) + Assert(block(i).has_ghost_elements()==ghosted, ExcInternalError()); +#endif + return ghosted; + } inline diff --git a/deal.II/include/deal.II/lac/trilinos_parallel_block_vector.h b/deal.II/include/deal.II/lac/trilinos_parallel_block_vector.h index f35166b1c3..d684216bdc 100644 --- a/deal.II/include/deal.II/lac/trilinos_parallel_block_vector.h +++ b/deal.II/include/deal.II/lac/trilinos_parallel_block_vector.h @@ -127,6 +127,16 @@ namespace TrilinosWrappers explicit BlockVector (const std::vector ¶llel_partitioning, const MPI_Comm &communicator = MPI_COMM_WORLD); + /** + * Creates a BlockVector with ghost elements. @p ghost_values + * may contain any elements in @p parallel_partitioning, they will + * be ignored. + */ + BlockVector (const std::vector ¶llel_partitioning, + const std::vector &ghost_values, + const MPI_Comm &communicator); + + /** * Copy-Constructor. Set all the * properties of the parallel vector @@ -353,6 +363,11 @@ namespace TrilinosWrappers */ bool is_compressed () const; + /** + * Returns if this Vector contains ghost elements. + */ + bool has_ghost_elements() const; + /** * Swap the contents of this * vector and the other vector @@ -431,6 +446,14 @@ namespace TrilinosWrappers } + inline + BlockVector::BlockVector (const std::vector ¶llel_partitioning, + const std::vector &ghost_values, + const MPI_Comm &communicator) + { + reinit(parallel_partitioning, ghost_values, communicator); + } + inline BlockVector::BlockVector (const size_type num_blocks) @@ -510,6 +533,18 @@ namespace TrilinosWrappers } + inline + bool + BlockVector::has_ghost_elements() const + { + bool ghosted=block(0).has_ghost_elements(); +#ifdef DEBUG + for (unsigned int i=0; in_blocks(); ++i) + Assert(block(i).has_ghost_elements()==ghosted, ExcInternalError()); +#endif + return ghosted; + } + inline void BlockVector::swap (BlockVector &v)