DUNE-FEM (unstable)

space.hh
1#ifndef DUNE_FEM_SPACE_RAVIARTTHOMAS_SPACE_HH
2#define DUNE_FEM_SPACE_RAVIARTTHOMAS_SPACE_HH
3
4#if HAVE_DUNE_LOCALFUNCTIONS
5
6// C++ includes
7#include <array>
8#include <tuple>
9
10// dune-common includes
12
13// dune-geometry includes
14#include <dune/geometry/type.hh>
15
16// dune-localfunction includes
17#include <dune/localfunctions/raviartthomas/raviartthomas02d.hh>
18#include <dune/localfunctions/raviartthomas/raviartthomas0cube2d.hh>
19#include <dune/localfunctions/raviartthomas/raviartthomas0cube3d.hh>
20#include <dune/localfunctions/raviartthomas/raviartthomas12d.hh>
21#include <dune/localfunctions/raviartthomas/raviartthomas1cube2d.hh>
22#include <dune/localfunctions/raviartthomas/raviartthomas1cube3d.hh>
23#include <dune/localfunctions/raviartthomas/raviartthomas2cube2d.hh>
24#include <dune/localfunctions/raviartthomas/raviartthomas3cube2d.hh>
25#include <dune/localfunctions/raviartthomas/raviartthomas4cube2d.hh>
26
27// dune-fem includes
28#include <dune/fem/space/common/uniquefacetorientation.hh>
29#include <dune/fem/space/basisfunctionset/piolatransformation.hh>
30#include <dune/fem/space/localfiniteelement/space.hh>
31
32
33namespace Dune
34{
35
36 namespace Fem
37 {
38
39 namespace Impl
40 {
41
42 // RaviartThomasLocalFiniteElement
43 // -------------------------------
44
45 template< unsigned int id, class DomainField, class RangeField, int dimension, int order >
46 struct RaviartThomasLocalFiniteElement
47 {
48 static_assert( AlwaysFalse< DomainField >::value, "RaviartThomasLocalFiniteElement not implemented for your choice." );
49 };
50
51 // 2d, Simplex, 0th order
52 template< class D, class R >
53 struct RaviartThomasLocalFiniteElement< Dune::GeometryTypes::simplex( 2 ).id(), D, R, 2, 0 >
54 : public RT02DLocalFiniteElement< D, R >
55 {
56 static constexpr std::size_t numOrientations = 8;
57 using RT02DLocalFiniteElement< D, R >::RT02DLocalFiniteElement;
58 };
59
60 // 2d, Simplex, 1st order
61 template< class D, class R >
62 struct RaviartThomasLocalFiniteElement< Dune::GeometryTypes::simplex( 2 ).id(), D, R, 2, 1 >
63 : public RT12DLocalFiniteElement< D, R >
64 {
65 static constexpr std::size_t numOrientations = 8;
66 using RT12DLocalFiniteElement< D, R >::RT12DLocalFiniteElement;
67 };
68
69 // 2d, Cube, 0th order
70 template< class D, class R >
71 struct RaviartThomasLocalFiniteElement< Dune::GeometryTypes::cube( 2 ).id(), D, R, 2, 0 >
72 : public RT0Cube2DLocalFiniteElement< D, R >
73 {
74 static constexpr std::size_t numOrientations = 16;
75 using RT0Cube2DLocalFiniteElement< D, R >::RT0Cube2DLocalFiniteElement;
76 };
77
78 // 2d, Cube, 1st order
79 template< class D, class R >
80 struct RaviartThomasLocalFiniteElement< Dune::GeometryTypes::cube( 2 ).id(), D, R, 2, 1 >
81 : public RT1Cube2DLocalFiniteElement< D, R >
82 {
83 static constexpr std::size_t numOrientations = 16;
84 using RT1Cube2DLocalFiniteElement< D, R >::RT1Cube2DLocalFiniteElement;
85 };
86
87 // 2d, Cube, 2nd order
88 template< class D, class R >
89 struct RaviartThomasLocalFiniteElement< Dune::GeometryTypes::cube( 2 ).id(), D, R, 2, 2 >
90 : public RT2Cube2DLocalFiniteElement< D, R >
91 {
92 static constexpr std::size_t numOrientations = 16;
93 using RT2Cube2DLocalFiniteElement< D, R >::RT2Cube2DLocalFiniteElement;
94 };
95
96 // 2d, Cube, 3rd order
97 template< class D, class R >
98 struct RaviartThomasLocalFiniteElement< Dune::GeometryTypes::cube( 2 ).id(), D, R, 2, 3 >
99 : public RT3Cube2DLocalFiniteElement< D, R >
100 {
101 static constexpr std::size_t numOrientations = 16;
102 using RT3Cube2DLocalFiniteElement< D, R >::RT3Cube2DLocalFiniteElement;
103 };
104
105 // 2d, Cube, 4th order
106 template< class D, class R >
107 struct RaviartThomasLocalFiniteElement< Dune::GeometryTypes::cube( 2 ).id(), D, R, 2, 4 >
108 : public RT4Cube2DLocalFiniteElement< D, R >
109 {
110 static constexpr std::size_t numOrientations = 16;
111 using RT4Cube2DLocalFiniteElement< D, R >::RT4Cube2DLocalFiniteElement;
112 };
113
114 // 3d, Cube, 0th order
115 template< class D, class R >
116 struct RaviartThomasLocalFiniteElement< Dune::GeometryTypes::cube( 3 ).id(), D, R, 3, 0 >
117 : public RT0Cube3DLocalFiniteElement< D, R >
118 {
119 static constexpr std::size_t numOrientations = 64;
120 using RT0Cube3DLocalFiniteElement< D, R >::RT0Cube3DLocalFiniteElement;
121 };
122
123 // 3d, Cube, 1st order
124 template< class D, class R >
125 struct RaviartThomasLocalFiniteElement< Dune::GeometryTypes::cube( 3 ).id(), D, R, 3, 1 >
126 : public RT1Cube3DLocalFiniteElement< D, R >
127 {
128 static constexpr std::size_t numOrientations = 64;
129 using RT1Cube3DLocalFiniteElement< D, R >::RT1Cube3DLocalFiniteElement;
130 };
131
132 } // namespace Impl
133
134
135 // RaviartThomasLocalFiniteElementMap
136 // ----------------------------------
137
138 template< class GridPart, class FunctionSpace, int polOrder >
139 class RaviartThomasLocalFiniteElementMap
140 {
141 using hasSingleGeometryType = GridPartCapabilities::hasSingleGeometryType< GridPart >;
142
143 static_assert( hasSingleGeometryType::v, "`GridPart` has more the one geometry type." );
144
145 static constexpr int dimLocal = GridPart::dimension;
146 static constexpr unsigned int topologyId = hasSingleGeometryType::topologyId;
147
148 static_assert( dimLocal == FunctionSpace::dimRange, "`dimRange` has to be equal to `GridPart::dimension`" );
149
150 using Geometry = typename GridPart::template Codim< 0 >::EntityType::Geometry;
151
152 public:
153 using GridPartType = GridPart;
154
155 using DomainFieldType = typename FunctionSpace::DomainFieldType;
156 using RangeFieldType = typename FunctionSpace::RangeFieldType;
157
158 using KeyType = std::tuple<>;
159
160 using TransformationType = PiolaTransformation< Geometry, FunctionSpace::dimRange >;
161
162 using LocalFiniteElementType =
163 Impl::RaviartThomasLocalFiniteElement< topologyId, DomainFieldType, RangeFieldType, dimLocal, polOrder >;
164
165 using LocalBasisType = typename LocalFiniteElementType::Traits::LocalBasisType;
166 using LocalCoefficientsType = typename LocalFiniteElementType::Traits::LocalCoefficientsType;
167 using LocalInterpolationType = typename LocalFiniteElementType::Traits::LocalInterpolationType;
168
169 static constexpr auto size () -> std::size_t { return LocalFiniteElementType::numOrientations; }
170
171 template< class ... Args >
172 RaviartThomasLocalFiniteElementMap ( const GridPartType& gridPart, Args&& ... )
173 : orientation_( gridPart )
174 {
175 for ( auto i : range( size() ) )
176 map_[ i ] = LocalFiniteElementType( i );
177 }
178
179 int order () const { return polOrder; }
180
181 template< class Entity >
182 int order ( const Entity& entity ) const { return order; }
183
184 template< class Entity >
185 auto operator() ( const Entity& entity ) const
186 -> std::tuple< std::size_t, const LocalBasisType&, const LocalInterpolationType& >
187 {
188 auto o = orientation_( entity );
189 return std::tuple< std::size_t, const LocalBasisType&, const LocalInterpolationType& >(
190 static_cast< std::size_t >( o ), map_[ o ].localBasis(), map_[ o ].localInterpolation() );
191 }
192
193 auto localCoefficients ( const GeometryType& type ) const
194 -> const LocalCoefficientsType&
195 {
196 return map_[ 0 ].localCoefficients();
197 }
198
199 bool hasCoefficients ( const GeometryType& type ) const { return type == GeometryType( topologyId, dimLocal ); }
200 auto gridPart () const -> const GridPartType& { return orientation_.gridPart(); }
201
202 private:
203 UniqueFacetOrientation< GridPartType > orientation_;
204 std::array< LocalFiniteElementType, LocalFiniteElementType::numOrientations > map_;
205 };
206
207
208 // RaviartThomasSpace
209 // ------------------
210
211 template< class FunctionSpace, class GridPart, int polOrder, class Storage = CachingStorage >
212 using RaviartThomasSpace
213 = LocalFiniteElementSpace< RaviartThomasLocalFiniteElementMap< GridPart, FunctionSpace, polOrder >, FunctionSpace, Storage >;
214
215
216 } // namespace Fem
217
218} // namespace Dune
219
220#endif // HAVE_DUNE_LOCALFUNCTIONS
221
222#endif // #ifndef DUNE_FEM_SPACE_RAVIARTTHOMAS_SPACE_HH
FunctionSpaceTraits::DomainFieldType DomainFieldType
Intrinsic type used for values in the domain field (usually a double)
Definition: functionspaceinterface.hh:60
@ dimRange
dimension of range vector space
Definition: functionspaceinterface.hh:48
FunctionSpaceTraits::RangeFieldType RangeFieldType
Intrinsic type used for values in the range field (usually a double)
Definition: functionspaceinterface.hh:63
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
constexpr GeometryType simplex(unsigned int dim)
Returns a GeometryType representing a simplex of dimension dim.
Definition: type.hh:453
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
A unique label for each type of element that can occur in a grid.
Traits for type conversions and type information.
Creative Commons License   |  Legal Statements / Impressum  |  Hosted by TU Dresden  |  generated with Hugo v0.111.3 (Nov 21, 23:30, 2024)