dune-fem 2.12-git
Loading...
Searching...
No Matches
piolatransformation.hh
Go to the documentation of this file.
1#ifndef DUNE_FEM_SPACE_BASISFUNCTIONSET_PIOLATRANSFORMATION_HH
2#define DUNE_FEM_SPACE_BASISFUNCTIONSET_PIOLATRANSFORMATION_HH
3
4#include <algorithm>
5
10
12
13namespace Dune
14{
15
16 namespace Fem
17 {
18
19
20 // usefull implementations
21 // -----------------------
22
23 template< class Mat >
24 double determinante ( const Mat &m )
25 { return m.det(); }
26
27 template< class F, int d, int l >
29 { return m.determinant(); }
30
31 template< class F, int d >
33 { return m.determinant(); }
34
35
36 // internal forward declaration
37 // ----------------------------
38
39 template< class Geometry, int dimRange >
40 class InversePiolaTransformation;
41
42
43 // PiolaTransformation
44 // -------------------
45
46 template< class Geometry, int dimRange >
48 {
50
51 static const int dimDomain = Geometry::GlobalCoordinate::dimension;
52 typedef typename Geometry::JacobianTransposed JacobianTransposed;
53
54 static_assert( dimRange % dimDomain == 0, "PiolaTransformation can only be applied if dimRange is a multiple of dimDomain." );
55
56 typedef typename FieldTraits< JacobianTransposed >::real_type real_type;
57 static const int blocks = dimRange / dimDomain;
58
59 public:
61
62 template< class Point >
63 PiolaTransformation ( const Geometry &geo, const Point &p )
64 : gjt_( geo.jacobianTransposed( p ) ),
65 detInv_( 1.0 / determinante( gjt_ ) )
66 {
67 }
68
69 template< class F >
71 {
73 if constexpr ( dimDomain == dimRange )
74 {
75 gjt_.mtv( d, ret );
76 }
77 else
78 {
80 for( int r = 0; r < blocks; ++r )
81 {
82 std::copy_n( d.begin() + r*dimDomain, dimDomain, arg.begin() );
83 gjt_.mtv( arg, dest );
84 std::copy_n( dest.begin(), dimDomain, ret.begin() + r*dimDomain );
85 }
86 }
87 ret *= detInv_;
88 return ret;
89 }
90
91 template< class F >
93 {
95 if constexpr ( dimDomain == dimRange )
96 {
97 gjt_.mv( d, ret );
98 }
99 else
100 {
102 for( int r = 0; r < blocks; ++r )
103 {
104 std::copy_n( ret.begin() + r*dimDomain, dimDomain, arg.begin() );
105 gjt_.mv( arg, dest );
106 std::copy_n( dest.begin(), dimDomain, ret.begin() + r*dimDomain );
107 }
108 }
109 ret *= detInv_;
110 return ret;
111 }
112
113 template< class F >
115 {
118
119 for( std::size_t r = 0; r < dimDomain; ++r )
120 {
122 for( std::size_t b = 0; b < blocks; ++b )
123 {
124 std::copy_n( col.begin() + b*dimDomain, dimDomain, arg.begin() );
125 gjt_.mtv( arg, dest );
126 std::copy_n( dest.begin(), dimDomain, col.begin() + b*dimDomain );
127 }
128 }
129
130 ret *= detInv_;
131 return ret;
132 }
133
134 template< class F >
136 {
139 for( std::size_t r = 0; r < dimDomain; ++r )
140 {
142 for( std::size_t b = 0; b < blocks; ++b )
143 {
144 std::copy_n( col.begin() + b*dimDomain, dimDomain, arg.begin() );
145 gjt_.mv( arg, dest );
146 std::copy_n( dest.begin(), dimDomain, col.begin() + b*dimDomain );
147 }
148 }
149 ret *= detInv_;
150 return ret;
151 }
152
153 protected:
154 JacobianTransposed gjt_;
155 real_type detInv_;
156 };
157
158
159
160 // InverseTransformationType
161 // -------------------------
162
163 template< class Geometry, int dimRange >
165 {
167
168 static const int dimDomain = Geometry::GlobalCoordinate::dimension;
169 typedef typename Geometry::JacobianInverseTransposed JacobianInverseTransposed;
170
171 static_assert( dimRange % dimDomain == 0, "PiolaTransformation can only be applied if dimRange is a multiple of dimDomain." );
172
174 static const int blocks = dimRange / dimDomain;
175
176 public:
178
179 template< class Point >
180 InversePiolaTransformation ( const Geometry &geo, const Point &p )
181 : gjit_( geo.jacobianInverseTransposed( p ) ),
182 detInv_( 1.0 / determinante( gjit_ ) )
183 {}
184
185 template< class F >
187 {
190 for( std::size_t r = 0; r < blocks; ++r )
191 {
192 std::copy_n( d.begin() + r*dimDomain, dimDomain, arg.begin() );
193 gjit_.mtv( arg, dest );
194 std::copy_n( dest.begin(), dimDomain, ret.begin() + r*dimDomain );
195 }
196 ret *= detInv_;
197 return ret;
198 }
199
200 template< class F >
202 {
205 for( std::size_t r = 0; r < blocks; ++r )
206 {
207 std::copy_n( ret.begin() + r*dimDomain, dimDomain, arg.begin() );
208 gjit_.mv( arg, dest );
209 std::copy_n( dest.begin(), dimDomain, ret.begin() + r*dimDomain );
210 }
211 ret *= detInv_;
212 return ret;
213 }
214
215 template< class F >
217 {
220
221 for( std::size_t r = 0; r < dimDomain; ++r )
222 {
224 for( std::size_t b = 0; b < blocks; ++b )
225 {
226 std::copy_n( col.begin() + b*dimDomain, dimDomain, arg.begin() );
227 gjit_.mtv( arg, dest );
228 std::copy_n( dest.begin(), dimDomain, col.begin() + b*dimDomain );
229 }
230 }
231
232 ret *= detInv_;
233 return ret;
234 }
235
236 template< class F >
238 {
241 for( std::size_t r = 0; r < dimDomain; ++r )
242 {
244 for( std::size_t b = 0; b < blocks; ++b )
245 {
246 std::copy_n( col.begin() + b*dimDomain, dimDomain, arg.begin() );
247 gjit_.mv( arg, dest );
248 std::copy_n( dest.begin(), dimDomain, col.begin() + b*dimDomain );
249 }
250 }
251 ret *= detInv_;
252 return ret;
253 }
254
255 protected:
256 JacobianInverseTransposed gjit_;
257 real_type detInv_;
258 };
259
260 } // namespace Fem
261
262} // namespace Dune
263
264#endif // #ifndef DUNE_FEM_SPACE_BASISFUNCTIONSET_PIOLATRANSFORMATION_HH
Col col
double determinante(const Mat &m)
Definition piolatransformation.hh:24
field_type determinant(bool doPivoting=true) const
static constexpr int dimension
constexpr Iterator begin()
Implementation::JacobianTransposed JacobianTransposed
Implementation::JacobianInverseTransposed JacobianInverseTransposed
Definition fmatrixcol.hh:16
Definition piolatransformation.hh:165
InversePiolaTransformation(const Geometry &geo, const Point &p)
Definition piolatransformation.hh:180
FieldVector< F, dimRange > apply_t(const FieldVector< F, dimRange > &d) const
Definition piolatransformation.hh:201
real_type detInv_
Definition piolatransformation.hh:257
PiolaTransformation< Geometry, dimRange > InverseTransformationType
Definition piolatransformation.hh:177
FieldMatrix< F, dimRange, dimDomain > apply(const FieldMatrix< F, dimRange, dimDomain > &d) const
Definition piolatransformation.hh:216
FieldVector< F, dimRange > apply(const FieldVector< F, dimRange > &d) const
Definition piolatransformation.hh:186
FieldMatrix< F, dimRange, dimDomain > apply_t(const FieldMatrix< F, dimRange, dimDomain > &d) const
Definition piolatransformation.hh:237
JacobianInverseTransposed gjit_
Definition piolatransformation.hh:256
Definition piolatransformation.hh:48
FieldMatrix< F, dimRange, dimDomain > apply_t(const FieldMatrix< F, dimRange, dimDomain > &d) const
Definition piolatransformation.hh:135
FieldVector< F, dimRange > apply_t(const FieldVector< F, dimRange > &d) const
Definition piolatransformation.hh:92
PiolaTransformation(const Geometry &geo, const Point &p)
Definition piolatransformation.hh:63
JacobianTransposed gjt_
Definition piolatransformation.hh:154
InversePiolaTransformation< Geometry, dimRange > InverseTransformationType
Definition piolatransformation.hh:60
FieldMatrix< F, dimRange, dimDomain > apply(const FieldMatrix< F, dimRange, dimDomain > &d) const
Definition piolatransformation.hh:114
FieldVector< F, dimRange > apply(const FieldVector< F, dimRange > &d) const
Definition piolatransformation.hh:70
real_type detInv_
Definition piolatransformation.hh:155
T copy_n(T... args)