Skip to content

Add factory for container descriptors specialized for different pre-basis types

Simon Praetorius requested to merge feature/container-descriptor-bases into master

Summary

This MR implements the first step towards container descriptors for dune-functions bases. The descriptors for leaf bases and for power/composite bases with blocked-lexicographic IMS is provided. All other cases return a ContainerDescriptors::Unknown tag, indicating: not implemented.

Design

The container descriptors of a pre-basis can be obtained by calling preBasis.containerDescriptor() and by using the factory method

template <class PreBasis>
auto constainerDescriptor(const PreBasis& preBasis)
{
  if constexpr (/* preBasis implements .containerDescriptor() */)
    return preBasis.containerDescriptor();
  else
    return ContainerDescriptors::Unknown{};
}

with a fallback to ContainerDescriptors::Unknown in case the pre-basis does not provide a definition.

Specializations for leaf pre-bases in dune-functions are provided. Additionally, in this MR the specialization for composie/power/dynamic-power pre-basis with blocked-lexicographic index-merging strategy is implemented. In follow-up MRs the other index-merging strategy specializations will be added.

Example

using namespace Dune::Functions;
using namespace Dune::Functions::BasisFactory;
namespace CD = Dune::Functions::ContainerDescriptors;

auto basis1 = makeBasis(gridView, power<2>(lagrange<1>(), blockedLexicographic()));
auto descriptor1 = containerDescriptor(basis1.preBasis());
  // -> CD::UniformArray<CD::FlatVector,2>

auto basis2 = makeBasis(gridView, 
  composite(power<3>(lagrange<2>(),blockedLexicographic()), lagrange<1>(), blockedLexicographic()));
auto descriptor2 = containerDescriptor(basis2.preBasis());
  // -> CD::Tuple<CD::UniformArray<CD::FlatVector,2>,CD::FlatVector>

auto basis3 = makeBasis(gridView, power<2>(lagrange<1>(), flatInterleaved()));
auto descriptor3 = containerDescriptor(basis3.preBasis());
  // -> CD::Unknown

Changes

  • Each pre-basis gets a new member-function containerDescriptor() const returning a type from the namespace ContainerDescriptors.
  • The GenericIndexingTransformation is parametrized additionally with a ContainerDescriptorImplementation, i.e. a callable returning the container-descriptor associated to the pre-basis after index transformation. This callable is passed as additional last constructor argument. The factory function indexTransformation also gets an additional parameter, but for backwards-compatibility, there is an overload that just returns ContainerDescriptor::Unkown if nothing is provided.
Edited by Simon Praetorius

Merge request reports

Loading