DUNE PDELab (2.8)

referenceelement.hh
1// -*- tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*-
2// vi: set et ts=4 sw=2 sts=2:
3#ifndef DUNE_GEOMETRY_REFERENCEELEMENT_HH
4#define DUNE_GEOMETRY_REFERENCEELEMENT_HH
5
7
8namespace Dune {
9 namespace Geo {
10
11 namespace Impl {
12
13 // forward declaration for friend declaration
14 template<typename ctype, int dim>
15 class ReferenceElementContainer;
16
17 }
18
19 // forward declaration for constructing default reference element type
20 template<typename ctype, int dim>
21 class ReferenceElementImplementation;
22
23 // forward declaration for backwards compatibility conversion
24 template<typename ctype, int dim>
25 struct ReferenceElements;
26
27 // ReferenceElement
28 // ----------------
29
48 template<typename Implementation>
50 {
51
52 public:
53
54#ifndef DOXYGEN
55
57 template<int codim>
58 using Codim = typename Implementation::template Codim<codim>;
59
60#else
61
63 template< int codim >
64 struct Codim
65 {
67 using Geometry = implementation-defined;
68 };
69
70#endif // DOXYGEN
71
73 using ctype = typename Implementation::ctype;
74
77
79 using Coordinate = typename Implementation::Coordinate;
80
82 typedef ctype Volume;
83
85 static constexpr int dimension = Implementation::dimension;
86
87
92 int size(int c) const
93 {
94 return _impl->size(c);
95 }
96
97
109 int size(int i, int c, int cc) const
110 {
111 return _impl->size(i,c,cc);
112 }
113
114
128 int subEntity(int i, int c, int ii, int cc) const
129 {
130 return _impl->subEntity(i,c,ii,cc);
131 }
132
151 auto subEntities ( int i, int c, int cc ) const
152 {
153 return _impl->subEntities(i,c,cc);
154 }
155
156
169 decltype(auto) type(int i, int c) const
170 {
171 return _impl->type(i,c);
172 }
173
174
182 decltype(auto) type() const
183 {
184 return _impl->type();
185 }
186
187
201 decltype(auto) position(int i, int c) const
202 {
203 return _impl->position(i,c);
204 }
205
206
214 bool checkInside(const Coordinate& local) const
215 {
216 return _impl->checkInside(local);
217 }
218
219
231 template<int codim>
232 typename Codim<codim>::Geometry geometry(int i) const
233 {
234 return _impl->template geometry<codim>(i);
235 }
236
237
240 {
241 return _impl->volume();
242 }
243
244
256 decltype(auto) integrationOuterNormal(int face) const
257 {
258 return _impl->integrationOuterNormal(face);
259 }
260
261
270 : _impl(nullptr)
271 {}
272
278 const Implementation& impl() const
279 {
280 return *_impl;
281 }
282
284 bool operator==(const ReferenceElement& r) const
285 {
286 return _impl == r._impl;
287 }
288
290 bool operator!=(const ReferenceElement& r) const
291 {
292 return not (*this == r);
293 }
294
296 friend std::size_t hash_value(const ReferenceElement& r)
297 {
298 return reinterpret_cast<std::size_t>(r._impl);
299 }
300
301 private:
302
303 // The implementation must be a friend to construct a wrapper around itself.
304 friend Implementation;
305
306 // The reference container is a friend to be able to call setImplementation.
307 friend class Impl::ReferenceElementContainer<ctype,dimension>;
308
309 // Constructor for wrapping an implementation reference (required internally by the default implementation)
310 ReferenceElement(const Implementation& impl)
311 : _impl(&impl)
312 {}
313
314 void setImplementation(const Implementation& impl)
315 {
316 _impl = &impl;
317 }
318
319 const Implementation* _impl;
320
321 };
322
323 }
324
325}
326
327
328#endif // DUNE_GEOMETRY_REFERENCEELEMENT_HH
This class provides access to geometric and topological properties of a reference element.
Definition: referenceelement.hh:50
CoordinateField volume() const
obtain the volume of the reference element
Definition: referenceelement.hh:239
ReferenceElement()
Constructs an empty reference element.
Definition: referenceelement.hh:269
bool operator!=(const ReferenceElement &r) const
Compares for inequality with another reference element.
Definition: referenceelement.hh:290
decltype(auto) type(int i, int c) const
obtain the type of subentity (i,c)
Definition: referenceelement.hh:169
typename Implementation::Coordinate Coordinate
The coordinate type.
Definition: referenceelement.hh:79
Codim< codim >::Geometry geometry(int i) const
obtain the embedding of subentity (i,codim) into the reference element
Definition: referenceelement.hh:232
static constexpr int dimension
The dimension of the reference element.
Definition: referenceelement.hh:85
int size(int i, int c, int cc) const
number of subentities of codimension cc of subentity (i,c)
Definition: referenceelement.hh:109
int subEntity(int i, int c, int ii, int cc) const
obtain number of ii-th subentity with codim cc of (i,c)
Definition: referenceelement.hh:128
typename Implementation::ctype ctype
The coordinate field type.
Definition: referenceelement.hh:73
int size(int c) const
number of subentities of codimension c
Definition: referenceelement.hh:92
decltype(auto) type() const
obtain the type of this reference element
Definition: referenceelement.hh:182
const Implementation & impl() const
Returns a reference to the internal implementation object.
Definition: referenceelement.hh:278
bool checkInside(const Coordinate &local) const
check if a coordinate is in the reference element
Definition: referenceelement.hh:214
ctype CoordinateField
The coordinate field type.
Definition: referenceelement.hh:76
bool operator==(const ReferenceElement &r) const
Compares for equality with another reference element.
Definition: referenceelement.hh:284
decltype(auto) position(int i, int c) const
position of the barycenter of entity (i,c)
Definition: referenceelement.hh:201
decltype(auto) integrationOuterNormal(int face) const
obtain the integration outer normal of the reference element
Definition: referenceelement.hh:256
friend std::size_t hash_value(const ReferenceElement &r)
Yields a hash value suitable for storing the reference element a in hash table.
Definition: referenceelement.hh:296
auto subEntities(int i, int c, int cc) const
Obtain the range of numbers of subentities with codim cc of (i,c)
Definition: referenceelement.hh:151
ctype Volume
Type used for volume.
Definition: referenceelement.hh:82
Dune namespace.
Definition: alignedallocator.hh:11
Collection of types depending on the codimension.
Definition: referenceelement.hh:65
implementation-defined Geometry
type of geometry embedding a subentity into the reference element
Definition: referenceelement.hh:67
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 24, 22:29, 2024)