]> https://gitweb.dealii.org/ - dealii.git/commitdiff
Bugfix: Implement BlockVector<number>::swap for different block sizes
authorMatthias Maier <tamiko@43-1.org>
Mon, 4 May 2015 07:36:52 +0000 (09:36 +0200)
committerMatthias Maier <tamiko@43-1.org>
Mon, 4 May 2015 11:46:24 +0000 (13:46 +0200)
include/deal.II/lac/block_vector.h
include/deal.II/lac/block_vector.templates.h

index 6b1ac989cf3de446b3de521d3cf8a0e47de472f4..95e7bbf2d3b3dbf9ea11046c13b07cfe30862ecb 100644 (file)
@@ -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
    * <tt>u.swap(v)</tt>, again in analogy to standard functions.
@@ -433,6 +429,7 @@ BlockVector<Number> &
 BlockVector<Number>::operator= (BlockVector<Number> &&v)
 {
   swap(v);
+
   // be nice and reset v to zero
   v.reinit(0, 0, false);
 
index abdb94e7e067df185d9339f5f91b354c7abffb37..d873067e551e448326743c66fb2684b397793e76 100644 (file)
@@ -173,11 +173,8 @@ BlockVector<Number>::operator= (const TrilinosWrappers::BlockVector &v)
 template <typename Number>
 void BlockVector<Number>::swap (BlockVector<Number> &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; i<this->n_blocks(); ++i)
-    dealii::swap (this->components[i], v.components[i]);
   dealii::swap (this->block_indices, v.block_indices);
 }
 

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.