Skip to content

Feature/hybrid local blocks

Martin Nolte requested to merge feature/hybrid-local-blocks into master

For DG spaces, there is only one block per element. This fact allows using an ISTL BlockVector / BCRSMatrix. We can, however, add more static structure to the local block if we replace the for loops like

for( int i = 0; i < localBlockSize; ++i )
  doSomething( i );

by a Hybrid::forEach statement:

Hybrid::forEach( LocalBlockIndices(), [] ( auto &&i ) { doSomething( i ); }

This loop can mimic both, dynamic for loops (as are currently used) and static ones. Especially, i need no longer be an integer or even the same type for every local index. We can, for example, use std::pair< integral_constant< 0 >, int > and std::pair< std::integral_constant< 1 >, int >, which allows us to address an ISTL MultiTypeBlockVector.

That's the basic idea of this MR. It consists of four basic blocks:

  1. Add index ranges allowing for statical nesting (dune/fem/common/hybrid.hh).
  2. Interface change: Replace localBlockSize by LocalBlockIndices and use Hybrid::forEach instead of a plain for loop.
  3. Add a HierarchicalDiscreteFunction wrapping the MultiTypeBlockVector as sketched above.
  4. Add a HierarchicalLinearOperator wrapping the MultiTypeBlockMatrix as sketched above.

Notice that interface changes do not affect the user. All spaces / functions still provide localBlockSize / blockSize and the local indices pass to the functor in a Hybrid::foreach still convert silently to an integer. Developers, however, are affected by this change. All discrete function spaces and discrete functions outside of dune-fem have to be adapted to provide block indices instead of a block size. Moreover, for forward compatibility, all for loops up to the local block size should be converted to Hybrid::forEach statements.

On the upside, this patch allows assembling the four big block matrices of a Stokes system in a single grid traversal. Even the assembly code does not change (except: The HierarchicLinearOperator does not provide a local matrix - use a TemporaryLocalMatrix).

Merge request reports

Loading