]> https://gitweb.dealii.org/ - dealii-svn.git/commitdiff
fix bug in ConstraintMatrix::set_zero
authorheister <heister@0785d39b-7218-0410-832d-ea1e28bc413d>
Sun, 7 Jul 2013 15:47:02 +0000 (15:47 +0000)
committerheister <heister@0785d39b-7218-0410-832d-ea1e28bc413d>
Sun, 7 Jul 2013 15:47:02 +0000 (15:47 +0000)
git-svn-id: https://svn.dealii.org/trunk@29940 0785d39b-7218-0410-832d-ea1e28bc413d

deal.II/include/deal.II/lac/constraint_matrix.templates.h

index 397be1b7cc4958975eb21b9c93b251155f74da09..a8c1d393c1bd8cc95e8d5edaf89c1578899446bb 100644 (file)
@@ -738,12 +738,22 @@ namespace internal
       template<class VEC>
       void set_zero_parallel(const std::vector<size_type> &cm, VEC &vec, size_type shift = 0)
       {
-        Assert(!vec.has_ghost_elements(), ExcInternalError());//ExcGhostsPresent());
+        Assert(!vec.has_ghost_elements(), ExcInternalError());
         IndexSet locally_owned = vec.locally_owned_elements();
         for (typename std::vector<size_type>::const_iterator it = cm.begin();
              it != cm.end(); ++it)
-          if (locally_owned.is_element(*it))
-            vec(*it) = 0.;
+          {
+            // If shift>0 then we are working on a part of a BlockVector
+            // so vec(i) is actually the global entry i+shift.
+            // We first make sure the line falls into the range of vec,
+            // then check if is part of the local part of the vector, before
+            // finally setting it to 0.
+            if ((*it)<shift)
+              continue;
+            size_type idx = *it - shift;
+            if (idx<vec.size() && locally_owned.is_element(idx))
+              vec(idx) = 0.;
+          }
       }
 
       template<typename Number>

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.