Dune Core Modules (2.6.0)

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 static constexpr int dimension = Implementation::dimension;
89
90
95 int size(int c) const
96 {
97 return _impl->size(c);
98 }
99
100
112 int size(int i, int c, int cc) const
113 {
114 return _impl->size(i,c,cc);
115 }
116
117
131 int subEntity(int i, int c, int ii, int cc) const
132 {
133 return _impl->subEntity(i,c,ii,cc);
134 }
135
136
149 decltype(auto) type(int i, int c) const
150 {
151 return _impl->type(i,c);
152 }
153
154
162 decltype(auto) type() const
163 {
164 return _impl->type();
165 }
166
167
181 decltype(auto) position(int i, int c) const
182 {
183 return _impl->position(i,c);
184 }
185
186
194 bool checkInside(const Coordinate& local) const
195 {
196 return _impl->checkInside(local);
197 }
198
199
211 template<int codim>
212 typename Codim<codim>::Geometry geometry(int i) const
213 {
214 return _impl->template geometry<codim>(i);
215 }
216
217
220 {
221 return _impl->volume();
222 }
223
224
236 decltype(auto) integrationOuterNormal(int face) const
237 {
238 return _impl->integrationOuterNormal(face);
239 }
240
241
250 : _impl(nullptr)
251 {}
252
258 const Implementation& impl() const
259 {
260 return *_impl;
261 }
262
263#ifndef DOXYGEN
264
265 DUNE_DEPRECATED_MSG("Capturing reference elements by reference is deprecated in DUNE 2.6. Please store a copy instead.")
266 operator const DeprecatedReferenceElement<ctype,dimension>&() const
267 {
269 }
270
271#endif // DOXYGEN
272
273
275 bool operator==(const ReferenceElement& r) const
276 {
277 return _impl == r._impl;
278 }
279
281 bool operator!=(const ReferenceElement& r) const
282 {
283 return not (*this == r);
284 }
285
287 friend std::size_t hash_value(const ReferenceElement& r)
288 {
289 return reinterpret_cast<std::size_t>(r._impl);
290 }
291
292 private:
293
294 // The implementation must be a friend to construct a wrapper around itself.
295 friend Implementation;
296
297 // The reference container is a friend to be able to call setImplementation.
298 friend class Impl::ReferenceElementContainer<ctype,dimension>;
299
300 // Constructor for wrapping an implementation reference (required internally by the default implementation)
301 ReferenceElement(const Implementation& impl)
302 : _impl(&impl)
303 {}
304
305 void setImplementation(const Implementation& impl)
306 {
307 _impl = &impl;
308 }
309
310 const Implementation* _impl;
311
312 };
313
314 }
315
316}
317
318
319#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:219
ReferenceElement()
Constructs an empty reference element.
Definition: referenceelement.hh:249
bool operator!=(const ReferenceElement &r) const
Compares for inequality with another reference element.
Definition: referenceelement.hh:281
decltype(auto) type(int i, int c) const
obtain the type of subentity (i,c)
Definition: referenceelement.hh:149
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:212
static constexpr int dimension
The dimension of the reference element.
Definition: referenceelement.hh:88
int size(int i, int c, int cc) const
number of subentities of codimension cc of subentity (i,c)
Definition: referenceelement.hh:112
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:131
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:95
decltype(auto) type() const
obtain the type of this reference element
Definition: referenceelement.hh:162
const Implementation & impl() const
Returns a reference to the internal implementation object.
Definition: referenceelement.hh:258
bool checkInside(const Coordinate &local) const
check if a coordinate is in the reference element
Definition: referenceelement.hh:194
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:275
decltype(auto) position(int i, int c) const
position of the barycenter of entity (i,c)
Definition: referenceelement.hh:181
decltype(auto) integrationOuterNormal(int face) const
obtain the integration outer normal of the reference element
Definition: referenceelement.hh:236
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:287
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:10
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 (Nov 13, 23:29, 2024)