From: Peter Munch Date: Wed, 16 Feb 2022 07:11:51 +0000 (+0100) Subject: LA::d::BV add copy_locally_owned_data_from() X-Git-Tag: v9.4.0-rc1~483^2 X-Git-Url: https://gitweb.dealii.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=979ee960d1eabf6ea0ffd4e11f78bcaeed901eac;p=dealii.git LA::d::BV add copy_locally_owned_data_from() --- diff --git a/include/deal.II/lac/la_parallel_block_vector.h b/include/deal.II/lac/la_parallel_block_vector.h index 13fe98bbbb..ed6f38500f 100644 --- a/include/deal.II/lac/la_parallel_block_vector.h +++ b/include/deal.II/lac/la_parallel_block_vector.h @@ -366,6 +366,24 @@ namespace LinearAlgebra bool has_ghost_elements() const; + /** + * This method copies the data in the locally owned range from another + * distributed vector @p src into the calling vector. As opposed to + * operator= that also includes ghost entries, this operation ignores + * the ghost range. The only prerequisite is that the local range on the + * calling vector and the given vector @p src are the same on all + * processors. It is explicitly allowed that the two vectors have + * different ghost elements that might or might not be related to each + * other. + * + * Since no data exchange is performed, make sure that neither @p src + * nor the calling vector have pending communications in order to obtain + * correct results. + */ + template + void + copy_locally_owned_data_from(const BlockVector &src); + /** * This is a collective add operation that adds a whole set of values * stored in @p values to the vector components specified by @p indices. diff --git a/include/deal.II/lac/la_parallel_block_vector.templates.h b/include/deal.II/lac/la_parallel_block_vector.templates.h index 188d03138a..8583819aef 100644 --- a/include/deal.II/lac/la_parallel_block_vector.templates.h +++ b/include/deal.II/lac/la_parallel_block_vector.templates.h @@ -211,6 +211,20 @@ namespace LinearAlgebra + template + template + void + BlockVector::copy_locally_owned_data_from( + const BlockVector &v) + { + AssertDimension(this->n_blocks(), v.n_blocks()); + + for (unsigned int b = 0; b < this->n_blocks(); ++b) + this->block(b).copy_locally_owned_data_from(v.block(b)); + } + + + #ifdef DEAL_II_WITH_PETSC namespace petsc_helpers diff --git a/source/lac/la_parallel_block_vector.inst.in b/source/lac/la_parallel_block_vector.inst.in index 7968153ad2..eb29b8491e 100644 --- a/source/lac/la_parallel_block_vector.inst.in +++ b/source/lac/la_parallel_block_vector.inst.in @@ -65,6 +65,9 @@ for (S1 : REAL_AND_COMPLEX_SCALARS; S2 : REAL_SCALARS) template void BlockVector::reinit(const BlockVector &, const bool); template void + BlockVector::copy_locally_owned_data_from( + const BlockVector &); + template void BlockVector::add(const std::vector &, const ::dealii::Vector &); \} @@ -82,6 +85,9 @@ for (S1, S2 : COMPLEX_SCALARS) template void BlockVector::reinit(const BlockVector &, const bool); template void + BlockVector::copy_locally_owned_data_from( + const BlockVector &); + template void BlockVector::add(const std::vector &, const ::dealii::Vector &); \}