dune-fem  2.8-git
basisfunctionset/hpdg/legendre.hh
Go to the documentation of this file.
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 
13 #include <dune/grid/common/capabilities.hh>
14 
21 
22 #include "basisfunctionsets.hh"
23 
24 namespace 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 =
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  {
77  return Dune::GeometryTypes::cube( FunctionSpace::dimDomain );
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 >;
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;
197  return Dune::Capabilities::isCartesian< GridType >::v;
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
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
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::GridPartType GridPartType
grid part type
Definition: basisfunctionset/hpdg/basisfunctionsets.hh:36
A family of local product basis function sets.
Definition: basisfunctionset/hpdg/legendre.hh:131
typename BaseType::BasisFunctionSetType BasisFunctionSetType
basis function set
Definition: basisfunctionset/hpdg/legendre.hh:147
BasisFunctionSetType basisFunctionSet(const EntityType &entity, KeyType key) const
return basis function set for given entity
Definition: basisfunctionset/hpdg/legendre.hh:214
typename BaseType::KeyType KeyType
Definition: basisfunctionset/hpdg/legendre.hh:150
int order(GeometryType type, KeyType key) const
return maximum order
Definition: basisfunctionset/hpdg/legendre.hh:207
typename BaseType::EntityType EntityType
entity type
Definition: basisfunctionset/hpdg/legendre.hh:139
static constexpr int order() noexcept
return maximum order
Definition: basisfunctionset/hpdg/legendre.hh:201
LegendreBasisFunctionSets(const ThisType &)=default
copy constructor
std::size_t blocks(GeometryType type, KeyType key) const
Definition: basisfunctionset/hpdg/legendre.hh:182
std::size_t maxBlocks() const
Definition: basisfunctionset/hpdg/legendre.hh:170
static constexpr int order(GeometryType type) noexcept
return maximum order
Definition: basisfunctionset/hpdg/legendre.hh:204
typename BaseType::GridPartType GridPartType
Definition: basisfunctionset/hpdg/legendre.hh:137
LegendreBasisFunctionSets()=default
constructor
BaseType::Types types() const
Definition: basisfunctionset/hpdg/legendre.hh:164
std::size_t maxBlocks(GeometryType type) const
Definition: basisfunctionset/hpdg/legendre.hh:176
static KeyType decode(const DataType &data) noexcept
Definition: basisfunctionset/hpdg/legendre.hh:191
static constexpr bool orthogonal() noexcept
Definition: basisfunctionset/hpdg/legendre.hh:194
LegendreBasisFunctionSets(ThisType &&)=default
move constructor
static DataType encode(const KeyType &key) noexcept
Definition: basisfunctionset/hpdg/legendre.hh:188
typename BaseType::DataType DataType
Definition: basisfunctionset/hpdg/legendre.hh:152
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
Definition: selectcaching.hh:26
Definition: shapefunctionset/vectorial.hh:447