From ecc86d92d03882255696ee5cb94171dfe10d4219 Mon Sep 17 00:00:00 2001
From: Elias Pipping <elias.pipping@fu-berlin.de>
Date: Tue, 29 Jan 2013 11:01:30 +0100
Subject: [PATCH] Add indices before computing A+B

---
 src/timestepping.cc | 9 +++++++--
 1 file changed, 7 insertions(+), 2 deletions(-)

diff --git a/src/timestepping.cc b/src/timestepping.cc
index 9b46235d..07d1bf41 100644
--- a/src/timestepping.cc
+++ b/src/timestepping.cc
@@ -2,6 +2,7 @@
 #include "config.h"
 #endif
 
+#include <dune/istl/matrixindexset.hh>
 #include <dune/fufem/arithmetic.hh>
 #include "timestepping.hh"
 
@@ -262,8 +263,12 @@ void Newmark<VectorType, MatrixType, FunctionType, dim>::setup(
   A.usmv(-tau / 2.0, ud_old, problem_rhs);
 
   // For fixed tau, we'd only really have to do this once
-  problem_A = A;
-  problem_A *= tau / 2.0;
+  Dune::MatrixIndexSet indices(A.N(), A.M());
+  indices.import(A);
+  indices.import(B);
+  indices.exportIdx(problem_A);
+  problem_A = 0.0;
+  Arithmetic::addProduct(problem_A, tau / 2.0, A);
   Arithmetic::addProduct(problem_A, 2.0 / tau, B);
 
   // ud_old makes a good initial iterate; we could use anything, though
-- 
GitLab