Dune Core Modules (2.9.1)

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