Dune Core Modules (2.9.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 // SPDX-FileCopyrightInfo: Copyright (C) DUNE Project contributors, see file LICENSE.md in module root
4 // SPDX-License-Identifier: LicenseRef-GPL-2.0-only-with-DUNE-exception
5 #ifndef DUNE_GEOMETRY_REFERENCEELEMENT_HH
6 #define DUNE_GEOMETRY_REFERENCEELEMENT_HH
7 
8 #include <dune/geometry/type.hh>
9 
10 namespace 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 backwards compatibility conversion
26  template<typename ctype, int dim>
27  struct ReferenceElements;
28 
29  // ReferenceElement
30  // ----------------
31 
50  template<typename Implementation>
51  class ReferenceElement
52  {
53 
54  public:
55 
56 #ifndef DOXYGEN
57 
59  template<int codim>
60  using Codim = typename Implementation::template Codim<codim>;
61 
62 #else
63 
65  template< int codim >
66  struct Codim
67  {
69  using Geometry = implementation-defined;
70  };
71 
72 #endif // DOXYGEN
73 
75  using ctype = typename Implementation::ctype;
76 
79 
81  using Coordinate = typename Implementation::Coordinate;
82 
84  typedef ctype Volume;
85 
87  static constexpr int dimension = Implementation::dimension;
88 
89 
94  int size(int c) const
95  {
96  return _impl->size(c);
97  }
98 
99 
111  int size(int i, int c, int cc) const
112  {
113  return _impl->size(i,c,cc);
114  }
115 
116 
130  int subEntity(int i, int c, int ii, int cc) const
131  {
132  return _impl->subEntity(i,c,ii,cc);
133  }
134 
153  auto subEntities ( int i, int c, int cc ) const
154  {
155  return _impl->subEntities(i,c,cc);
156  }
157 
158 
171  decltype(auto) type(int i, int c) const
172  {
173  return _impl->type(i,c);
174  }
175 
176 
184  decltype(auto) type() const
185  {
186  return _impl->type();
187  }
188 
189 
203  decltype(auto) position(int i, int c) const
204  {
205  return _impl->position(i,c);
206  }
207 
208 
216  bool checkInside(const Coordinate& local) const
217  {
218  return _impl->checkInside(local);
219  }
220 
221 
233  template<int codim>
234  typename Codim<codim>::Geometry geometry(int i) const
235  {
236  return _impl->template geometry<codim>(i);
237  }
238 
239 
242  {
243  return _impl->volume();
244  }
245 
246 
258  decltype(auto) integrationOuterNormal(int face) const
259  {
260  return _impl->integrationOuterNormal(face);
261  }
262 
263 
272  : _impl(nullptr)
273  {}
274 
280  const Implementation& impl() const
281  {
282  return *_impl;
283  }
284 
286  bool operator==(const ReferenceElement& r) const
287  {
288  return _impl == r._impl;
289  }
290 
292  bool operator!=(const ReferenceElement& r) const
293  {
294  return not (*this == r);
295  }
296 
298  friend std::size_t hash_value(const ReferenceElement& r)
299  {
300  return reinterpret_cast<std::size_t>(r._impl);
301  }
302 
303  private:
304 
305  // The implementation must be a friend to construct a wrapper around itself.
306  friend Implementation;
307 
308  // The reference container is a friend to be able to call setImplementation.
309  friend class Impl::ReferenceElementContainer<ctype,dimension>;
310 
311  // Constructor for wrapping an implementation reference (required internally by the default implementation)
312  ReferenceElement(const Implementation& impl)
313  : _impl(&impl)
314  {}
315 
316  void setImplementation(const Implementation& impl)
317  {
318  _impl = &impl;
319  }
320 
321  const Implementation* _impl;
322 
323  };
324 
325  }
326 
327 }
328 
329 
330 #endif // DUNE_GEOMETRY_REFERENCEELEMENT_HH
This class provides access to geometric and topological properties of a reference element.
Definition: referenceelement.hh:27
CoordinateField volume() const
obtain the volume of the reference element
Definition: referenceelement.hh:241
ReferenceElement()
Constructs an empty reference element.
Definition: referenceelement.hh:271
bool operator!=(const ReferenceElement &r) const
Compares for inequality with another reference element.
Definition: referenceelement.hh:292
typename Implementation::Coordinate Coordinate
The coordinate type.
Definition: referenceelement.hh:81
static constexpr int dimension
The dimension of the reference element.
Definition: referenceelement.hh:87
int size(int i, int c, int cc) const
number of subentities of codimension cc of subentity (i,c)
Definition: referenceelement.hh:111
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:130
typename Implementation::ctype ctype
The coordinate field type.
Definition: referenceelement.hh:75
int size(int c) const
number of subentities of codimension c
Definition: referenceelement.hh:94
const Implementation & impl() const
Returns a reference to the internal implementation object.
Definition: referenceelement.hh:280
decltype(auto) type() const
obtain the type of this reference element
Definition: referenceelement.hh:184
bool checkInside(const Coordinate &local) const
check if a coordinate is in the reference element
Definition: referenceelement.hh:216
ctype CoordinateField
The coordinate field type.
Definition: referenceelement.hh:78
bool operator==(const ReferenceElement &r) const
Compares for equality with another reference element.
Definition: referenceelement.hh:286
decltype(auto) position(int i, int c) const
position of the barycenter of entity (i,c)
Definition: referenceelement.hh:203
decltype(auto) integrationOuterNormal(int face) const
obtain the integration outer normal of the reference element
Definition: referenceelement.hh:258
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:298
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:153
Codim< codim >::Geometry geometry(int i) const
obtain the embedding of subentity (i,codim) into the reference element
Definition: referenceelement.hh:234
ctype Volume
Type used for volume.
Definition: referenceelement.hh:84
unspecified-type ReferenceElement
Returns the type of reference element for the argument type T.
Definition: referenceelements.hh:497
Dune namespace.
Definition: alignedallocator.hh:13
Collection of types depending on the codimension.
Definition: referenceelement.hh:67
implementation-defined Geometry
type of geometry embedding a subentity into the reference element
Definition: referenceelement.hh:69
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.80.0 (Apr 29, 22:29, 2024)