dune-fem  2.4.1-rc
transformation.hh
Go to the documentation of this file.
1 #ifndef DUNE_FEM_SPACE_BASISFUNCTIONSET_TRANSFORMATION_HH
2 #define DUNE_FEM_SPACE_BASISFUNCTIONSET_TRANSFORMATION_HH
3 
4 #include <dune/common/exceptions.hh>
5 #include <dune/common/fmatrix.hh>
6 #include <dune/common/fvector.hh>
7 
9 
10 namespace Dune
11 {
12 
13  namespace Fem
14  {
15 
16  // jacobianTransformation
17  // ----------------------
18 
19  template< class GeometryJacobianInverseTransposed, class K, int ROWS >
20  void jacobianTransformation ( const GeometryJacobianInverseTransposed &gjit,
21  const FieldMatrix< K, ROWS, GeometryJacobianInverseTransposed::cols > &a,
22  FieldMatrix< K, ROWS, GeometryJacobianInverseTransposed::rows > &b )
23  {
24  for( int r = 0; r < ROWS; ++r )
25  gjit.mv( a[ r ], b[ r ] );
26  }
27 
28 
29 
30  // JacobianTransformation
31  // ----------------------
32 
33  template< class Geometry >
35  {
36  typedef typename Geometry::LocalCoordinate LocalCoordinate;
37  typedef typename Geometry::JacobianInverseTransposed GeometryJacobianInverseTransposed;
38 
39  JacobianTransformation ( const Geometry &geometry, const LocalCoordinate &x )
40  : gjit_( geometry.jacobianInverseTransposed( x ) )
41  {}
42 
43  template< class A, class B >
44  void operator() ( const A &a, B &b ) const
45  {
46  jacobianTransformation( gjit_, a, b );
47  }
48 
49  private:
50  GeometryJacobianInverseTransposed gjit_;
51  };
52 
53 
54 
55  // hessianTransformation
56  // ---------------------
57 
58  template< class GeometryJacobianInverseTransposed, class K, int SIZE >
60  const FieldVector< FieldMatrix< K, GeometryJacobianInverseTransposed::cols, GeometryJacobianInverseTransposed::cols >, SIZE > &a,
61  FieldVector< FieldMatrix< K, GeometryJacobianInverseTransposed::rows, GeometryJacobianInverseTransposed::rows >, SIZE > &b )
62  {
63  const int dimLocal = GeometryJacobianInverseTransposed::cols;
64  const int dimGlobal = GeometryJacobianInverseTransposed::rows;
65 
66  for( int r = 0; r < SIZE; ++r )
67  {
68  // c = J^{-T} a_r^T
69  FieldMatrix< K, dimLocal, dimGlobal > c;
70  for( int i = 0; i < dimLocal; ++i )
71  gjit.mv( a[ r ][ i ], c[ i ] );
72 
73  // b_r = J^{-T} c
74  for( int i = 0; i < dimGlobal; ++i )
75  {
78  gjit.mv( ci, bi );
79  }
80 #if 0
81  b[ r ] = K( 0 );
82  for( int k = 0; k < GeometryJacobianInverseTransposed::cols; ++k )
83  {
84  FieldVector< K, GeometryJacobianInverseTransposed::rows > c;
85  gjit.mv( a[ r ][ k ], c );
86  for( int j = 0; j < GeometryJacobianInverseTransposed::rows; ++j )
87  b[ r ][ j ].axpy( gjit[ j ][ k ], c );
88  }
89 #endif
90  }
91  }
92 
93 
94 
95  // HessianTransformation
96  // ---------------------
97 
98  template< class Geometry >
100  {
101  typedef typename Geometry::LocalCoordinate LocalCoordinate;
102  typedef typename Geometry::JacobianInverseTransposed GeometryJacobianInverseTransposed;
103 
104  HessianTransformation ( const Geometry &geometry, const LocalCoordinate &x )
105  : gjit_( geometry.jacobianInverseTransposed( x ) )
106  {
107  if( !geometry.affine() )
108  DUNE_THROW( NotImplemented, "HessianTransformation not implemented for non-affine geometries." );
109  }
110 
111  template< class A, class B >
112  void operator() ( const A &a, B &b ) const
113  {
114  hessianTransformation( gjit_, a, b );
115  }
116 
117  private:
118  GeometryJacobianInverseTransposed gjit_;
119  };
120 
121  } // namespace Fem
122 
123 } // namespace Dune
124 
125 #endif // #ifndef DUNE_FEM_SPACE_BASISFUNCTIONSET_TRANSFORMATION_HH
HessianTransformation(const Geometry &geometry, const LocalCoordinate &x)
Definition: transformation.hh:104
Geometry::JacobianInverseTransposed GeometryJacobianInverseTransposed
Definition: transformation.hh:102
Geometry::LocalCoordinate LocalCoordinate
Definition: transformation.hh:36
Definition: transformation.hh:99
Geometry::JacobianInverseTransposed GeometryJacobianInverseTransposed
Definition: transformation.hh:37
Definition: transformation.hh:34
void hessianTransformation(const GeometryJacobianInverseTransposed &gjit, const FieldVector< FieldMatrix< K, GeometryJacobianInverseTransposed::cols, GeometryJacobianInverseTransposed::cols >, SIZE > &a, FieldVector< FieldMatrix< K, GeometryJacobianInverseTransposed::rows, GeometryJacobianInverseTransposed::rows >, SIZE > &b)
Definition: transformation.hh:59
void axpy(const T &a, const T &x, T &y)
Definition: space/basisfunctionset/functor.hh:37
Definition: coordinate.hh:4
void jacobianTransformation(const GeometryJacobianInverseTransposed &gjit, const FieldMatrix< K, ROWS, GeometryJacobianInverseTransposed::cols > &a, FieldMatrix< K, ROWS, GeometryJacobianInverseTransposed::rows > &b)
Definition: transformation.hh:20
Definition: fmatrixcol.hh:16
Geometry::LocalCoordinate LocalCoordinate
Definition: transformation.hh:101
void operator()(const A &a, B &b) const
Definition: transformation.hh:44
JacobianTransformation(const Geometry &geometry, const LocalCoordinate &x)
Definition: transformation.hh:39