[Dune-devel] New experimental BCRSMatrix in DUNE

Santiago Ospina De Los Ríos sospinar at gmail.com
Tue Oct 13 08:52:50 CEST 2026


Dear DUNE developers,


I would like to draw your attention to a newly introduced experimental 
|BCRSMatrix| which can be found in the development branch of dune-istl 
under the Dune::Experimental namespace (as decided in our last 
development meeting). The main motivation is that this matrix should be 
faster on memory bound problems due to its reduced memory requirements.


The main improvements over our current |BCRSMatrix| version are:

  * Column indices can be chosen at compile time, with a default of
    |uint32| which saves about 25% of memory usage on flat matrices.
  * Row offsets are now part of the shared pattern, and are now stored
    more compactly.
  * Sparse patterns are now an external class with a slim interface for
    general patterns, allowing the pattern to be shared with other
    classes, e.g. for mixed-precision algorithms, and to simplify
    implementation of dense, banded, and diagonal matrices.
  * There are two separate builder classes for sparse pattern creation,
    making the matrix itself much smaller, which is important for
    sparse-sparse matrices.
  * These sparse pattern builders have proper buffer growth and
    compression, removing the need of the overflow map or scattered
    memory allocations.
  * Full support of move semantics with much better exception guarantees.
  * Full support of stateful allocators, even on move and swap operations.
  * Follows the /AllocatorAwareContainer/
    <https://en.cppreference.com/cpp/named_req/AllocatorAwareContainer>
    named requirement from the standard library, thus propagating
    allocators to its stored objects.

It is designed to be an almost drop-in replacement of |BCRSMatrix| with 
a few caveats that are usually easy to modify:

  * Rows are proxy objects that are generated on-the-fly, this means
    that they cannot be bound to non-const references.
  * Row and const row iterators are different, respecting const
    correctness. This may cause some issues in code that used the
    relaxed const correctness guarantees of the current |BCRMatrix|
    iterators.
  * The matrix does not store any values during the patter
    formation. Hence, in the case of implicit build mode, only default
    initialized blocks are accepted. For instance, this currently
    affects ILU(t) when t != 0.
  * The row-wise build mode has different begin and end iterator types.
  * The |setSize()| method should be used /after/ selecting the build
    mode and /before/ the pattern construction is finalized.
  * The |N()| and |M()| methods are not available during the pattern
    construction.
  * The build mode becomes |BuildMode::unknown| after the pattern is
    built, meaning that it needs to be reset before constructing a new
    pattern.
  * Setting a build mode cleans up the matrix.
  * There is no |BuildStage| and their related functions.
  * There is no one-before iterators as they would be undefined behavior
    (see dune-common#430
    <https://gitlab.dune-project.org/core/dune-common/-/work_items/430>).


If you try it out and find issues, please report them by opening an 
issue in our GitLab or (equivalently) by sending an email to dune-istl 
at dune-project.org.


Happy coding!

Santiago

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.dune-project.org/pipermail/dune-devel/attachments/20261013/d732602e/attachment.htm>


More information about the Dune-devel mailing list