]> https://gitweb.dealii.org/ - dealii.git/commitdiff
Bugfix: Implement PETScWrappers::BlockVector::swap for different block sizes
authorMatthias Maier <tamiko@43-1.org>
Mon, 4 May 2015 08:30:48 +0000 (10:30 +0200)
committerMatthias Maier <tamiko@43-1.org>
Mon, 4 May 2015 11:46:25 +0000 (13:46 +0200)
include/deal.II/lac/petsc_parallel_block_vector.h
source/lac/petsc_parallel_block_vector.cc

index 5294689154dfabcacc752302f5cd1956484cecec..24b435a98441755cc9c6d7213cc0b129596ccf91 100644 (file)
@@ -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; i<this->n_blocks(); ++i)
-        this->components[i].swap (v.components[i]);
       ::dealii::swap (this->block_indices, v.block_indices);
     }
 
index 21d8ee066a2c01b55ec7a590f46ffc3959b73643..5c66680de4f38950865e66a300c27bcb44a2358a 100644 (file)
@@ -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; i<this->n_blocks(); ++i)
         this->block(i) = v.block(i);

In the beginning the Universe was created. This has made a lot of people very angry and has been widely regarded as a bad move.

Douglas Adams


Typeset in Trocchi and Trocchi Bold Sans Serif.