AMDiS 2.11-git
The Adaptive Multi-Dimensional Simulation Toolbox
 
Loading...
Searching...
No Matches
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/dynamicpowerbasis.hh>
6#include <dune/functions/functionspacebases/powerbasis.hh>
7
8#include <amdis/Output.hpp>
9
10namespace AMDiS
11{
13
24 template <class PreBasis>
26 {
27 using type = PreBasis;
28
30 template <class PB>
31 static type create(PB const& preBasis)
32 {
33 return {preBasis.gridView()};
34 }
35
37 static PreBasis const& create(PreBasis const& preBasis)
38 {
39 return preBasis;
40 }
41 };
42
44 template <class PreBasis>
45 using FlatPreBasis_t = typename FlatPreBasis<PreBasis>::type;
46
48 template <class PreBasis>
49 decltype(auto) flatPreBasis(PreBasis const& preBasis)
50 {
51 return FlatPreBasis<PreBasis>::create(preBasis);
52 }
53
54
56 template <class IMS>
58 {
59 using type = IMS;
60 };
61
62 // specialization for BlockedInterleaved
63 template <>
64 struct FlatIndexMergingStrategy<Dune::Functions::BasisFactory::BlockedInterleaved>
65 {
66 using type = Dune::Functions::BasisFactory::FlatInterleaved;
67 };
68
69 // specialization for BlockedLexicographic
70 template <>
71 struct FlatIndexMergingStrategy<Dune::Functions::BasisFactory::BlockedLexicographic>
72 {
73 using type = Dune::Functions::BasisFactory::FlatLexicographic;
74 };
75
76 // specialization for composite bases
77 template <class IMS, class... SPB>
78 struct FlatPreBasis<Dune::Functions::CompositePreBasis<IMS, SPB...>>
79 {
80 using FIMS = typename FlatIndexMergingStrategy<IMS>::type;
81 using type = Dune::Functions::CompositePreBasis<FIMS, FlatPreBasis_t<SPB>...>;
82
83 template <class PreBasis>
84 static type create(PreBasis const& preBasis)
85 {
86 return create(preBasis, std::index_sequence_for<SPB...>{});
87 }
88
89 template <class PreBasis, std::size_t... I>
90 static type create(PreBasis const& preBasis, std::index_sequence<I...>)
91 {
92 test_warning(std::is_same_v<IMS,FIMS>, "Basis converted into flat index-merging strategy.");
93 return {FlatPreBasis<SPB>::create(preBasis.subPreBasis(Dune::index_constant<I>{}))...};
94 }
95 };
96
97 // specialization for power bases
98 template <class IMS, class SPB, std::size_t C>
99 struct FlatPreBasis<Dune::Functions::PowerPreBasis<IMS, SPB, C>>
100 {
101 using FIMS = typename FlatIndexMergingStrategy<IMS>::type;
102 using type = Dune::Functions::PowerPreBasis<FIMS, FlatPreBasis_t<SPB>, C>;
103
104 template <class PreBasis>
105 static type create(PreBasis const& preBasis)
106 {
107 test_warning(std::is_same_v<IMS,FIMS>, "Basis converted into flat index-merging strategy.");
108 return type{FlatPreBasis<SPB>::create(preBasis.subPreBasis())};
109 }
110 };
111
112 // specialization for power bases
113 template <class IMS, class SPB>
114 struct FlatPreBasis<Dune::Functions::DynamicPowerPreBasis<IMS, SPB>>
115 {
116 using FIMS = typename FlatIndexMergingStrategy<IMS>::type;
117 using type = Dune::Functions::DynamicPowerPreBasis<FIMS, FlatPreBasis_t<SPB>>;
118
119 template <class PreBasis>
120 static type create(PreBasis const& preBasis)
121 {
122 test_warning(std::is_same_v<IMS,FIMS>, "Basis converted into flat index-merging strategy.");
123 return type{preBasis.children(),FlatPreBasis<SPB>::create(preBasis.subPreBasis())};
124 }
125 };
126
127} // end namespace AMDiS
Define the flat index-merging strategy for a given strategy IMS
Definition FlatPreBasis.hpp:58
Transform a PreBasis into one with flat index-merging strategy.
Definition FlatPreBasis.hpp:26
static PreBasis const & create(PreBasis const &preBasis)
Do not transform the preBasis if already flat.
Definition FlatPreBasis.hpp:37
static type create(PB const &preBasis)
Try to construct the pre-basis using a gridView.
Definition FlatPreBasis.hpp:31