DUNE-FEM (unstable)

anisotropic.hh
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
14#include <dune/common/math.hh>
15
16#include <dune/geometry/type.hh>
17
19
20#include <dune/fem/space/basisfunctionset/default.hh>
21#include <dune/fem/space/common/functionspace.hh>
23#include <dune/fem/space/shapefunctionset/selectcaching.hh>
24#include <dune/fem/space/shapefunctionset/tensorproduct.hh>
25#include <dune/fem/space/shapefunctionset/vectorial.hh>
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 >
43 class AnisotropicBasisFunctionSets;
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 >;
57 using ElementType = Dune::Fem::ShapeFunctionSetProxy< typename FactoryType::ShapeFunctionSetType >;
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 {
91 using BaseType = Dune::Fem::TensorProductShapeFunctionSet< FunctionSpace, typename LegendreShapeFunctionSetTuple< FunctionSpace, order, Storage >::Type >;
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:
105 {
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:
119 using ImplementationType = AnisotropicBasisFunctionSets< FunctionSpace, GridPart, maxOrder, Storage >;
120
121 using GridPartType = GridPart;
122 using EntityType = typename GridPartType::template Codim< 0 >::EntityType;
123 using Types = std::array< GeometryType, 1 >;
124
126
127 using ScalarFunctionSpaceType = typename Dune::Fem::ToNewDimRangeFunctionSpace< FunctionSpace, 1 >::Type;
128 using ScalarShapeFunctionSetType = AnisotropicShapeFunctionSet< ScalarFunctionSpaceType, maxOrder, Storage >;
129 using ShapeFunctionSetType = Dune::Fem::VectorialShapeFunctionSet< ScalarShapeFunctionSetType, typename FunctionSpace::RangeType >;
130
131 using BasisFunctionSetType = DefaultBasisFunctionSet< EntityType, ShapeFunctionSetType >;
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::power( int(maxOrder+1), int(FunctionSpace::dimDomain) );
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;
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
@ dimDomain
dimension of domain vector space
Definition: functionspaceinterface.hh:46
@ dimRange
dimension of range vector space
Definition: functionspaceinterface.hh:48
A family of anisotropic local product basis function sets.
Definition: anisotropic.hh:159
typename BaseType::EntityType EntityType
entity type
Definition: anisotropic.hh:166
static DataType encode(const KeyType &key) noexcept
Definition: anisotropic.hh:218
static constexpr int order(Dune::GeometryType type) noexcept
return maximum order
Definition: anisotropic.hh:254
static std::size_t blocks(GeometryType type, KeyType key) noexcept
Definition: anisotropic.hh:203
static std::size_t maxBlocks(Dune::GeometryType type) noexcept
Definition: anisotropic.hh:196
typename BaseType::KeyType KeyType
Definition: anisotropic.hh:177
static constexpr std::size_t maxBlocks() noexcept
Definition: anisotropic.hh:190
typename BaseType::BasisFunctionSetType BasisFunctionSetType
basis function set
Definition: anisotropic.hh:169
static BasisFunctionSetType basisFunctionSet(const EntityType &entity, const KeyType &key) noexcept
return basis function set for given entity
Definition: anisotropic.hh:268
static int order(Dune::GeometryType type, KeyType key) noexcept
return maximum order
Definition: anisotropic.hh:261
static constexpr int order() noexcept
return maximum order
Definition: anisotropic.hh:251
typename BaseType::DataType DataType
Definition: anisotropic.hh:179
BaseType::Types types() const noexcept
Definition: anisotropic.hh:184
static constexpr bool orthogonal() noexcept
Definition: anisotropic.hh:244
static KeyType decode(DataType data) noexcept
Definition: anisotropic.hh:232
typename BaseType::GridPartType GridPartType
Definition: anisotropic.hh:164
abstract interface class for a family of local basis function sets
Definition: basisfunctionsets.hh:30
typename Traits::Types Types
a range of geometry types
Definition: basisfunctionsets.hh:47
typename Traits::BasisFunctionSetType BasisFunctionSetType
basis function set type
Definition: basisfunctionsets.hh:42
typename BasisFunctionSetType::EntityType EntityType
entity type
Definition: basisfunctionsets.hh:44
typename Traits::GridPartType GridPartType
grid part type
Definition: basisfunctionsets.hh:36
vector space out of a tensor product of fields.
Definition: fvector.hh:91
Unique label for each type of entities that can occur in DUNE grids.
Definition: type.hh:114
@ cube
Cube element in any nonnegative dimension.
Definition: type.hh:122
A set of traits classes to store static information about grid implementation.
Implements a vector constructed from a given type representing a field and a compile-time given size.
constexpr GeometryType cube(unsigned int dim)
Returns a GeometryType representing a hypercube of dimension dim.
Definition: type.hh:462
Some useful basic math stuff.
Dune namespace.
Definition: alignedallocator.hh:13
constexpr std::integral_constant< std::size_t, sizeof...(II)> size(std::integer_sequence< T, II... >)
Return the size of the sequence.
Definition: integersequence.hh:75
constexpr Base power(Base m, Exponent p)
Power method for integer exponents.
Definition: math.hh:75
constexpr auto get(std::integer_sequence< T, II... >, std::integral_constant< std::size_t, pos >={})
Return the entry at position pos of the given sequence.
Definition: integersequence.hh:22
Provides a proxy class for pointers to a shape function set.
Specialize with 'true' if the grid is a Cartesian grid. Cartesian grids satisfy the following propert...
Definition: capabilities.hh:48
convert functions space to space with new dim range
Definition: functionspace.hh:250
A unique label for each type of element that can occur in a grid.
Creative Commons License   |  Legal Statements / Impressum  |  Hosted by TU Dresden  |  generated with Hugo v0.111.3 (Nov 13, 23:29, 2024)