AMDiS 2.10
The Adaptive Multi-Dimensional Simulation Toolbox
FlatPreBasis.hpp
1#pragma once
2
3#include <dune/functions/functionspacebases/basistags.hh>
4#include <dune/functions/functionspacebases/compositebasis.hh>
5#include <dune/functions/functionspacebases/powerbasis.hh>
6
7#include <amdis/Output.hpp>
8
9namespace AMDiS
10{
12
23 template <class PreBasis>
25 {
26 using type = PreBasis;
27
29 template <class PB>
30 static type create(PB const& preBasis)
31 {
32 return {preBasis.gridView()};
33 }
34
36 static PreBasis const& create(PreBasis const& preBasis)
37 {
38 return preBasis;
39 }
40 };
41
43 template <class PreBasis>
44 using FlatPreBasis_t = typename FlatPreBasis<PreBasis>::type;
45
47 template <class PreBasis>
48 decltype(auto) flatPreBasis(PreBasis const& preBasis)
49 {
50 return FlatPreBasis<PreBasis>::create(preBasis);
51 }
52
53
55 template <class IMS>
57 {
58 using type = IMS;
59 };
60
61 // specialization for BlockedInterleaved
62 template <>
63 struct FlatIndexMergingStrategy<Dune::Functions::BasisFactory::BlockedInterleaved>
64 {
65 using type = Dune::Functions::BasisFactory::FlatInterleaved;
66 };
67
68 // specialization for BlockedLexicographic
69 template <>
70 struct FlatIndexMergingStrategy<Dune::Functions::BasisFactory::BlockedLexicographic>
71 {
72 using type = Dune::Functions::BasisFactory::FlatLexicographic;
73 };
74
75 // specialization for composite bases
76 template <class IMS, class... SPB>
77 struct FlatPreBasis<Dune::Functions::CompositePreBasis<IMS, SPB...>>
78 {
79 using FIMS = typename FlatIndexMergingStrategy<IMS>::type;
80 using type = Dune::Functions::CompositePreBasis<FIMS, FlatPreBasis_t<SPB>...>;
81
82 template <class PreBasis>
83 static type create(PreBasis const& preBasis)
84 {
85 return create(preBasis, std::index_sequence_for<SPB...>{});
86 }
87
88 template <class PreBasis, std::size_t... I>
89 static type create(PreBasis const& preBasis, std::index_sequence<I...>)
90 {
91 test_warning(std::is_same_v<IMS,FIMS>, "Basis converted into flat index-merging strategy.");
92 return {FlatPreBasis<SPB>::create(preBasis.subPreBasis(Dune::index_constant<I>{}))...};
93 }
94 };
95
96 // specialization for power bases
97 template <class IMS, class SPB, std::size_t C>
98 struct FlatPreBasis<Dune::Functions::PowerPreBasis<IMS, SPB, C>>
99 {
100 using FIMS = typename FlatIndexMergingStrategy<IMS>::type;
101 using type = Dune::Functions::PowerPreBasis<FIMS, FlatPreBasis_t<SPB>, C>;
102
103 template <class PreBasis>
104 static type create(PreBasis const& preBasis)
105 {
106 test_warning(std::is_same_v<IMS,FIMS>, "Basis converted into flat index-merging strategy.");
107 return type{FlatPreBasis<SPB>::create(preBasis.subPreBasis())};
108 }
109 };
110
111} // end namespace AMDiS
Define the flat index-merging strategy for a given strategy IMS
Definition: FlatPreBasis.hpp:57
Transform a PreBasis into one with flat index-merging strategy.
Definition: FlatPreBasis.hpp:25
static PreBasis const & create(PreBasis const &preBasis)
Do not transform the preBasis if already flat.
Definition: FlatPreBasis.hpp:36
static type create(PB const &preBasis)
Try to construct the pre-basis using a gridView.
Definition: FlatPreBasis.hpp:30