DUNE PDELab (2.7)

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
9
10namespace Dune {
11 namespace Geo {
12
13 namespace Impl {
14
15 // forward declaration for friend declaration
16 template<typename ctype, int dim>
17 class ReferenceElementContainer;
18
19 }
20
21 // forward declaration for constructing default reference element type
22 template<typename ctype, int dim>
23 class ReferenceElementImplementation;
24
25 // forward declaration for deprecation check reference element type
26 template<typename ctype, int dim>
27 class DeprecatedReferenceElement;
28
29 // forward declaration for backwards compatibility conversion
30 template<typename ctype, int dim>
31 struct ReferenceElements;
32
33 // ReferenceElement
34 // ----------------
35
54 template<typename Implementation>
56 {
57
58 public:
59
60#ifndef DOXYGEN
61
63 template<int codim>
64 using Codim = typename Implementation::template Codim<codim>;
65
66#else
67
69 template< int codim >
70 struct Codim
71 {
73 using Geometry = implementation-defined;
74 };
75
76#endif // DOXYGEN
77
79 using ctype = typename Implementation::ctype;
80
83
85 using Coordinate = typename Implementation::Coordinate;
86
88 typedef ctype Volume;
89
91 static constexpr int dimension = Implementation::dimension;
92
93
98 int size(int c) const
99 {
100 return _impl->size(c);
101 }
102
103
115 int size(int i, int c, int cc) const
116 {
117 return _impl->size(i,c,cc);
118 }
119
120
134 int subEntity(int i, int c, int ii, int cc) const
135 {
136 return _impl->subEntity(i,c,ii,cc);
137 }
138
157 auto subEntities ( int i, int c, int cc ) const
158 {
159 return _impl->subEntities(i,c,cc);
160 }
161
162
175 decltype(auto) type(int i, int c) const
176 {
177 return _impl->type(i,c);
178 }
179
180
188 decltype(auto) type() const
189 {
190 return _impl->type();
191 }
192
193
207 decltype(auto) position(int i, int c) const
208 {
209 return _impl->position(i,c);
210 }
211
212
220 bool checkInside(const Coordinate& local) const
221 {
222 return _impl->checkInside(local);
223 }
224
225
237 template<int codim>
238 typename Codim<codim>::Geometry geometry(int i) const
239 {
240 return _impl->template geometry<codim>(i);
241 }
242
243
246 {
247 return _impl->volume();
248 }
249
250
262 decltype(auto) integrationOuterNormal(int face) const
263 {
264 return _impl->integrationOuterNormal(face);
265 }
266
267
276 : _impl(nullptr)
277 {}
278
284 const Implementation& impl() const
285 {
286 return *_impl;
287 }
288
289#ifndef DOXYGEN
290
291 DUNE_DEPRECATED_MSG("Capturing reference elements by reference is deprecated in DUNE 2.6. Please store a copy instead.")
292 operator const DeprecatedReferenceElement<ctype,dimension>&() const
293 {
295 }
296
297#endif // DOXYGEN
298
299
301 bool operator==(const ReferenceElement& r) const
302 {
303 return _impl == r._impl;
304 }
305
307 bool operator!=(const ReferenceElement& r) const
308 {
309 return not (*this == r);
310 }
311
313 friend std::size_t hash_value(const ReferenceElement& r)
314 {
315 return reinterpret_cast<std::size_t>(r._impl);
316 }
317
318 private:
319
320 // The implementation must be a friend to construct a wrapper around itself.
321 friend Implementation;
322
323 // The reference container is a friend to be able to call setImplementation.
324 friend class Impl::ReferenceElementContainer<ctype,dimension>;
325
326 // Constructor for wrapping an implementation reference (required internally by the default implementation)
327 ReferenceElement(const Implementation& impl)
328 : _impl(&impl)
329 {}
330
331 void setImplementation(const Implementation& impl)
332 {
333 _impl = &impl;
334 }
335
336 const Implementation* _impl;
337
338 };
339
340 }
341
342}
343
344
345#endif // DUNE_GEOMETRY_REFERENCEELEMENT_HH
This class provides access to geometric and topological properties of a reference element.
Definition: referenceelement.hh:56
CoordinateField volume() const
obtain the volume of the reference element
Definition: referenceelement.hh:245
ReferenceElement()
Constructs an empty reference element.
Definition: referenceelement.hh:275
bool operator!=(const ReferenceElement &r) const
Compares for inequality with another reference element.
Definition: referenceelement.hh:307
decltype(auto) type(int i, int c) const
obtain the type of subentity (i,c)
Definition: referenceelement.hh:175
typename Implementation::Coordinate Coordinate
The coordinate type.
Definition: referenceelement.hh:85
Codim< codim >::Geometry geometry(int i) const
obtain the embedding of subentity (i,codim) into the reference element
Definition: referenceelement.hh:238
static constexpr int dimension
The dimension of the reference element.
Definition: referenceelement.hh:91
int size(int i, int c, int cc) const
number of subentities of codimension cc of subentity (i,c)
Definition: referenceelement.hh:115
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:134
typename Implementation::ctype ctype
The coordinate field type.
Definition: referenceelement.hh:79
int size(int c) const
number of subentities of codimension c
Definition: referenceelement.hh:98
decltype(auto) type() const
obtain the type of this reference element
Definition: referenceelement.hh:188
const Implementation & impl() const
Returns a reference to the internal implementation object.
Definition: referenceelement.hh:284
bool checkInside(const Coordinate &local) const
check if a coordinate is in the reference element
Definition: referenceelement.hh:220
ctype CoordinateField
The coordinate field type.
Definition: referenceelement.hh:82
bool operator==(const ReferenceElement &r) const
Compares for equality with another reference element.
Definition: referenceelement.hh:301
decltype(auto) position(int i, int c) const
position of the barycenter of entity (i,c)
Definition: referenceelement.hh:207
decltype(auto) integrationOuterNormal(int face) const
obtain the integration outer normal of the reference element
Definition: referenceelement.hh:262
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:313
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:157
ctype Volume
Type used for volume.
Definition: referenceelement.hh:88
Definition of the DUNE_DEPRECATED macro for the case that config.h is not available.
#define DUNE_DEPRECATED_MSG(text)
Mark some entity as deprecated.
Definition: deprecated.hh:169
Dune namespace.
Definition: alignedallocator.hh:14
Collection of types depending on the codimension.
Definition: referenceelement.hh:71
implementation-defined Geometry
type of geometry embedding a subentity into the reference element
Definition: referenceelement.hh:73
Class providing access to the singletons of the reference elements.
Definition: referenceelements.hh:168
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 15, 22:36, 2024)