Dune Core Modules (unstable)

geometryreference.hh
Go to the documentation of this file.
1 // SPDX-FileCopyrightText: Copyright © DUNE Project contributors, see file LICENSE.md in module root
2 // SPDX-License-Identifier: LicenseRef-GPL-2.0-only-with-DUNE-exception
3 // -*- tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*-
4 // vi: set et ts=4 sw=2 sts=2:
5 #ifndef DUNE_GRID_ALBERTAGRID_GEOMETRYREFERENCE_HH
6 #define DUNE_GRID_ALBERTAGRID_GEOMETRYREFERENCE_HH
7 
13 
14 #include <dune/geometry/type.hh>
15 
17 
18 namespace Dune
19 {
20 
21  // GeometryReference
22  // -----------------
23 
24  template< class Implementation >
25  class GeometryReference
26  {
27  typedef GeometryReference< Implementation > This;
28 
29  public:
30  static const int mydimension = Implementation::mydimension;
31  static const int coorddimension = Implementation::coorddimension;
32 
33  typedef typename Implementation::ctype ctype;
34 
35  typedef typename Implementation::LocalCoordinate LocalCoordinate;
36  typedef typename Implementation::GlobalCoordinate GlobalCoordinate;
37 
38  typedef typename Implementation::JacobianInverseTransposed JacobianInverseTransposed;
39  typedef typename Implementation::JacobianTransposed JacobianTransposed;
40 
41  private:
42 
43  template<class Implementation_T>
44  using JacobianInverseOfImplementation = decltype(typename Implementation_T::JacobianInverse{std::declval<Implementation_T>().jacobianInverse(std::declval<LocalCoordinate>())});
45 
46  using JacobianInverseDefault = decltype(transpose(std::declval<JacobianInverseTransposed>()));
47 
48  template<class Implementation_T>
49  using JacobianOfImplementation = decltype(typename Implementation_T::Jacobian{std::declval<Implementation_T>().jacobian(std::declval<LocalCoordinate>())});
50 
51  using JacobianDefault = decltype(transpose(std::declval<JacobianTransposed>()));
52 
53 
54  template <class I = Implementation>
55  [[deprecated("Geometry implementatons are required to provide a jacobian(local) method. The default implementation is deprecated and will be removed after release 2.9")]]
56  auto deprecatedDefaultJacobian ( const LocalCoordinate& local ) const {
57  return transpose(jacobianTransposed(local));
58  }
59 
60  template <class I = Implementation>
61  [[deprecated("Geometry implementatons are required to provide a jacobianInverse(local) method. The default implementation is deprecated and will be removed after release 2.9")]]
62  auto deprecatedDefaultJacobianInverse ( const LocalCoordinate& local ) const {
63  return transpose(jacobianInverseTransposed(local));
64  }
65 
66  public:
67 
68  using Jacobian = Std::detected_or_t<JacobianDefault, JacobianOfImplementation, Implementation>;
69  using JacobianInverse = Std::detected_or_t<JacobianInverseDefault, JacobianInverseOfImplementation, Implementation>;
70 
71  explicit GeometryReference ( const Implementation &impl )
72  : impl_( &impl )
73  {}
74 
75  GeometryType type () const { return impl().type(); }
76 
77  bool affine() const { return impl().affine(); }
78 
79  int corners () const { return impl().corners(); }
80  GlobalCoordinate corner ( int i ) const { return impl().corner( i ); }
81  GlobalCoordinate center () const { return impl().center(); }
82 
83  GlobalCoordinate global ( const LocalCoordinate &local ) const
84  {
85  return impl().global( local );
86  }
87 
88  LocalCoordinate local ( const GlobalCoordinate &global ) const
89  {
90  return impl().local( global );
91  }
92 
93  ctype integrationElement ( const LocalCoordinate &local ) const
94  {
95  return impl().integrationElement( local );
96  }
97 
98  ctype volume () const { return impl().volume(); }
99 
100  JacobianTransposed jacobianTransposed ( const LocalCoordinate &local ) const
101  {
102  return impl().jacobianTransposed( local );
103  }
104 
105  JacobianInverseTransposed jacobianInverseTransposed ( const LocalCoordinate &local ) const
106  {
107  return impl().jacobianInverseTransposed( local );
108  }
109 
110  Jacobian jacobian ( const LocalCoordinate& local ) const
111  {
112  if constexpr(Std::is_detected_v<JacobianOfImplementation, Implementation>)
113  return impl().jacobian(local);
114  else
115  return deprecatedDefaultJacobian(local);
116  }
117 
118  JacobianInverse jacobianInverse ( const LocalCoordinate &local ) const
119  {
120  if constexpr(Std::is_detected_v<JacobianInverseOfImplementation, Implementation>)
121  return impl().jacobianInverse(local);
122  else
123  return deprecatedDefaultJacobianInverse(local);
124  }
125 
126  const Implementation &impl () const { return *impl_; }
127 
128  private:
129  const Implementation *impl_;
130  };
131 
132 
133  // LocalGeometryReference
134  // -----------------------
135 
136  template< int mydim, int cdim, class Grid >
137  class LocalGeometryReference
138  : public GeometryReference< typename std::remove_const< Grid >::type::Traits::template Codim< std::remove_const< Grid >::type::dimension - mydim >::LocalGeometryImpl >
139  {
140  typedef typename std::remove_const< Grid >::type::Traits::template Codim< std::remove_const< Grid >::type::dimension - mydim >::LocalGeometryImpl Implementation;
141 
142  public:
143  LocalGeometryReference ( const Implementation &impl )
144  : GeometryReference< Implementation >( impl )
145  {}
146  };
147 
148 
149 
150  // Definitions of GeometryReference
151  // --------------------------------
152 
153  template< class Implementation >
154  const int GeometryReference< Implementation >::mydimension;
155 
156  template< class Implementation >
157  const int GeometryReference< Implementation >::coorddimension;
158 
159 } // namespace Dune
160 
161 #endif // #ifndef DUNE_GRID_ALBERTAGRID_GEOMETRYREFERENCE_HH
Wrapper and interface classes for element geometries.
GeometryType
Type representing VTK's entity geometry types.
Definition: common.hh:132
Dune namespace.
Definition: alignedallocator.hh:13
auto transpose(const Matrix &matrix)
Return the transposed of the given matrix.
Definition: transpose.hh:183
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.80.0 (May 16, 22:29, 2024)