From: wolf <wolf@0785d39b-7218-0410-832d-ea1e28bc413d>
Date: Tue, 16 Mar 2004 20:18:01 +0000 (+0000)
Subject: Avoid excessive accesses to vector elements, since this really grinds PETSc to
X-Git-Url: https://gitweb.dealii.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=9832ec3d0672d674e7ef212e93f7f2f5f9fbe06b;p=dealii-svn.git

Avoid excessive accesses to vector elements, since this really grinds PETSc to
a halt. Don't know what I thought of this code in the first place anyhow...


git-svn-id: https://svn.dealii.org/trunk@8789 0785d39b-7218-0410-832d-ea1e28bc413d
---

diff --git a/deal.II/deal.II/include/dofs/dof_constraints.templates.h b/deal.II/deal.II/include/dofs/dof_constraints.templates.h
index f32ee76c44..d32a004c7b 100644
--- a/deal.II/deal.II/include/dofs/dof_constraints.templates.h
+++ b/deal.II/deal.II/include/dofs/dof_constraints.templates.h
@@ -906,16 +906,15 @@ ConstraintMatrix::distribute (VectorType &vec) const
   std::vector<ConstraintLine>::const_iterator next_constraint = lines.begin();
   for (; next_constraint != lines.end(); ++next_constraint) 
     {
-				       // make entry in line
-				       // next_constraint.line first
-				       // set it to zero
-      vec(next_constraint->line) = 0.;
-				       // then add the different
-				       // contributions
+				       // fill entry in line
+				       // next_constraint.line by adding the
+				       // different contributions
+      double new_value = 0;
       for (unsigned int i=0; i<next_constraint->entries.size(); ++i)
-	vec(next_constraint->line) += (vec(next_constraint->entries[i].first) *
-				       next_constraint->entries[i].second);
-    };
+	new_value += (vec(next_constraint->entries[i].first) *
+                      next_constraint->entries[i].second);
+      vec(next_constraint->line) = new_value;
+    }
 }