dune-grid  2.2.1
alugrid/common/transformation.hh
Go to the documentation of this file.
1 #ifndef DUNE_ALUGRID_TRANSFORMATION_HH
2 #define DUNE_ALUGRID_TRANSFORMATION_HH
3 
4 #include <dune/common/fvector.hh>
5 #include <dune/common/fmatrix.hh>
6 
7 #if HAVE_ALUGRID
8 
9 namespace Dune
10 {
11 
12  template< class ctype, int dimw >
13  struct ALUGridTransformation
14  {
15  static const int dimension = dimw;
16 
17  typedef FieldVector< ctype, dimension > WorldVector;
18  typedef FieldMatrix< ctype, dimension, dimension > WorldMatrix;
19 
20  ALUGridTransformation ( const WorldMatrix &matrix, const WorldVector &shift )
21  : matrix_( matrix ),
22  shift_( shift )
23  {}
24 
25  WorldVector evaluate ( const WorldVector &x ) const
26  {
27  WorldVector y = shift_;
28  matrix_.umv( x, y );
29  return y;
30  }
31 
32  WorldVector evaluateInverse ( const WorldVector &y ) const
33  {
34  // Note: We assume the matrix to be orthogonal, here
35  WorldVector ys = y - shift_;
36  WorldVector x;
37  matrix_.mtv( ys, x );
38  return x;
39  }
40 
41  private:
42  WorldMatrix matrix_;
43  WorldVector shift_;
44  };
45 
46 }
47 
48 #endif // #if HAVE_ALUGRID
49 
50 #endif // #ifndef DUNE_ALUGRID_TRANSFORMATION_HH