From a837cff172ea40378ecd90f4d538036b527bedfd Mon Sep 17 00:00:00 2001 From: Matthias Maier Date: Mon, 4 May 2015 10:30:48 +0200 Subject: [PATCH] Bugfix: Implement PETScWrappers::BlockVector::swap for different block sizes --- include/deal.II/lac/petsc_parallel_block_vector.h | 5 +---- source/lac/petsc_parallel_block_vector.cc | 8 +++++--- 2 files changed, 6 insertions(+), 7 deletions(-) diff --git a/include/deal.II/lac/petsc_parallel_block_vector.h b/include/deal.II/lac/petsc_parallel_block_vector.h index 5294689154..24b435a984 100644 --- a/include/deal.II/lac/petsc_parallel_block_vector.h +++ b/include/deal.II/lac/petsc_parallel_block_vector.h @@ -531,11 +531,8 @@ namespace PETScWrappers 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 (unsigned int i=0; in_blocks(); ++i) - this->components[i].swap (v.components[i]); ::dealii::swap (this->block_indices, v.block_indices); } diff --git a/source/lac/petsc_parallel_block_vector.cc b/source/lac/petsc_parallel_block_vector.cc index 21d8ee066a..5c66680de4 100644 --- a/source/lac/petsc_parallel_block_vector.cc +++ b/source/lac/petsc_parallel_block_vector.cc @@ -1,6 +1,6 @@ // --------------------------------------------------------------------- // -// Copyright (C) 2004 - 2014 by the deal.II authors +// Copyright (C) 2004 - 2015 by the deal.II authors // // This file is part of the deal.II library. // @@ -30,8 +30,10 @@ namespace PETScWrappers BlockVector & BlockVector::operator = (const PETScWrappers::BlockVector &v) { - Assert (v.get_block_indices() == this->get_block_indices(), - ExcNonMatchingBlockVectors()); + this->block_indices = v.get_block_indices(); + + if (this->components.size() != this->n_blocks()) + this->components.resize(this->n_blocks()); for (unsigned int i=0; in_blocks(); ++i) this->block(i) = v.block(i); -- 2.39.5