From 46372534cd63cb2c294b4938aed43174c7501ac1 Mon Sep 17 00:00:00 2001 From: Martin Kronbichler Date: Wed, 16 Oct 2013 14:43:54 +0000 Subject: [PATCH] Add update_ghost_values and compress to parallel block vector for a consistent interface with the parallel non-block vector. git-svn-id: https://svn.dealii.org/trunk@31260 0785d39b-7218-0410-832d-ea1e28bc413d --- .../deal.II/lac/parallel_block_vector.h | 58 +++++++++++++++++++ 1 file changed, 58 insertions(+) diff --git a/deal.II/include/deal.II/lac/parallel_block_vector.h b/deal.II/include/deal.II/lac/parallel_block_vector.h index 747d12a33e..3be362a635 100644 --- a/deal.II/include/deal.II/lac/parallel_block_vector.h +++ b/deal.II/include/deal.II/lac/parallel_block_vector.h @@ -226,6 +226,41 @@ namespace parallel void reinit (const BlockVector &V, const bool fast=false); + /** + * This function copies the data that has accumulated in the data buffer + * for ghost indices to the owning processor. For the meaning of the + * argument @p operation, see the entry on @ref GlossCompress + * "Compressing distributed vectors and matrices" in the glossary. + * + * There are two variants for this function. If called with argument @p + * VectorOperation::add adds all the data accumulated in ghost elements + * to the respective elements on the owning processor and clears the + * ghost array afterwards. If called with argument @p + * VectorOperation::insert, a set operation is performed. Since setting + * elements in a vector with ghost elements is ambiguous (as one can set + * both the element on the ghost site as well as the owning site), this + * operation makes the assumption that all data is set correctly on the + * owning processor. Upon call of compress(VectorOperation::insert), all + * ghost entries are therefore simply zeroed out (using + * zero_ghost_values()). In debug mode, a check is performed that makes + * sure that the data set is actually consistent between processors, + * i.e., whenever a non-zero ghost element is found, it is compared to + * the value on the owning processor and an exception is thrown if these + * elements do not agree. + * + */ + void compress (::dealii::VectorOperation::values operation); + + /** + * Fills the data field for ghost indices with the values stored in the + * respective positions of the owning processor. This function is needed + * before reading from ghosts. The function is @p const even though + * ghost data is changed. This is needed to allow functions with a @p + * const vector to perform the data exchange without creating + * temporaries. + */ + void update_ghost_values () const; + /** * Return whether the vector contains only elements with value * zero. This function is mainly for internal consistency checks and @@ -543,6 +578,29 @@ namespace parallel } + + template + inline + void + BlockVector::compress (::dealii::VectorOperation::values operation) + { + for (unsigned int block=0; blockn_blocks(); ++block) + this->block(block).compress(operation); + } + + + + template + inline + void + BlockVector::update_ghost_values () const + { + for (unsigned int block=0; blockn_blocks(); ++block) + this->block(block).update_ghost_values(); + } + + + template inline bool -- 2.39.5