From ba49b5b0a162bfdfc65e824f60cfdf2c24fd6e9d Mon Sep 17 00:00:00 2001 From: Matthias Maier Date: Mon, 4 May 2015 09:36:52 +0200 Subject: [PATCH] Bugfix: Implement BlockVector::swap for different block sizes --- include/deal.II/lac/block_vector.h | 5 +---- include/deal.II/lac/block_vector.templates.h | 5 +---- 2 files changed, 2 insertions(+), 8 deletions(-) diff --git a/include/deal.II/lac/block_vector.h b/include/deal.II/lac/block_vector.h index 6b1ac989cf..95e7bbf2d3 100644 --- a/include/deal.II/lac/block_vector.h +++ b/include/deal.II/lac/block_vector.h @@ -314,10 +314,6 @@ public: * only swaps the pointers to the data of the two vectors and therefore does * not need to allocate temporary storage and move data around. * - * Limitation: right now this function only works if both vectors have the - * same number of blocks. If needed, the numbers of blocks should be - * exchanged, too. - * * This function is analog to the the swap() function of all C++ standard * containers. Also, there is a global function swap(u,v) that simply calls * u.swap(v), again in analogy to standard functions. @@ -433,6 +429,7 @@ BlockVector & BlockVector::operator= (BlockVector &&v) { swap(v); + // be nice and reset v to zero v.reinit(0, 0, false); diff --git a/include/deal.II/lac/block_vector.templates.h b/include/deal.II/lac/block_vector.templates.h index abdb94e7e0..d873067e55 100644 --- a/include/deal.II/lac/block_vector.templates.h +++ b/include/deal.II/lac/block_vector.templates.h @@ -173,11 +173,8 @@ BlockVector::operator= (const TrilinosWrappers::BlockVector &v) template void BlockVector::swap (BlockVector &v) { - Assert (this->n_blocks() == v.n_blocks(), - ExcDimensionMismatch(this->n_blocks(), v.n_blocks())); + std::swap(this->components, v.components); - for (size_type i=0; in_blocks(); ++i) - dealii::swap (this->components[i], v.components[i]); dealii::swap (this->block_indices, v.block_indices); } -- 2.39.5