From 63e7bfa2af02cb33527ec3d422aac492c168d8f4 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Carsten=20Gr=C3=A4ser?= <graeser@mi.fu-berlin.de>
Date: Wed, 19 Oct 2016 21:56:22 +0000
Subject: [PATCH] Merge branch 'feature/fix-implicit-buildmode-doc' into
 'master'

Fix implicit buildmode documentation and adjust test accordingly

This basically turns the issue #21 into a feature by correctly describing the constraints of the implicit build mode and the meaning of its parameters. This invalidates the test against the old interface description which is hence dropped by this MR. As a consequence the bcrsimplicitbuild-test passes again.

See merge request !63
---
 dune/istl/bcrsmatrix.hh             | 25 ++++++++++++++++++-------
 dune/istl/test/bcrsimplicitbuild.cc | 19 -------------------
 2 files changed, 18 insertions(+), 26 deletions(-)

diff --git a/dune/istl/bcrsmatrix.hh b/dune/istl/bcrsmatrix.hh
index 727c83325..bbaf1726d 100644
--- a/dune/istl/bcrsmatrix.hh
+++ b/dune/istl/bcrsmatrix.hh
@@ -327,17 +327,27 @@ namespace Dune {
      \endcode
 
      3. implicit scheme
+
      With the above Random Scheme, the sparsity pattern has to be determined
      and stored before the matrix is assembled. This leads to increased memory
      usage and computation time. Often, one has good a priori
      knowledge about the number of entries a row contains on average. `implicit`
      mode tries to make use of that knowledge by allocating memory based on
-     that average. Entries in rows with more non-zeroes than the average value
-     are written to an overflow area during the initial assembly phase, up to a
-     specified maximum number of overflow entries that must not be exceeded.
+     that average. If a row contains more non-zeroes than the average value
+     these are stored in an auxiliary buffer during the initial assembly phase.
      After all indices are added a compression step optimizes the matrix and
-     integrates any entries from the overflow area into the standard BCRS storage
-     scheme.
+     integrates any entries from the buffer into the standard BCRS storage
+     making use of an optional overflow area to allow rows exceeding the
+     average non-zero count. More precisely, if \f$\textrm{nnz}_j\f$ denotes the
+     number of non-zeros in the \f$j\f$-th row, then the maximal number of
+     allowed non-zeros in the \f$i\f$-th row is
+     \f[
+        M_i = \textrm{avg} + A + \sum_{j<i} (\textrm{avg} - \textrm{nnz}_j)
+     \f]
+     where
+     \f$ A = \textrm{avg}(n \cdot \textrm{overflowsize} +4) \f$
+     is the total size of the overflow area determined by the parameters
+     explained below.
 
      To use this mode use the following methods:
 
@@ -349,8 +359,9 @@ namespace Dune {
      Here, the parameter `_avg` denotes the average number of matrix entries per row, while
      `_overflowsize` reserves `_n * _overflowsize * _avg` entries in the overflow area.
 
-     \warning If you exceed this number of overflow entries during the assembly phase, matrix
-              construction fails and an exception will be thrown!
+     \warning If the overflow area is exhausted during the compression step,
+              i.e., if the assertion \f$\textrm{nnz}_i \leq M_i\f$ is not matched,
+              an exception will be thrown during compress().
 
      Start filling your matrix by calling entry(size_type row, size_type col),
      which returns the corresponding matrix entry, creating it on the fly if
diff --git a/dune/istl/test/bcrsimplicitbuild.cc b/dune/istl/test/bcrsimplicitbuild.cc
index 0b74016e5..e53e3140b 100644
--- a/dune/istl/test/bcrsimplicitbuild.cc
+++ b/dune/istl/test/bcrsimplicitbuild.cc
@@ -331,24 +331,6 @@ void testImplicitMatrixBuilderExtendedConstructor()
   setMatrix(m);
 }
 
-
-void testAverageStorage()
-{
-  using M = Dune::BCRSMatrix<Dune::FieldMatrix<double,1,1>>;
-  for(auto j : {5, 0})
-  {
-    std::cout << j << std::endl;
-    M m(6, 6, 1, 0.0, M::implicit);
-
-    for(std::size_t i=0; i<6; ++i)
-      m.entry(j,i) = i;
-
-    m.compress();
-  }
-}
-
-
-
 int main()
 {
   int ret=0;
@@ -371,7 +353,6 @@ int main()
     ret+=testConstBracketOperatorBeforeCompress();
     testImplicitMatrixBuilder();
     testImplicitMatrixBuilderExtendedConstructor();
-    testAverageStorage();
   }catch(Dune::Exception& e) {
     std::cerr << e <<std::endl;
     return 1;
-- 
GitLab