DUNE-FEM (unstable)

legendre.hh
1#ifndef DUNE_FEM_HPDG_SPACE_BASISFUNCTIONSETS_LEGENDRE_HH
2#define DUNE_FEM_HPDG_SPACE_BASISFUNCTIONSETS_LEGENDRE_HH
3
4#include <cassert>
5#include <cstddef>
6
7#include <array>
8#include <memory>
9#include <type_traits>
10
11#include <dune/geometry/type.hh>
12
14
15#include <dune/fem/space/basisfunctionset/default.hh>
16#include <dune/fem/space/common/functionspace.hh>
17#include <dune/fem/space/shapefunctionset/legendre.hh>
19#include <dune/fem/space/shapefunctionset/selectcaching.hh>
20#include <dune/fem/space/shapefunctionset/vectorial.hh>
21
22#include "basisfunctionsets.hh"
23
24namespace Dune
25{
26
27 namespace Fem
28 {
29
30 namespace hpDG
31 {
32
33 // Internal forward declarations
34 // -----------------------------
35
36 template< class FunctionSpace, class GridPart, int maxOrder, bool hierarchicalOrdering, class Storage >
37 class LegendreBasisFunctionSets;
38
39
40
41#ifndef DOXYGEN
42
43 // LegendreShapeFunctionSets
44 // -------------------------
45
46 template< class FunctionSpace, int order, bool hierarchicalOrdering, class Storage >
47 class LegendreShapeFunctionSets
48 {
49 using ThisType = LegendreShapeFunctionSets< FunctionSpace, order, hierarchicalOrdering, Storage >;
50
51 public:
52 using ShapeFunctionSetType =
53 Dune::Fem::SelectCachingShapeFunctionSet< LegendreShapeFunctionSet< FunctionSpace, hierarchicalOrdering >, Storage >;
54
55 protected:
56 LegendreShapeFunctionSets ()
57 {
58 for( int p = 0; p <= order; ++p )
59 shapeFunctionSets_[ p ].reset( new ShapeFunctionSetType( type(), typename ShapeFunctionSetType::ImplementationType( p ) ) );
60 }
61
62 static const ThisType &instance ()
63 {
64 static ThisType instance;
65 return instance;
66 }
67
68 public:
69 static const ShapeFunctionSetType &get ( int p )
70 {
71 return *instance().shapeFunctionSets_[ p ];
72 }
73
74 private:
75 static GeometryType type ()
76 {
78 }
79
80 std::array< std::unique_ptr< ShapeFunctionSetType >, order+1 > shapeFunctionSets_;
81 };
82
83
84
85 // LegendreBasisFunctionSetsTraits
86 // -------------------------------
87
88 template< class FunctionSpace, class GridPart, int maxOrder, bool hierarchicalOrdering, class Storage >
89 class LegendreBasisFunctionSetsTraits
90 {
91 public:
92 using ImplementationType = LegendreBasisFunctionSets< FunctionSpace, GridPart, maxOrder, hierarchicalOrdering, Storage >;
93
94 using GridPartType = GridPart;
95 using Types = std::array< GeometryType, 1 >;
96
97 using KeyType = int;
98 using DataType = KeyType;
99
100 using EntityType = typename GridPartType::template Codim< 0 >::EntityType;
101
102 using ShapeFunctionSetsType = LegendreShapeFunctionSets< Dune::Fem::FunctionSpace< typename FunctionSpace::DomainFieldType, typename FunctionSpace::RangeFieldType, EntityType::mydimension, 1 >, maxOrder, hierarchicalOrdering, Storage >;
103 using ShapeFunctionSetType = Dune::Fem::VectorialShapeFunctionSet< Dune::Fem::ShapeFunctionSetProxy< typename ShapeFunctionSetsType::ShapeFunctionSetType >, typename FunctionSpace::RangeType >;
104
105 using BasisFunctionSetType = DefaultBasisFunctionSet< EntityType, ShapeFunctionSetType >;
106
107 static const int localBlockSize = BasisFunctionSetType::RangeType::dimension;
108 };
109
110#endif // #ifndef DOXYGEN
111
112
113
114 // LegendreBasisFunctionSets
115 // -------------------------
116
128 template< class FunctionSpace, class GridPart, int maxOrder, bool hierarchicalOrdering, class Storage >
130 : public BasisFunctionSets< LegendreBasisFunctionSetsTraits< FunctionSpace, GridPart, maxOrder, hierarchicalOrdering, Storage > >
131 {
134
135 public:
140
141 private:
142 using ShapeFunctionSetsType = typename BaseType::Traits::ShapeFunctionSetsType;
143 using ShapeFunctionSetType = typename BaseType::Traits::ShapeFunctionSetType;
144
145 public:
148
150 using KeyType = typename BaseType::KeyType;
152 using DataType = typename BaseType::DataType;
153
156
158 LegendreBasisFunctionSets ( const ThisType & ) = default;
159
162
164 typename BaseType::Types types () const
165 {
166 return std::array< GeometryType, 1 >{{ Dune::GeometryTypes::cube( EntityType::mydimension ) }};
167 }
168
170 std::size_t maxBlocks () const
171 {
172 return ShapeFunctionSetsType::get( maxOrder ).size();
173 }
174
176 std::size_t maxBlocks ( GeometryType type ) const
177 {
178 return contains( type ) ? maxBlocks() : 0u;
179 }
180
182 std::size_t blocks ( GeometryType type, KeyType key ) const
183 {
184 return contains( type ) ? ShapeFunctionSetsType::get( key ).size() : 0u;
185 }
186
188 static DataType encode ( const KeyType &key ) noexcept { return key; }
189
191 static KeyType decode ( const DataType &data ) noexcept { return data; }
192
194 static constexpr bool orthogonal () noexcept
195 {
196 using GridType = typename GridPartType::GridType;
198 }
199
201 static constexpr int order () noexcept { return maxOrder; }
202
204 static constexpr int order ( GeometryType type ) noexcept { return order(); }
205
207 int order ( GeometryType type, KeyType key ) const
208 {
209 assert( contains( type ) );
210 return static_cast< int >( key );
211 }
212
215 {
216 assert( contains( entity.type() ) );
217 return BasisFunctionSetType( entity, shapeFunctionSet( key ) );
218 }
219
220 private:
221 static bool contains ( GeometryType type )
222 {
223 return (type.isCube() && type.dim() == EntityType::mydimension);
224 }
225
226 static ShapeFunctionSetType shapeFunctionSet ( KeyType key )
227 {
228 return ShapeFunctionSetType( &ShapeFunctionSetsType::get( static_cast< int >( key ) ) );
229 }
230 };
231
232 } // namespace hpDG
233
234 } // namespace Fem
235
236} // namespace Dune
237
238#endif // #ifndef DUNE_FEM_HPDG_SPACE_BASISFUNCTIONSETS_LEGENDRE_HH
FunctionSpaceTraits::RangeType RangeType
Type of range vector (using type of range field) has a Dune::FieldVector type interface.
Definition: functionspaceinterface.hh:71
@ dimDomain
dimension of domain vector space
Definition: functionspaceinterface.hh:46
abstract interface class for a family of local basis function sets
Definition: basisfunctionsets.hh:30
typename Traits::BasisFunctionSetType BasisFunctionSetType
basis function set type
Definition: basisfunctionsets.hh:42
A family of local product basis function sets.
Definition: legendre.hh:131
typename BaseType::BasisFunctionSetType BasisFunctionSetType
basis function set
Definition: legendre.hh:147
BasisFunctionSetType basisFunctionSet(const EntityType &entity, KeyType key) const
return basis function set for given entity
Definition: legendre.hh:214
typename BaseType::KeyType KeyType
Definition: legendre.hh:150
int order(GeometryType type, KeyType key) const
return maximum order
Definition: legendre.hh:207
typename BaseType::EntityType EntityType
entity type
Definition: legendre.hh:139
static constexpr int order() noexcept
return maximum order
Definition: legendre.hh:201
LegendreBasisFunctionSets(const ThisType &)=default
copy constructor
std::size_t blocks(GeometryType type, KeyType key) const
Definition: legendre.hh:182
std::size_t maxBlocks() const
Definition: legendre.hh:170
static constexpr int order(GeometryType type) noexcept
return maximum order
Definition: legendre.hh:204
typename BaseType::GridPartType GridPartType
Definition: legendre.hh:137
LegendreBasisFunctionSets()=default
constructor
BaseType::Types types() const
Definition: legendre.hh:164
std::size_t maxBlocks(GeometryType type) const
Definition: legendre.hh:176
static KeyType decode(const DataType &data) noexcept
Definition: legendre.hh:191
static constexpr bool orthogonal() noexcept
Definition: legendre.hh:194
LegendreBasisFunctionSets(ThisType &&)=default
move constructor
static DataType encode(const KeyType &key) noexcept
Definition: legendre.hh:188
typename BaseType::DataType DataType
Definition: legendre.hh:152
Unique label for each type of entities that can occur in DUNE grids.
Definition: type.hh:114
constexpr unsigned int dim() const
Return dimension of the type.
Definition: type.hh:360
constexpr bool isCube() const
Return true if entity is a cube of any dimension.
Definition: type.hh:324
A set of traits classes to store static information about grid implementation.
GeometryType
Type representing VTK's entity geometry types.
Definition: common.hh:132
constexpr GeometryType cube(unsigned int dim)
Returns a GeometryType representing a hypercube of dimension dim.
Definition: type.hh:462
Dune namespace.
Definition: alignedallocator.hh:13
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
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 21, 23:30, 2024)