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 maximummax_overlap
entities can be overlapping (including vertices). This is set tomax_overlap = 10
currently. The data structure of the overlapping domain indices ends up in something like anstd::array<int, max_overlap>
per host entity. An access to the sub-domain index thus turns out on an memory stride ofmax_overlap * sizeof(int)
. That's not ideal. - On the other hand switching to
Dune::mdgrid::FewSubDomainsTraits<dim, 64>
turns storage into auint64_t
per host entity where each sub-domain index is stored in one of the 64 bits of theuint64_t
. The stride would now besizeof(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