]> https://gitweb.dealii.org/ - dealii-svn.git/commitdiff
PETSc/Trilinos BlockVectors now only allow assignment if destination is empty or...
authorheister <heister@0785d39b-7218-0410-832d-ea1e28bc413d>
Tue, 13 Aug 2013 19:58:15 +0000 (19:58 +0000)
committerheister <heister@0785d39b-7218-0410-832d-ea1e28bc413d>
Tue, 13 Aug 2013 19:58:15 +0000 (19:58 +0000)
git-svn-id: https://svn.dealii.org/trunk@30307 0785d39b-7218-0410-832d-ea1e28bc413d

deal.II/include/deal.II/lac/petsc_parallel_block_vector.h
deal.II/source/lac/trilinos_block_vector.cc

index f7e5a4f1dbc90653b945d87e80c3832cf0d31887..f55e61d5cc737bceb01d13d21e648bbfcee2742c 100644 (file)
@@ -441,17 +441,25 @@ namespace PETScWrappers
       return *this;
     }
 
-
-
     inline
     BlockVector &
     BlockVector::operator = (const BlockVector &v)
     {
-      BaseClass::operator = (v);
-      return *this;
-    }
+      // we only allow assignment to vectors with the same number of blocks
+      // or to an empty BlockVector
+      Assert (n_blocks() == 0 || n_blocks() == v.n_blocks(),
+          ExcDimensionMismatch(n_blocks(), v.n_blocks()));
 
+      if (this->n_blocks() != v.n_blocks())
+        reinit(v.n_blocks());
 
+      for (size_type i=0; i<this->n_blocks(); ++i)
+        this->components[i] = v.block(i);
+
+      collect_sizes();
+
+      return *this;
+    }
 
     inline
     BlockVector::~BlockVector ()
index b09660c23687e21e1fccd75363a4eab775f42346..7344ec1199ef9fab238dbe8ce28703d1f9e7a1f3 100644 (file)
@@ -59,6 +59,11 @@ namespace TrilinosWrappers
     BlockVector &
     BlockVector::operator = (const BlockVector &v)
     {
+      // we only allow assignment to vectors with the same number of blocks
+      // or to an empty BlockVector
+      Assert (n_blocks() == 0 || n_blocks() == v.n_blocks(),
+                    ExcDimensionMismatch(n_blocks(), v.n_blocks()));
+
       if (this->n_blocks() != v.n_blocks())
         reinit(v.n_blocks());
 

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.