dune-grid
2.11
Toggle main menu visibility
Loading...
Searching...
No Matches
dune
grid
albertagrid
transformation.hh
Go to the documentation of this file.
1
// SPDX-FileCopyrightText: Copyright © 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
10
#include <
dune/grid/albertagrid/misc.hh
>
11
12
#if HAVE_ALBERTA
13
14
namespace
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
misc.hh
Dune
Include standard header files.
Definition
agrid.hh:60
Dune::Alberta::AffineTransformation
ALBERTA AFF_TRAFO AffineTransformation
Definition
misc.hh:52
Dune::Alberta::Real
ALBERTA REAL Real
Definition
misc.hh:48
Dune::Alberta::dimWorld
static const int dimWorld
Definition
misc.hh:46
Dune::Alberta::GlobalSpace
Definition
misc.hh:102
Dune::Alberta::GlobalSpace::Matrix
GlobalMatrix Matrix
Definition
misc.hh:106
Dune::Alberta::GlobalSpace::Vector
GlobalVector Vector
Definition
misc.hh:107
Dune::AlbertaTransformation::AlbertaTransformation
AlbertaTransformation(const Alberta::AffineTransformation *trafo=NULL)
Definition
transformation.hh:29
Dune::AlbertaTransformation::dimension
static const int dimension
Definition
transformation.hh:24
Dune::AlbertaTransformation::WorldVector
FieldVector< ctype, dimension > WorldVector
Definition
transformation.hh:26
Dune::AlbertaTransformation::AlbertaTransformation
AlbertaTransformation(const GlobalSpace::Matrix &matrix, const GlobalSpace::Vector &shift)
Definition
transformation.hh:34
Dune::AlbertaTransformation::ctype
Alberta::Real ctype
Definition
transformation.hh:22
Dune::AlbertaTransformation::evaluateInverse
WorldVector evaluateInverse(const WorldVector &y) const
Definition
transformation.hh:53
Dune::AlbertaTransformation::evaluate
WorldVector evaluate(const WorldVector &x) const
Definition
transformation.hh:40
Generated by
1.17.0