dune-fem 2.8.0
Loading...
Searching...
No Matches
basisfunctionset/hpdg/anisotropic.hh
Go to the documentation of this file.
1#ifndef DUNE_FEM_HPDG_SPACE_BASISFUNCTIONSETS_ANISOTROPIC_HH
2#define DUNE_FEM_HPDG_SPACE_BASISFUNCTIONSETS_ANISOTROPIC_HH
3
4#include <cassert>
5#include <cstddef>
6
7#include <algorithm>
8#include <array>
9#include <tuple>
10#include <type_traits>
11#include <utility>
12
13#include <dune/common/fvector.hh>
14#include <dune/common/power.hh>
15
16#include <dune/geometry/type.hh>
17
18#include <dune/grid/common/capabilities.hh>
19
26
27#include "basisfunctionsets.hh"
28#include "legendre.hh"
29
30namespace Dune
31{
32
33 namespace Fem
34 {
35
36 namespace hpDG
37 {
38
39 // Internal forward declaration
40 // ----------------------------
41
42 template< class FunctionSpace, class GridPart, int maxOrder, class Storage >
44
45
46
47#ifndef DOXYGEN
48
49 // LegendreShapeFunctionSetTuple
50 // -----------------------------
51
52 template< class FunctionSpace, int order, class Storage >
53 class LegendreShapeFunctionSetTuple
54 {
55 // false == no hierarchical ordering
56 using FactoryType = LegendreShapeFunctionSets< typename Dune::Fem::ToNewDimDomainFunctionSpace< FunctionSpace, 1 >::Type, order, false, Storage >;
58
59 template< int i, class MultiIndex >
60 static ElementType get ( const MultiIndex &multiIndex )
61 {
62 return &FactoryType::get( multiIndex[ i ] );
63 }
64
65 template< class MultiIndex, int... i >
66 static auto get ( const MultiIndex &multiIndex, std::integer_sequence< int, i... > )
67 -> decltype( std::make_tuple( get< i, MultiIndex >( multiIndex )... ) )
68 {
69 return std::make_tuple( get< i, MultiIndex >( multiIndex )... );
70 }
71
72 public:
73 using Type = decltype( get( std::declval< Dune::FieldVector< int, FunctionSpace::dimDomain > >(), std::make_integer_sequence< int, FunctionSpace::dimDomain >() ) );
74
75 template< class MultiIndex >
76 static Type get ( const MultiIndex &multiIndex )
77 {
78 return get( multiIndex, std::make_integer_sequence< int, FunctionSpace::dimDomain >() );
79 }
80 };
81
82
83
84 // AnisotropicShapeFunctionSet
85 // ---------------------------
86
87 template< class FunctionSpace, int order, class Storage >
88 struct AnisotropicShapeFunctionSet
89 : public Dune::Fem::TensorProductShapeFunctionSet< FunctionSpace, typename LegendreShapeFunctionSetTuple< FunctionSpace, order, Storage >::Type >
90 {
92
93 public:
94 AnisotropicShapeFunctionSet ()
95 : AnisotropicShapeFunctionSet( multiIndex() )
96 {}
97
98 template< class MultiIndex >
99 explicit AnisotropicShapeFunctionSet ( const MultiIndex &multiIndex )
100 : BaseType( LegendreShapeFunctionSetTuple< FunctionSpace, order, Storage >::get( multiIndex ) )
101 {}
102
103 private:
104 static Dune::FieldVector< int, FunctionSpace::dimDomain > multiIndex ()
105 {
106 return Dune::FieldVector< int, FunctionSpace::dimDomain >( order );
107 }
108 };
109
110
111
112 // AnisotropicBasisFunctionSetsTraits
113 // ----------------------------------
114
115 template< class FunctionSpace, class GridPart, int maxOrder, class Storage >
116 class AnisotropicBasisFunctionSetsTraits
117 {
118 public:
120
121 using GridPartType = GridPart;
122 using EntityType = typename GridPartType::template Codim< 0 >::EntityType;
123 using Types = std::array< GeometryType, 1 >;
124
125 using KeyType = Dune::FieldVector< int, FunctionSpace::dimDomain >;
126
127 using ScalarFunctionSpaceType = typename Dune::Fem::ToNewDimRangeFunctionSpace< FunctionSpace, 1 >::Type;
128 using ScalarShapeFunctionSetType = AnisotropicShapeFunctionSet< ScalarFunctionSpaceType, maxOrder, Storage >;
130
132
133 static const int localBlockSize = FunctionSpace::dimRange;
134
135 using DataType = int;
136 };
137
138#endif // ifndef DOXYGEN
139
140
141
142 // AnisotropicBasisFunctionSets
143 // ----------------------------
144
156 template< class FunctionSpace, class GridPart, int maxOrder, class Storage >
158 : public BasisFunctionSets< AnisotropicBasisFunctionSetsTraits< FunctionSpace, GridPart, maxOrder, Storage > >
159 {
161
162 public:
167
170
171 private:
172 using ScalarShapeFunctionSetType = typename BaseType::Traits::ScalarShapeFunctionSetType;
173 using ShapeFunctionSetType = typename BaseType::Traits::ShapeFunctionSetType;
174
175 public:
177 using KeyType = typename BaseType::KeyType;
179 using DataType = typename BaseType::DataType;
180
184 typename BaseType::Types types () const noexcept
185 {
186 return std::array< GeometryType, 1 >{{ Dune::GeometryTypes::cube( EntityType::mydimension ) }};
187 }
188
190 static constexpr std::size_t maxBlocks () noexcept
191 {
192 return Dune::StaticPower< maxOrder+1, FunctionSpace::dimDomain >::power;
193 }
194
196 static std::size_t maxBlocks ( Dune::GeometryType type ) noexcept
197 {
198 assert( contains( type ) );
199 return maxBlocks();
200 }
201
203 static std::size_t blocks ( GeometryType type, KeyType key ) noexcept
204 {
205 assert( contains( type ) );
206 std::size_t blocks = 1;
207 auto function = [&blocks]( int order ) -> void
208 {
209 assert( 0 <= order && order <= maxOrder );
210 blocks *= order+1;
211 };
212 std::for_each( key.begin(), key.end(), function );
213 assert( blocks == scalarShapeFunctionSet( key ).size() );
214 return blocks;
215 }
216
218 static DataType encode ( const KeyType &key ) noexcept
219 {
220 DataType data = 0, factor = 1;
221 for( int i = 0; i < FunctionSpace::dimDomain-1; ++i )
222 {
223 data += key[ i ]*factor;
224 factor *= maxOrder+1;
225 }
226 data += key[ FunctionSpace::dimDomain-1 ]*factor;
227 assert( decode( data ) == key );
228 return data;
229 }
230
232 static KeyType decode ( DataType data ) noexcept
233 {
234 KeyType key;
235 for( int i = 0; i < FunctionSpace::dimDomain-1; ++i )
236 {
237 key[ i ] = data % (maxOrder+1);
238 data /= (maxOrder+1);
239 }
240 return std::move( key );
241 }
242
244 static constexpr bool orthogonal () noexcept
245 {
246 using GridType = typename GridPartType::GridType;
247 return Dune::Capabilities::isCartesian< GridType >::v;
248 }
249
251 static constexpr int order () noexcept { return maxOrder; }
252
254 static constexpr int order ( Dune::GeometryType type ) noexcept
255 {
256 assert( type == GeometryType( GeometryType::cube, EntityType::mydimension ) );
257 return order();
258 }
259
261 static int order ( Dune::GeometryType type, KeyType key ) noexcept
262 {
263 assert( type == GeometryType( GeometryType::cube, EntityType::mydimension ) );
264 return *std::max_element( key.begin(), key.end() );
265 }
266
268 static BasisFunctionSetType basisFunctionSet ( const EntityType &entity, const KeyType &key ) noexcept
269 {
270 assert( entity.type() == Dune::GeometryTypes::cube( EntityType::mydimension ) );
271 return BasisFunctionSetType( entity, shapeFunctionSet( key ) );
272 }
273
274 private:
275 static bool contains ( Dune::GeometryType type ) noexcept
276 {
277 return (type.isCube() && type.dim() == EntityType::mydimension);
278 }
279
280 static ScalarShapeFunctionSetType scalarShapeFunctionSet ( const KeyType &key ) noexcept
281 {
282 return ScalarShapeFunctionSetType( key );
283 }
284
285 static ShapeFunctionSetType shapeFunctionSet ( const KeyType &key ) noexcept
286 {
287 return ShapeFunctionSetType( scalarShapeFunctionSet( key ) );
288 }
289 };
290
291 } // namespace hpDG
292
293 } // namespace Fem
294
295} // namespace Dune
296
297#endif // #ifndef DUNE_FEM_HPDG_SPACE_BASISFUNCTIONSETS_ANISOTROPIC_HH
Provides a proxy class for pointers to a shape function set.
Definition: bindguard.hh:11
std::tuple_element< i, Tuple >::type & get(Dune::TypeIndexedTuple< Tuple, Types > &tuple)
Definition: typeindexedtuple.hh:122
Definition: space/basisfunctionset/default.hh:52
A family of anisotropic local product basis function sets.
Definition: basisfunctionset/hpdg/anisotropic.hh:159
typename BaseType::EntityType EntityType
entity type
Definition: basisfunctionset/hpdg/anisotropic.hh:166
static DataType encode(const KeyType &key) noexcept
Definition: basisfunctionset/hpdg/anisotropic.hh:218
static constexpr int order(Dune::GeometryType type) noexcept
return maximum order
Definition: basisfunctionset/hpdg/anisotropic.hh:254
static std::size_t blocks(GeometryType type, KeyType key) noexcept
Definition: basisfunctionset/hpdg/anisotropic.hh:203
static std::size_t maxBlocks(Dune::GeometryType type) noexcept
Definition: basisfunctionset/hpdg/anisotropic.hh:196
typename BaseType::KeyType KeyType
Definition: basisfunctionset/hpdg/anisotropic.hh:177
static constexpr std::size_t maxBlocks() noexcept
Definition: basisfunctionset/hpdg/anisotropic.hh:190
typename BaseType::BasisFunctionSetType BasisFunctionSetType
basis function set
Definition: basisfunctionset/hpdg/anisotropic.hh:169
static BasisFunctionSetType basisFunctionSet(const EntityType &entity, const KeyType &key) noexcept
return basis function set for given entity
Definition: basisfunctionset/hpdg/anisotropic.hh:268
static int order(Dune::GeometryType type, KeyType key) noexcept
return maximum order
Definition: basisfunctionset/hpdg/anisotropic.hh:261
static constexpr int order() noexcept
return maximum order
Definition: basisfunctionset/hpdg/anisotropic.hh:251
typename BaseType::DataType DataType
Definition: basisfunctionset/hpdg/anisotropic.hh:179
BaseType::Types types() const noexcept
Definition: basisfunctionset/hpdg/anisotropic.hh:184
static constexpr bool orthogonal() noexcept
Definition: basisfunctionset/hpdg/anisotropic.hh:244
static KeyType decode(DataType data) noexcept
Definition: basisfunctionset/hpdg/anisotropic.hh:232
typename BaseType::GridPartType GridPartType
Definition: basisfunctionset/hpdg/anisotropic.hh:164
abstract interface class for a family of local basis function sets
Definition: basisfunctionset/hpdg/basisfunctionsets.hh:30
typename Traits::DataType DataType
data type
Definition: basisfunctionset/hpdg/basisfunctionsets.hh:53
typename Traits::Types Types
a range of geometry types
Definition: basisfunctionset/hpdg/basisfunctionsets.hh:47
typename Traits::BasisFunctionSetType BasisFunctionSetType
basis function set type
Definition: basisfunctionset/hpdg/basisfunctionsets.hh:42
typename BasisFunctionSetType::EntityType EntityType
entity type
Definition: basisfunctionset/hpdg/basisfunctionsets.hh:44
typename Traits::KeyType KeyType
key type
Definition: basisfunctionset/hpdg/basisfunctionsets.hh:39
typename Traits::GridPartType GridPartType
grid part type
Definition: basisfunctionset/hpdg/basisfunctionsets.hh:36
convert functions space to space with new dim range
Definition: functionspace.hh:250
@ dimDomain
dimension of domain vector space
Definition: functionspaceinterface.hh:46
Definition: proxy.hh:35
Definition: tensorproduct.hh:28
Definition: shapefunctionset/vectorial.hh:447