Skip to content

Add support for (dune-functions) prefix resizing

Summary

When using ISTL blocked vectors for entity blocking, I came across the issue that the ordering was not able to provide individual sizes for each entity.

  • Tag dispatched resize methods using the virtual interface of the ordering. This was not suitable for local ordering resizing.
  • The ordering tree structure does not map directly to the container blocking, which makes it difficult to make resize based on its tree structure.
  • dune-functions method of resizing is much more flexible and more intuitive than tag dispatched resizing.

Proposal

Use the dune-functions approach. That is, provide the ordering with a function size(MultiIndex) to which we pass a partial path (i.e. prefix) to the container and it should return the size for such path. In the dune-functions jargon, the ordering would be the size provider. Once this is possible, we are able to reuse dune-functions algorithms for ISTL backends...

// assume the following blocking
auto b = BlockVector<BlockVector<FieldVector<double,1>>>{};
auto prefix = MultiIndex<std::size_t,1>{}; // -> {}
auto base_size = gfs.ordering().size(predix); // get size of first level blocking
b.resize(base_size);

prefix.push_back(0); // -> {0}
for (std::size_t i = 0; i < base_size; ++i) {
  prefix.back() = i; // -> {i}
  auto block_size_i = gfs.ordering().size(prefix); // get size for block i
  b[i].resize(block_size_i);
}

...or, this could be done recursively with the dune-functions implementation:

auto b = BlockVector<BlockVector<FieldVector<double,1>>>{};
auto backend = Functions::istlVectorBackend(b);
backend.resize(gfs.ordering()); // calls size on ordering recursively

Disclaimer

  • I only tested dynamic entity booking for a two nested block vector BlockVector<BlockVector<FieldVector<double,1>>> so far.
  • The dune-functions grid function spaces are yet not adapted, but I assume that this is trivially feasibly since no complex trees used yet. DONE
Edited by Santiago Ospina De Los Ríos

Merge request reports