Dune Core Modules (2.4.2)

transformation.hh
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
7
8#include <dune/grid/albertagrid/misc.hh>
9
10#if HAVE_ALBERTA
11
12namespace Dune
13{
14
15 class AlbertaTransformation
16 {
17 typedef Alberta::GlobalSpace GlobalSpace;
18
19 public:
20 typedef Alberta::Real ctype;
21
22 static const int dimension = Alberta::dimWorld;
23
24 typedef FieldVector< ctype, dimension > WorldVector;
25
26 explicit
27 AlbertaTransformation ( const Alberta::AffineTransformation *trafo = NULL )
28 : matrix_( (trafo != NULL ? trafo->M : GlobalSpace::identityMatrix()) ),
29 shift_( (trafo != NULL ? trafo->t : GlobalSpace::nullVector()) )
30 {}
31
32 AlbertaTransformation ( const GlobalSpace::Matrix &matrix,
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
Implements a vector constructed from a given type representing a field and a compile-time given size.
Dune namespace.
Definition: alignment.hh:10
Creative Commons License   |  Legal Statements / Impressum  |  Hosted by TU Dresden  |  generated with Hugo v0.111.3 (Dec 21, 23:30, 2024)