DUNE-FEM (unstable)

orthogonal.hh
1#ifndef DUNE_FEM_HPDG_SPACE_BASISFUNCTIONSETS_ORTHOGONAL_HH
2#define DUNE_FEM_HPDG_SPACE_BASISFUNCTIONSETS_ORTHOGONAL_HH
3
4#include <cassert>
5#include <cstddef>
6
7#include <algorithm>
8#include <array>
9#include <memory>
10#include <type_traits>
11#include <vector>
12
13#include <dune/geometry/type.hh>
14
16
17#include <dune/fem/space/basisfunctionset/default.hh>
18#include <dune/fem/space/common/functionspace.hh>
20#include <dune/fem/space/shapefunctionset/selectcaching.hh>
21#include <dune/fem/space/shapefunctionset/vectorial.hh>
22
23#include <dune/fem/space/shapefunctionset/orthonormal.hh>
24
25#include "typeindexset.hh"
26#include "typemap.hh"
27#include "basisfunctionsets.hh"
28
29namespace Dune
30{
31
32 namespace Fem
33 {
34
35 namespace hpDG
36 {
37
38 // Internal forward declarations
39 // -----------------------------
40
41 template< class FunctionSpace, class GridPart, int maxOrder, class Storage >
42 class OrthogonalBasisFunctionSets;
43
44
45
46#ifndef DOXYGEN
47
48 // OrthonormalShapeFunctionSets
49 // ----------------------------
50
51 template< class FunctionSpace, int order, class Storage >
52 class OrthonormalShapeFunctionSets
53 {
54 using ThisType = OrthonormalShapeFunctionSets< FunctionSpace, order, Storage >;
55
56 public:
58 using ShapeFunctionSetType =
59 Dune::Fem::SelectCachingShapeFunctionSet< OrthonormalShapeFunctionSet< FunctionSpace >, Storage >;
60
61 private:
62 static const int dimension = ShapeFunctionSetType::DomainType::dimension;
63
64 protected:
65 OrthonormalShapeFunctionSets ()
66 {
67 using GeometryTypeIndexSet = LocalGeometryTypeIndexSet< dimension, true >;
68 const std::size_t types = GeometryTypeIndexSet::size();
69 for( std::size_t i = 0u; i < types; ++i )
70 {
71 GeometryType type = GeometryTypeIndexSet::type( i );
72 assert( !type.isNone() );
73 types_.push_back( type );
74 for( int p = 0; p <= order; ++p )
75 shapeFunctionSets_[ type ][ p ].reset( new ShapeFunctionSetType( type, typename ShapeFunctionSetType::ImplementationType( type, p ) ) );
76 }
77 }
78
79 static const ThisType &instance ()
80 {
81 static ThisType instance;
82 return instance;
83 }
84
85 public:
87 static const std::vector< GeometryType > &types ()
88 {
89 return instance().types();
90 }
91
93 static std::size_t maxSize ()
94 {
95 return OrthonormalShapeFunctions< dimension >::size( order );
96 }
97
99 static std::size_t size ( GeometryType type, int p )
100 {
101 return OrthonormalShapeFunctions< dimension >::size( p );
102 }
103
105 static const ShapeFunctionSetType &get ( GeometryType type, int p )
106 {
107 return *instance().shapeFunctionSets_[ type ][ p ];
108 }
109
110 private:
111 std::vector< GeometryType > types_;
112 LocalGeometryTypeMap< std::array< std::unique_ptr< ShapeFunctionSetType >, order+1 >, dimension > shapeFunctionSets_;
113 };
114
115
116
117 // OrthogonalBasisFunctionSetsTraits
118 // ---------------------------------
119
120 template< class FunctionSpace, class GridPart, int maxOrder, class Storage >
121 class OrthogonalBasisFunctionSetsTraits
122 {
123 public:
124 using ImplementationType = OrthogonalBasisFunctionSets< FunctionSpace, GridPart, maxOrder, Storage >;
125
126 using GridPartType = GridPart;
127 using Types = const std::vector< GeometryType > &;
128
129 using KeyType = int;
130 using DataType = KeyType;
131
132 using EntityType = typename GridPartType::template Codim< 0 >::EntityType;
133
134 using ShapeFunctionSetsType = OrthonormalShapeFunctionSets< Dune::Fem::FunctionSpace< typename FunctionSpace::DomainFieldType, typename FunctionSpace::RangeFieldType, EntityType::mydimension, 1 >, maxOrder, Storage >;
135 using ShapeFunctionSetType = Dune::Fem::VectorialShapeFunctionSet< Dune::Fem::ShapeFunctionSetProxy< typename ShapeFunctionSetsType::ShapeFunctionSetType >, typename FunctionSpace::RangeType >;
136
137 using BasisFunctionSetType = DefaultBasisFunctionSet< EntityType, ShapeFunctionSetType >;
138
139 static const int localBlockSize = BasisFunctionSetType::RangeType::dimension;
140 };
141
142#endif // #ifndef DOXYGEN
143
144
145
146 // OrthogonalBasisFunctionSets
147 // ---------------------------
148
158 template< class FunctionSpace, class GridPart, int maxOrder, class Storage >
160 : public BasisFunctionSets< OrthogonalBasisFunctionSetsTraits< FunctionSpace, GridPart, maxOrder, Storage > >
161 {
164
165 public:
170
171 private:
172 using ShapeFunctionSetsType = typename BaseType::Traits::ShapeFunctionSetsType;
173 using ShapeFunctionSetType = typename BaseType::Traits::ShapeFunctionSetType;
174
175 public:
178
180 using KeyType = typename BaseType::KeyType;
182 using DataType = typename BaseType::DataType;
183
186
189
192
199
202
205
213 ThisType &operator= ( const ThisType & ) = default;
214
216 ThisType &operator= ( ThisType && ) = default;
217
221 static const std::vector< GeometryType > &types ()
222 {
223 return ShapeFunctionSetsType::types();
224 }
225
227 static std::size_t maxBlocks ()
228 {
229 return ShapeFunctionSetsType::maxSize();
230 }
231
233 static std::size_t maxBlocks ( GeometryType type )
234 {
235 return contains( type ) ? maxBlocks() : 0u;
236 }
237
239 static std::size_t blocks ( GeometryType type, KeyType key )
240 {
241 return contains( type ) ? ShapeFunctionSetsType::size( type, key ) : 0u;
242 }
243
245 static DataType encode ( const KeyType &key ) noexcept { return key; }
246
248 static KeyType decode ( const DataType &data ) noexcept { return data; }
249
251 static constexpr bool orthogonal () noexcept
252 {
253 //using GridType = typename GridPartType::GridType;
254 //return Dune::Capabilities::isCartesian< GridType >::v;
255 return true;
256 }
257
259 static constexpr int order () noexcept { return maxOrder; }
260
262 static int order ( GeometryType type ) noexcept { return order(); }
263
265 static int order ( GeometryType type, KeyType key )
266 {
267 assert( contains( type ) );
268 return static_cast< int >( key );
269 }
270
273 {
274 assert( contains( entity.type() ) );
275 return BasisFunctionSetType( entity, shapeFunctionSet( entity.type(), key ) );
276 }
277
278 private:
279 static bool contains ( GeometryType type )
280 {
281 return (type.dim() <= 3 && !type.isNone());
282 }
283
284 static ShapeFunctionSetType shapeFunctionSet ( GeometryType type, KeyType key )
285 {
286 return ShapeFunctionSetType( &ShapeFunctionSetsType::get( type, static_cast< int >( key ) ) );
287 }
288 };
289
290 } // namespace hpDG
291
292 } // namespace Fem
293
294} // namespace Dune
295
296#endif // #ifndef DUNE_FEM_HPDG_SPACE_BASISFUNCTIONSETS_ORTHOGONAL_HH
FunctionSpaceTraits::RangeType RangeType
Type of range vector (using type of range field) has a Dune::FieldVector type interface.
Definition: functionspaceinterface.hh:71
FunctionSpaceTraits::DomainType DomainType
Type of domain vector (using type of domain field) has a Dune::FieldVector type interface.
Definition: functionspaceinterface.hh:67
A vector valued function space.
Definition: functionspace.hh:60
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
typename BasisFunctionSetType::EntityType EntityType
entity type
Definition: basisfunctionsets.hh:44
typename Traits::GridPartType GridPartType
grid part type
Definition: basisfunctionsets.hh:36
A family of orthogonal local basis function sets.
Definition: orthogonal.hh:161
static std::size_t maxBlocks(GeometryType type)
Definition: orthogonal.hh:233
static const std::vector< GeometryType > & types()
Definition: orthogonal.hh:221
OrthogonalBasisFunctionSets(const ThisType &)=default
copy constructor
typename BaseType::GridPartType GridPartType
Definition: orthogonal.hh:167
typename BaseType::DataType DataType
Definition: orthogonal.hh:182
static int order(GeometryType type, KeyType key)
return maximum order
Definition: orthogonal.hh:265
static BasisFunctionSetType basisFunctionSet(const EntityType &entity, KeyType key)
return basis function set for given entity
Definition: orthogonal.hh:272
static std::size_t blocks(GeometryType type, KeyType key)
Definition: orthogonal.hh:239
static KeyType decode(const DataType &data) noexcept
Definition: orthogonal.hh:248
static std::size_t maxBlocks()
Definition: orthogonal.hh:227
typename BaseType::EntityType EntityType
entity type
Definition: orthogonal.hh:169
typename FunctionSpaceType ::DomainType DomainType
range type of basis functions
Definition: orthogonal.hh:188
static constexpr bool orthogonal() noexcept
Definition: orthogonal.hh:251
typename BaseType::BasisFunctionSetType BasisFunctionSetType
basis function set
Definition: orthogonal.hh:177
typename BaseType::KeyType KeyType
Definition: orthogonal.hh:180
static constexpr int order() noexcept
return maximum order
Definition: orthogonal.hh:259
static int order(GeometryType type) noexcept
return maximum order
Definition: orthogonal.hh:262
OrthogonalBasisFunctionSets(ThisType &&)=default
move constructor
ThisType & operator=(const ThisType &)=default
assignment operator
static DataType encode(const KeyType &key) noexcept
Definition: orthogonal.hh:245
typename FunctionSpaceType ::RangeType RangeType
range type of basis functions
Definition: orthogonal.hh:191
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 isNone() const
Return true if entity is a singular of any dimension.
Definition: type.hh:355
Please doc me.
A set of traits classes to store static information about grid implementation.
GeometryType
Type representing VTK's entity geometry types.
Definition: common.hh:132
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 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.
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)