dune-grid  2.6-git
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_ALBERTA_TRANSFORMATION_HH
4 #define DUNE_ALBERTA_TRANSFORMATION_HH
5 
6 #include <dune/common/fvector.hh>
7 
9 
10 #if HAVE_ALBERTA
11 
12 namespace Dune
13 {
14 
16  {
18 
19  public:
21 
22  static const int dimension = Alberta::dimWorld;
23 
24  typedef FieldVector< ctype, dimension > WorldVector;
25 
26  explicit
28  : matrix_( (trafo != NULL ? trafo->M : GlobalSpace::identityMatrix()) ),
29  shift_( (trafo != NULL ? trafo->t : GlobalSpace::nullVector()) )
30  {}
31 
33  const GlobalSpace::Vector &shift )
34  : matrix_( matrix ),
35  shift_( shift )
36  {}
37 
38  WorldVector evaluate ( const WorldVector &x ) const
39  {
40  WorldVector y;
41  for( int i = 0; i < dimension; ++i )
42  {
43  const GlobalSpace::Vector &row = matrix_[ i ];
44  y[ i ] = shift_[ i ];
45  for( int j = 0; j < dimension; ++j )
46  y[ i ] += row[ j ] * x[ j ];
47  }
48  return y;
49  }
50 
51  WorldVector evaluateInverse ( const WorldVector &y ) const
52  {
53  // Note: ALBERTA requires the matrix to be orthogonal
54  WorldVector x( ctype( 0 ) );
55  for( int i = 0; i < dimension; ++i )
56  {
57  const GlobalSpace::Vector &row = matrix_[ i ];
58  const ctype v = y[ i ] - shift_[ i ];
59  for( int j = 0; j < dimension; ++j )
60  x[ j ] += row[ j ] * v;
61  }
62  return x;
63  }
64 
65  private:
66  const GlobalSpace::Matrix &matrix_;
67  const GlobalSpace::Vector &shift_;
68  };
69 
70 }
71 
72 #endif // #if HAVE_ALBERTA
73 
74 #endif // #ifndef DUNE_ALBERTA_TRANSFORMATION_HH
Definition: misc.hh:99
FieldVector< ctype, dimension > WorldVector
Definition: transformation.hh:24
static const int dimWorld
Definition: misc.hh:44
WorldVector evaluateInverse(const WorldVector &y) const
Definition: transformation.hh:51
AlbertaTransformation(const GlobalSpace::Matrix &matrix, const GlobalSpace::Vector &shift)
Definition: transformation.hh:32
static const int dimension
Definition: transformation.hh:22
WorldVector evaluate(const WorldVector &x) const
Definition: transformation.hh:38
GlobalMatrix Matrix
Definition: misc.hh:104
ALBERTA REAL Real
Definition: misc.hh:46
Definition: transformation.hh:15
AlbertaTransformation(const Alberta::AffineTransformation *trafo=NULL)
Definition: transformation.hh:27
ALBERTA AFF_TRAFO AffineTransformation
Definition: misc.hh:50
GlobalVector Vector
Definition: misc.hh:105
Alberta::Real ctype
Definition: transformation.hh:20
Include standard header files.
Definition: agrid.hh:58