DUNE-FEM (unstable)

legendre.hh
1#ifndef DUNE_FEM_SPACE_DISCONTINUOUSGALERKIN_LEGENDRE_HH
2#define DUNE_FEM_SPACE_DISCONTINUOUSGALERKIN_LEGENDRE_HH
3
4#include <cassert>
5
6#include <dune/common/math.hh>
7
9
10#include <dune/grid/common/gridenums.hh>
11
12#include <dune/fem/common/hybrid.hh>
13#include <dune/fem/gridpart/common/capabilities.hh>
14#include <dune/fem/space/common/capabilities.hh>
15#include <dune/fem/space/common/commoperations.hh>
16#include <dune/fem/space/common/defaultcommhandler.hh>
17#include <dune/fem/space/common/functionspace.hh>
18#include <dune/fem/space/shapefunctionset/legendre.hh>
19#include <dune/fem/space/shapefunctionset/selectcaching.hh>
20
21#include "basisfunctionsets.hh"
22#include "declaration.hh"
23#include "generic.hh"
24#include "localinterpolation.hh"
25#include "shapefunctionsets.hh"
26
27namespace Dune
28{
29
30 namespace Fem
31 {
32 // Forward declaration
33 template< class FunctionSpace, class GridPart, int polOrder, class Storage = CachingStorage >
34 class LegendreDiscontinuousGalerkinSpace;
35
36 template< class FunctionSpace, class GridPart, int polOrder, class Storage = CachingStorage >
37 class HierarchicLegendreDiscontinuousGalerkinSpace;
38
39 // LegendreDiscontinuousGalerkinSpaceTraits
40 // ----------------------------------------
41
42 template< class FunctionSpace, class GridPart, int polOrder, class Storage, bool hierarchicalOrdering >
43 struct LegendreDiscontinuousGalerkinSpaceTraits
44 {
45 // select space implementation depending on basis function ordering
46 typedef typename std::conditional< hierarchicalOrdering,
47 HierarchicLegendreDiscontinuousGalerkinSpace< FunctionSpace, GridPart, polOrder, Storage >,
48 LegendreDiscontinuousGalerkinSpace< FunctionSpace, GridPart, polOrder, Storage > >::type DiscreteFunctionSpaceType;
49
50 typedef GridPart GridPartType;
51 typedef GridFunctionSpace< GridPartType, FunctionSpace > FunctionSpaceType;
52
53 static const int codimension = 0;
54
57 GridPartType::dimension, 1
58 > ScalarShapeFunctionSpaceType;
59
60 struct ScalarShapeFunctionSet
61 : public Dune::Fem::LegendreShapeFunctionSet< ScalarShapeFunctionSpaceType, hierarchicalOrdering >
62 {
64 static const int numberShapeFunctions = Dune::power( int(polOrder+1), int(ScalarShapeFunctionSpaceType::dimDomain) );
65
66 public:
67 explicit ScalarShapeFunctionSet ( Dune::GeometryType type )
68 : BaseType( polOrder )
69 {
70 assert( type.isCube() );
71 assert( size() == BaseType::size() );
72 }
73
74 // overload size method because it's a static value
75 static constexpr unsigned int size() { return numberShapeFunctions; }
76 };
77
78 typedef SelectCachingShapeFunctionSets< GridPartType, ScalarShapeFunctionSet, Storage > ScalarShapeFunctionSetsType;
79 typedef VectorialShapeFunctionSets< ScalarShapeFunctionSetsType, typename FunctionSpaceType::RangeType > ShapeFunctionSetsType;
80
81 typedef DefaultBasisFunctionSets< GridPartType, ShapeFunctionSetsType > BasisFunctionSetsType;
82 typedef typename BasisFunctionSetsType::BasisFunctionSetType BasisFunctionSetType;
83
84 typedef CodimensionMapper< GridPartType, codimension > BlockMapperType;
85
86 typedef Hybrid::IndexRange< int, FunctionSpaceType::dimRange * ScalarShapeFunctionSet::numberShapeFunctions > LocalBlockIndices;
87
88 template <class DiscreteFunction, class Operation = DFCommunicationOperation::Copy >
89 struct CommDataHandle
90 {
91 typedef Operation OperationType;
92 typedef DefaultCommunicationHandler< DiscreteFunction, Operation > Type;
93 };
94 };
95
96
97 // LegendreDiscontinuousGalerkinSpaceBase
98 // --------------------------------------
99
100 template< class FunctionSpace, class GridPart, int polOrder, class Storage, bool hierarchicalOrdering >
101 class LegendreDiscontinuousGalerkinSpaceBase
102 : public GenericDiscontinuousGalerkinSpace< LegendreDiscontinuousGalerkinSpaceTraits< FunctionSpace, GridPart, polOrder, Storage, hierarchicalOrdering > >
103 {
104 typedef GenericDiscontinuousGalerkinSpace< LegendreDiscontinuousGalerkinSpaceTraits< FunctionSpace, GridPart, polOrder, Storage, hierarchicalOrdering > > BaseType;
105 typedef LegendreDiscontinuousGalerkinSpaceBase< FunctionSpace, GridPart, polOrder, Storage, hierarchicalOrdering > ThisType;
106
107 public:
109
110 static const int polynomialOrder = polOrder;
111
112 typedef typename BaseType::GridPartType GridPartType;
113 typedef typename BaseType::EntityType EntityType;
114
115 typedef typename BaseType::BasisFunctionSetsType BasisFunctionSetsType;
116 typedef typename BaseType::BasisFunctionSetType BasisFunctionSetType;
117
118 explicit LegendreDiscontinuousGalerkinSpaceBase ( GridPartType &gridPart,
119 const InterfaceType commInterface = InteriorBorder_All_Interface,
120 const CommunicationDirection commDirection = ForwardCommunication )
121 : BaseType( gridPart, makeBasisFunctionSets( gridPart ), commInterface, commDirection )
122 {}
123
124 static DFSpaceIdentifier type () { return LegendreDGSpace_id; }
125
126 private:
127 static BasisFunctionSetsType makeBasisFunctionSets ( const GridPartType &gridPart )
128 {
129 typedef typename BasisFunctionSetsType::ShapeFunctionSetsType ShapeFunctionSetsType;
130 ShapeFunctionSetsType shapeFunctionSets( gridPart );
131 return BasisFunctionSetsType( std::move( shapeFunctionSets ) );
132 }
133 };
134
135 // LegendreDiscontinuousGalerkinSpace
136 // ----------------------------------
137
138 template< class FunctionSpace, class GridPart, int polOrder, class Storage >
139 class LegendreDiscontinuousGalerkinSpace
140 : public LegendreDiscontinuousGalerkinSpaceBase< FunctionSpace, GridPart, polOrder, Storage, false >
141 {
142 // hierarchicalOrdering = false
143 typedef LegendreDiscontinuousGalerkinSpaceBase< FunctionSpace, GridPart, polOrder, Storage, false > BaseType;
144 typedef LegendreDiscontinuousGalerkinSpace< FunctionSpace, GridPart, polOrder, Storage > ThisType;
145
146 public:
147 typedef typename BaseType::GridPartType GridPartType;
148 typedef typename BaseType::EntityType EntityType;
149 typedef DiscontinuousGalerkinLocalInterpolation< ThisType > InterpolationType;
150 typedef InterpolationType InterpolationImplType;
151
152 explicit LegendreDiscontinuousGalerkinSpace ( GridPartType &gridPart,
153 const InterfaceType commInterface = InteriorBorder_All_Interface,
154 const CommunicationDirection commDirection = ForwardCommunication )
155 : BaseType( gridPart, commInterface, commDirection )
156 {}
157
158 InterpolationType interpolation () const
159 {
160 return InterpolationType( *this );
161 }
162
163 [[deprecated]]
164 InterpolationType interpolation ( const EntityType &entity ) const
165 {
166 return interpolation();
167 }
168
169 InterpolationType localInterpolation ( const EntityType &entity ) const
170 {
171 return interpolation();
172 }
173 };
174
175
176 namespace Capabilities
177 {
178
179 template< class FunctionSpace, class GridPart, int polOrder, class Storage >
180 struct hasFixedPolynomialOrder< LegendreDiscontinuousGalerkinSpace< FunctionSpace, GridPart, polOrder, Storage > >
181 {
182 static const bool v = true;
183 };
184
185 template< class FunctionSpace, class GridPart, int polOrder, class Storage >
186 struct hasStaticPolynomialOrder< LegendreDiscontinuousGalerkinSpace< FunctionSpace, GridPart, polOrder, Storage > >
187 {
188 static const bool v = true;
189 static const int order = polOrder;
190 };
191
192 template< class FunctionSpace, class GridPart, int polOrder, class Storage >
193 struct isContinuous< LegendreDiscontinuousGalerkinSpace< FunctionSpace, GridPart, polOrder, Storage > >
194 {
195 static const bool v = false;
196 };
197
198 template< class FunctionSpace, class GridPart, int polOrder, class Storage >
199 struct isLocalized< LegendreDiscontinuousGalerkinSpace< FunctionSpace, GridPart, polOrder, Storage > >
200 {
201 static const bool v = true;
202 };
203
204 template< class FunctionSpace, class GridPart, int polOrder, class Storage >
205 struct isAdaptive< LegendreDiscontinuousGalerkinSpace< FunctionSpace, GridPart, polOrder, Storage > >
206 {
207 static const bool v = true;
208 };
209
210 template< class FunctionSpace, class GridPart, int polOrder, class Storage >
211 struct threadSafe< LegendreDiscontinuousGalerkinSpace< FunctionSpace, GridPart, polOrder, Storage > >
212 {
213 static const bool v = false;
214 };
215
216 template< class FunctionSpace, class GridPart, int polOrder, class Storage >
217 struct viewThreadSafe< LegendreDiscontinuousGalerkinSpace< FunctionSpace, GridPart, polOrder, Storage > >
218 {
219 static const bool v = true;
220 };
221
222 } // namespace Capabilities
223
224 } // namespace Fem
225
226} // namespace Dune
227
228#endif // #ifndef DUNE_FEM_SPACE_DISCONTINUOUSGALERKIN_LEGENDRE_HH
Dune::Fem::DefaultBasisFunctionSet< EntityType, ShapeFunctionSetType > BasisFunctionSetType
entity type
Definition: basisfunctionsets.hh:105
ShapeFunctionSets ShapeFunctionSetsType
shape function sets type
Definition: basisfunctionsets.hh:91
DFSpaceIdentifier type() const
return type identifier of discrete function space
Definition: discretefunctionspace.hh:294
FunctionSpaceTraits::DomainFieldType DomainFieldType
Intrinsic type used for values in the domain field (usually a double)
Definition: functionspaceinterface.hh:60
@ dimDomain
dimension of domain vector space
Definition: functionspaceinterface.hh:46
FunctionSpaceTraits::RangeFieldType RangeFieldType
Intrinsic type used for values in the range field (usually a double)
Definition: functionspaceinterface.hh:63
A vector valued function space.
Definition: functionspace.hh:60
BasisFunctionSetType basisFunctionSet(const EntityType &entity) const
get basis function set for given entity
Definition: generic.hh:106
a Dune::Fem::ShapeFunctionSet of Legendre ansatz polynomials
Definition: legendre.hh:218
std::size_t size() const noexcept
return number of shape functions
Definition: legendre.hh:308
Unique label for each type of entities that can occur in DUNE grids.
Definition: type.hh:114
constexpr bool isCube() const
Return true if entity is a cube of any dimension.
Definition: type.hh:324
DFSpaceIdentifier
enumerator for identification of spaces
Definition: discretefunctionspace.hh:95
@ LegendreDGSpace_id
id for Legendre Discontinuous Galerkin Space
Definition: discretefunctionspace.hh:104
CommunicationDirection
Define a type for communication direction parameter.
Definition: gridenums.hh:170
InterfaceType
Parameter to be used for the communication functions.
Definition: gridenums.hh:86
@ ForwardCommunication
communicate as given in InterfaceType
Definition: gridenums.hh:171
@ InteriorBorder_All_Interface
send interior and border, receive all entities
Definition: gridenums.hh:88
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
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 (Jul 27, 22:29, 2024)