dune-grid 2.9.0
geometryreference.hh
Go to the documentation of this file.
1// SPDX-FileCopyrightText: Copyright (C) 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
12#include <dune/common/typetraits.hh>
13
14#include <dune/geometry/type.hh>
15
17
18namespace Dune
19{
20
21 // GeometryReference
22 // -----------------
23
24 template< class Implementation >
26 {
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
84 {
85 return impl().global( local );
86 }
87
89 {
90 return impl().local( global );
91 }
92
94 {
95 return impl().integrationElement( local );
96 }
97
98 ctype volume () const { return impl().volume(); }
99
101 {
102 return impl().jacobianTransposed( local );
103 }
104
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
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 >
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 >
155
156 template< class Implementation >
158
159} // namespace Dune
160
161#endif // #ifndef DUNE_GRID_ALBERTAGRID_GEOMETRYREFERENCE_HH
Include standard header files.
Definition: agrid.hh:60
GeometryType
Type representing VTK's entity geometry types.
Definition: common.hh:132
Definition: geometryreference.hh:26
static const int mydimension
Definition: geometryreference.hh:30
ctype integrationElement(const LocalCoordinate &local) const
Definition: geometryreference.hh:93
ctype volume() const
Definition: geometryreference.hh:98
const Implementation & impl() const
Definition: geometryreference.hh:126
JacobianInverse jacobianInverse(const LocalCoordinate &local) const
Definition: geometryreference.hh:118
GlobalCoordinate center() const
Definition: geometryreference.hh:81
Implementation::JacobianTransposed JacobianTransposed
Definition: geometryreference.hh:39
GeometryReference(const Implementation &impl)
Definition: geometryreference.hh:71
Std::detected_or_t< JacobianInverseDefault, JacobianInverseOfImplementation, Implementation > JacobianInverse
Definition: geometryreference.hh:69
Implementation::GlobalCoordinate GlobalCoordinate
Definition: geometryreference.hh:36
static const int coorddimension
Definition: geometryreference.hh:31
bool affine() const
Definition: geometryreference.hh:77
GlobalCoordinate corner(int i) const
Definition: geometryreference.hh:80
JacobianInverseTransposed jacobianInverseTransposed(const LocalCoordinate &local) const
Definition: geometryreference.hh:105
JacobianTransposed jacobianTransposed(const LocalCoordinate &local) const
Definition: geometryreference.hh:100
int corners() const
Definition: geometryreference.hh:79
Implementation::LocalCoordinate LocalCoordinate
Definition: geometryreference.hh:35
GlobalCoordinate global(const LocalCoordinate &local) const
Definition: geometryreference.hh:83
Std::detected_or_t< JacobianDefault, JacobianOfImplementation, Implementation > Jacobian
Definition: geometryreference.hh:68
Implementation::ctype ctype
Definition: geometryreference.hh:33
Implementation::JacobianInverseTransposed JacobianInverseTransposed
Definition: geometryreference.hh:38
Jacobian jacobian(const LocalCoordinate &local) const
Definition: geometryreference.hh:110
GeometryType type() const
Definition: geometryreference.hh:75
Definition: geometryreference.hh:139
LocalGeometryReference(const Implementation &impl)
Definition: geometryreference.hh:143
Wrapper and interface classes for element geometries.