1#ifndef DUNE_FEM_SPACE_BASISFUNCTIONSET_PIOLATRANSFORMATION_HH
2#define DUNE_FEM_SPACE_BASISFUNCTIONSET_PIOLATRANSFORMATION_HH
11#include <dune/fem/common/fmatrixcol.hh>
24 double determinante (
const Mat &m )
27 template<
class F,
int d,
int l >
28 double determinante (
const FieldMatrix< F, d, l > &m )
29 {
return m.determinant(); }
31 template<
class F,
int d >
32 double determinante (
const DiagonalMatrix< F, d > &m )
33 {
return m.determinant(); }
39 template<
class Geometry,
int dimRange >
40 class InversePiolaTransformation;
46 template<
class Geometry,
int dimRange >
47 class PiolaTransformation
49 typedef PiolaTransformation< Geometry, dimRange > ThisType;
54 static_assert( dimRange % dimDomain == 0,
"PiolaTransformation can only be applied if dimRange is a multiple of dimDomain." );
56 typedef typename FieldTraits< JacobianTransposed >::real_type real_type;
57 static const int blocks = dimRange / dimDomain;
60 typedef InversePiolaTransformation< Geometry, dimRange > InverseTransformationType;
62 template<
class Po
int >
63 PiolaTransformation (
const Geometry &geo,
const Point &p )
64 : gjt_( geo.jacobianTransposed( p ) ),
65 detInv_( 1.0 / determinante( gjt_ ) )
69 FieldVector< F, dimRange > apply (
const FieldVector< F, dimRange > &d )
const
71 FieldVector< F, dimRange > ret( d );
72 FieldVector< F, dimDomain > arg, dest;
73 for( std::size_t r = 0; r < blocks; ++r )
75 std::copy_n( d.begin() + r*dimDomain, dimDomain, arg.begin() );
76 gjt_.mtv( arg, dest );
77 std::copy_n( dest.begin(), dimDomain, ret.begin() + r*dimDomain );
84 FieldVector< F, dimRange > apply_t (
const FieldVector< F, dimRange > &d )
const
86 FieldVector< F, dimRange > ret( d );
87 FieldVector< F, dimDomain > arg, dest;
88 for( std::size_t r = 0; r < blocks; ++r )
90 std::copy_n( ret.begin() + r*dimDomain, dimDomain, arg.begin() );
92 std::copy_n( dest.begin(), dimDomain, ret.begin() + r*dimDomain );
99 FieldMatrix< F, dimRange, dimDomain > apply (
const FieldMatrix< F, dimRange, dimDomain > &d )
const
101 FieldMatrix< F, dimRange, dimDomain > ret( d );
102 FieldVector< F, dimDomain > arg, dest;
104 for( std::size_t r = 0; r < dimDomain; ++r )
106 FieldMatrixColumn< FieldMatrix< F, dimRange, dimDomain > > col( ret, r );
107 for( std::size_t b = 0; b < blocks; ++b )
109 std::copy_n( col.begin() + b*dimDomain, dimDomain, arg.begin() );
110 gjt_.mv( arg, dest );
111 std::copy_n( dest.begin(), dimDomain, col.begin() + b*dimDomain );
120 FieldMatrix< F, dimRange, dimDomain > apply_t (
const FieldMatrix< F, dimRange, dimDomain > &d )
const
122 FieldMatrix< F, dimRange, dimDomain > ret( d );
123 FieldVector< F, dimDomain > arg, dest;
124 for( std::size_t r = 0; r < dimDomain; ++r )
126 FieldMatrixColumn< FieldMatrix< F, dimRange, dimDomain > > col( ret, r );
127 for( std::size_t b = 0; b < blocks; ++b )
129 std::copy_n( col.begin() + b*dimDomain, dimDomain, arg.begin() );
130 gjt_.mtv( arg, dest );
131 std::copy_n( dest.begin(), dimDomain, col.begin() + b*dimDomain );
139 JacobianTransposed gjt_;
148 template<
class Geometry,
int dimRange >
149 class InversePiolaTransformation
151 typedef InversePiolaTransformation< Geometry, dimRange > ThisType;
156 static_assert( dimRange % dimDomain == 0,
"PiolaTransformation can only be applied if dimRange is a multiple of dimDomain." );
158 typedef typename FieldTraits< JacobianInverseTransposed >::real_type real_type;
159 static const int blocks = dimRange / dimDomain;
162 typedef PiolaTransformation< Geometry, dimRange > InverseTransformationType;
164 template<
class Po
int >
165 InversePiolaTransformation (
const Geometry &geo,
const Point &p )
166 : gjit_( geo.jacobianInverseTransposed( p ) ),
167 detInv_( 1.0 / determinante( gjit_ ) )
171 FieldVector< F, dimRange > apply (
const FieldVector< F, dimRange > &d )
const
173 FieldVector< F, dimRange > ret( d );
174 FieldVector< F, dimDomain > arg, dest;
175 for( std::size_t r = 0; r < blocks; ++r )
177 std::copy_n( d.begin() + r*dimDomain, dimDomain, arg.begin() );
178 gjit_.mtv( arg, dest );
179 std::copy_n( dest.begin(), dimDomain, ret.begin() + r*dimDomain );
186 FieldVector< F, dimRange > apply_t (
const FieldVector< F, dimRange > &d )
const
188 FieldVector< F, dimRange > ret( d );
189 FieldVector< F, dimDomain > arg, dest;
190 for( std::size_t r = 0; r < blocks; ++r )
192 std::copy_n( ret.begin() + r*dimDomain, dimDomain, arg.begin() );
193 gjit_.mv( arg, dest );
194 std::copy_n( dest.begin(), dimDomain, ret.begin() + r*dimDomain );
201 FieldMatrix< F, dimRange, dimDomain > apply (
const FieldMatrix< F, dimRange, dimDomain > &d )
const
203 FieldMatrix< F, dimRange, dimDomain > ret( d );
204 FieldVector< F, dimDomain > arg, dest;
206 for( std::size_t r = 0; r < dimDomain; ++r )
208 FieldMatrixColumn< FieldMatrix< F, dimRange, dimDomain > > col( ret, r );
209 for( std::size_t b = 0; b < blocks; ++b )
211 std::copy_n( col.begin() + b*dimDomain, dimDomain, arg.begin() );
212 gjit_.mv( arg, dest );
213 std::copy_n( dest.begin(), dimDomain, col.begin() + b*dimDomain );
222 FieldMatrix< F, dimRange, dimDomain > apply_t (
const FieldMatrix< F, dimRange, dimDomain > &d )
const
224 FieldMatrix< F, dimRange, dimDomain > ret( d );
225 FieldVector< F, dimDomain > arg, dest;
226 for( std::size_t r = 0; r < dimDomain; ++r )
228 FieldMatrixColumn< FieldMatrix< F, dimRange, dimDomain > > col( ret, r );
229 for( std::size_t b = 0; b < blocks; ++b )
231 std::copy_n( col.begin() + b*dimDomain, dimDomain, arg.begin() );
232 gjit_.mtv( arg, dest );
233 std::copy_n( dest.begin(), dimDomain, col.begin() + b*dimDomain );
241 JacobianInverseTransposed gjit_;
static constexpr int dimension
The size of this vector.
Definition: fvector.hh:96
Implementation::JacobianTransposed JacobianTransposed
type of jacobian transposed
Definition: geometry.hh:131
Implementation::JacobianInverseTransposed JacobianInverseTransposed
type of jacobian inverse transposed
Definition: geometry.hh:120
This file implements a quadratic diagonal matrix of fixed size.
Implements a matrix constructed from a given type representing a field and compile-time given number ...
Implements a vector constructed from a given type representing a field and a compile-time given size.
Dune namespace.
Definition: alignedallocator.hh:13