From: Matthias Maier Date: Mon, 4 May 2015 08:30:48 +0000 (+0200) Subject: Bugfix: Implement PETScWrappers::BlockVector::swap for different block sizes X-Git-Tag: v8.3.0-rc1~202^2~4 X-Git-Url: https://gitweb.dealii.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=a837cff172ea40378ecd90f4d538036b527bedfd;p=dealii.git Bugfix: Implement PETScWrappers::BlockVector::swap for different block sizes --- 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);