AMDiS 2.11-git
The Adaptive Multi-Dimensional Simulation Toolbox
 
Loading...
Searching...
No Matches
BlockedPreBasis.hpp
1#pragma once
2
3#include <dune/common/indices.hh>
4#include <dune/functions/functionspacebases/basistags.hh>
5#include <dune/functions/functionspacebases/compositebasis.hh>
6#include <dune/functions/functionspacebases/dynamicpowerbasis.hh>
7#include <dune/functions/functionspacebases/powerbasis.hh>
8
9#include <amdis/functions/FlatPreBasis.hpp>
10
11namespace AMDiS
12{
15
28 template <class PreBasis>
30 {
31 using type = PreBasis;
32
33 template <class PB>
34 static type create(PB const& preBasis)
35 {
36 return {preBasis.gridView()};
37 }
38
40 static PreBasis const& create(PreBasis const& preBasis)
41 {
42 return preBasis;
43 }
44 };
45
47 template <class PreBasis>
48 using BlockedPreBasis_t = typename BlockedPreBasis<PreBasis>::type;
49
51 template <class PreBasis>
52 decltype(auto) blockedPreBasis(PreBasis const& preBasis)
53 {
54 return BlockedPreBasis<PreBasis>::create(preBasis);
55 }
56
57
59 template <class IMS>
61 {
62 using type = IMS;
63 };
64
65 // specialization for FlatInterleaved
66 template <>
67 struct BlockedIndexMergingStrategy<Dune::Functions::BasisFactory::FlatInterleaved>
68 {
69 using type = Dune::Functions::BasisFactory::BlockedInterleaved;
70 };
71
72 // specialization for FlatLexicographic
73 template <>
74 struct BlockedIndexMergingStrategy<Dune::Functions::BasisFactory::FlatLexicographic>
75 {
76 using type = Dune::Functions::BasisFactory::BlockedLexicographic;
77 };
78
79
80 template <class IMS, class... SPB>
81 struct BlockedPreBasis<Dune::Functions::CompositePreBasis<IMS, SPB...>>
82 {
83 using BIMS = Dune::Functions::BasisFactory::BlockedLexicographic;
84 using type = Dune::Functions::CompositePreBasis<BIMS, FlatPreBasis_t<SPB>...>;
85
86 template <class PreBasis>
87 static type create(PreBasis const& preBasis)
88 {
89 return create(preBasis, std::index_sequence_for<SPB...>{});
90 }
91
92 template <class PreBasis, std::size_t... I>
93 static type create(PreBasis const& preBasis, std::index_sequence<I...>)
94 {
95 return {FlatPreBasis<SPB>::create(preBasis.subPreBasis(Dune::index_constant<I>{}))...};
96 }
97 };
98
99 template <class IMS, class SPB, std::size_t C>
100 struct BlockedPreBasis<Dune::Functions::PowerPreBasis<IMS, SPB, C>>
101 {
102 using BIMS = typename BlockedIndexMergingStrategy<IMS>::type;
103 using type = Dune::Functions::PowerPreBasis<BIMS, FlatPreBasis_t<SPB>, C>;
104
105 template <class PreBasis>
106 static type create(PreBasis const& preBasis)
107 {
108 return {FlatPreBasis<SPB>::create(preBasis.subPreBasis())};
109 }
110 };
111
112 template <class IMS, class SPB>
113 struct BlockedPreBasis<Dune::Functions::DynamicPowerPreBasis<IMS, SPB>>
114 {
115 using BIMS = typename BlockedIndexMergingStrategy<IMS>::type;
116 using type = Dune::Functions::DynamicPowerPreBasis<BIMS, FlatPreBasis_t<SPB>>;
117
118 template <class PreBasis>
119 static type create(PreBasis const& preBasis)
120 {
121 return {FlatPreBasis<SPB>::create(preBasis.subPreBasis())};
122 }
123 };
124
125} // end namespace AMDiS
Define the blocked index-merging strategy for a given strategy IMS
Definition BlockedPreBasis.hpp:61
Transform a PreBasis into one with an outer-level blocked index-merging strategy and all inner nodes ...
Definition BlockedPreBasis.hpp:30
static PreBasis const & create(PreBasis const &preBasis)
Do not transform the preBasis if already blocked.
Definition BlockedPreBasis.hpp:40
static type create(PB const &preBasis)
Try to construct the pre-basis using a gridView.
Definition FlatPreBasis.hpp:31