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