Skip to content

Use integer based multi-domain grid

When checking out the data structures of dune-multidomaingrid, I just realized that it turns out that using an integer based (used as bitset) storage of the multi-domain indices is more efficient than an array based. That's not very clear from the traits definition at first:

  • Currently, we have a Dune::mdgrid::DynamicSubDomainCountTraits<dim, max_overlap> which allows for an arbitrary number of sub-domains but at maximum max_overlap entities can be overlapping (including vertices). This is set to max_overlap = 10 currently. The data structure of the overlapping domain indices ends up in something like an std::array<int, max_overlap> per host entity. An access to the sub-domain index thus turns out on an memory stride of max_overlap * sizeof(int). That's not ideal.
  • On the other hand switching to Dune::mdgrid::FewSubDomainsTraits<dim, 64> turns storage into a uint64_t per host entity where each sub-domain index is stored in one of the 64 bits of the uint64_t. The stride would now be sizeof(uint64_t) at the expense of having an index extraction that needs boolean operations and the maximum number of sub-domains to be 64.

This needs some bench-marking to see if it actually matters at the end of the day.

Edited by Santiago Ospina De Los Ríos

Merge request reports