From 9cc4c6e8a4be9354d258a06b3b8ec677a527f52c Mon Sep 17 00:00:00 2001
From: Christian Engwer <christi@dune-project.org>
Date: Fri, 27 Nov 2015 22:26:17 +0100
Subject: [PATCH] [bugfix] fix broken assertion.
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

This patch fixes the errornous commits
e8d163848555c4ec74843a8d762ca71495633c04
1a2f4d0fdb07c3724ed972394fafd7da3aee7ac7

The introduced range checks were plain wring, as they neglected the nested structure of the
BlockVector. We now use `b.dim()` to get the flat size.

This fixes flyspray/FS#1724.
(cherry picked from commit 3aed940e84dbb4478f93375b8b2dcfffafca4600)

Signed-off-by: Steffen Müthing <muething@dune-project.org>
---
 dune/istl/superlu.hh | 8 ++++----
 dune/istl/umfpack.hh | 4 ++--
 2 files changed, 6 insertions(+), 6 deletions(-)

diff --git a/dune/istl/superlu.hh b/dune/istl/superlu.hh
index fb780d998..1aeeb885c 100644
--- a/dune/istl/superlu.hh
+++ b/dune/istl/superlu.hh
@@ -561,11 +561,11 @@ namespace Dune
   void SuperLU<BCRSMatrix<FieldMatrix<T,n,m>,A> >
   ::apply(domain_type& x, range_type& b, InverseOperatorResult& res)
   {
-    if (mat.N() != b.size())
+    if (mat.N() != b.dim())
       DUNE_THROW(ISTLError, "Size of right-hand-side vector b does not match the number of matrix rows!");
-    if (mat.M() != x.size())
+    if (mat.M() != x.dim())
       DUNE_THROW(ISTLError, "Size of solution vector x does not match the number of matrix columns!");
-    if(mat.M()+mat.N()==0)
+    if (mat.M()+mat.N()==0)
       DUNE_THROW(ISTLError, "Matrix of SuperLU is null!");
 
     SuperMatrix* mB = &B;
@@ -577,7 +577,7 @@ namespace Dune
         SuperLUDenseMatChooser<T>::create(&X, (int)mat.N(), 1,  reinterpret_cast<T*>(&x[0]), (int)mat.N(), SLU_DN, GetSuperLUType<T>::type, SLU_GE);
         first=false;
       }else{
-        ((DNformat*) B.Store)->nzval=&b[0];
+        ((DNformat*)B.Store)->nzval=&b[0];
         ((DNformat*)X.Store)->nzval=&x[0];
       }
     } else {
diff --git a/dune/istl/umfpack.hh b/dune/istl/umfpack.hh
index 6c4860835..c97661c1e 100644
--- a/dune/istl/umfpack.hh
+++ b/dune/istl/umfpack.hh
@@ -320,9 +320,9 @@ namespace Dune {
      */
     virtual void apply(domain_type& x, range_type& b, InverseOperatorResult& res)
     {
-      if (umfpackMatrix_.N() != b.size())
+      if (umfpackMatrix_.N() != b.dim())
         DUNE_THROW(Dune::ISTLError, "Size of right-hand-side vector b does not match the number of matrix rows!");
-      if (umfpackMatrix_.M() != x.size())
+      if (umfpackMatrix_.M() != x.dim())
         DUNE_THROW(Dune::ISTLError, "Size of solution vector x does not match the number of matrix columns!");
 
       double UMF_Apply_Info[UMFPACK_INFO];
-- 
GitLab