dune-grid 2.9.0
transformation.hh
Go to the documentation of this file.
1// SPDX-FileCopyrightText: Copyright (C) DUNE Project contributors, see file LICENSE.md in module root
2// SPDX-License-Identifier: LicenseRef-GPL-2.0-only-with-DUNE-exception
3// -*- tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*-
4// vi: set et ts=4 sw=2 sts=2:
5#ifndef DUNE_ALBERTA_TRANSFORMATION_HH
6#define DUNE_ALBERTA_TRANSFORMATION_HH
7
8#include <dune/common/fvector.hh>
9
11
12#if HAVE_ALBERTA
13
14namespace Dune
15{
16
18 {
20
21 public:
23
24 static const int dimension = Alberta::dimWorld;
25
26 typedef FieldVector< ctype, dimension > WorldVector;
27
28 explicit
30 : matrix_( (trafo != NULL ? trafo->M : GlobalSpace::identityMatrix()) ),
31 shift_( (trafo != NULL ? trafo->t : GlobalSpace::nullVector()) )
32 {}
33
35 const GlobalSpace::Vector &shift )
36 : matrix_( matrix ),
37 shift_( shift )
38 {}
39
40 WorldVector evaluate ( const WorldVector &x ) const
41 {
43 for( int i = 0; i < dimension; ++i )
44 {
45 const GlobalSpace::Vector &row = matrix_[ i ];
46 y[ i ] = shift_[ i ];
47 for( int j = 0; j < dimension; ++j )
48 y[ i ] += row[ j ] * x[ j ];
49 }
50 return y;
51 }
52
54 {
55 // Note: ALBERTA requires the matrix to be orthogonal
56 WorldVector x( ctype( 0 ) );
57 for( int i = 0; i < dimension; ++i )
58 {
59 const GlobalSpace::Vector &row = matrix_[ i ];
60 const ctype v = y[ i ] - shift_[ i ];
61 for( int j = 0; j < dimension; ++j )
62 x[ j ] += row[ j ] * v;
63 }
64 return x;
65 }
66
67 private:
68 const GlobalSpace::Matrix &matrix_;
69 const GlobalSpace::Vector &shift_;
70 };
71
72}
73
74#endif // #if HAVE_ALBERTA
75
76#endif // #ifndef DUNE_ALBERTA_TRANSFORMATION_HH
Include standard header files.
Definition: agrid.hh:60
ALBERTA AFF_TRAFO AffineTransformation
Definition: misc.hh:52
ALBERTA REAL Real
Definition: misc.hh:48
static const int dimWorld
Definition: misc.hh:46
Definition: misc.hh:102
GlobalMatrix Matrix
Definition: misc.hh:106
GlobalVector Vector
Definition: misc.hh:107
Definition: transformation.hh:18
AlbertaTransformation(const Alberta::AffineTransformation *trafo=NULL)
Definition: transformation.hh:29
static const int dimension
Definition: transformation.hh:24
FieldVector< ctype, dimension > WorldVector
Definition: transformation.hh:26
AlbertaTransformation(const GlobalSpace::Matrix &matrix, const GlobalSpace::Vector &shift)
Definition: transformation.hh:34
Alberta::Real ctype
Definition: transformation.hh:22
WorldVector evaluateInverse(const WorldVector &y) const
Definition: transformation.hh:53
WorldVector evaluate(const WorldVector &x) const
Definition: transformation.hh:40