Newer
Older
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
/***************************************************************************
tnlIdenticalGridGeometry_impl.h - description
-------------------
begin : May 1, 2013
copyright : (C) 2013 by Tomas Oberhuber
email : tomas.oberhuber@fjfi.cvut.cz
***************************************************************************/
/***************************************************************************
* *
* This program is free software; you can redistribute it and/or modify *
* it under the terms of the GNU General Public License as published by *
* the Free Software Foundation; either version 2 of the License, or *
* (at your option) any later version. *
* *
***************************************************************************/
#ifndef TNLIDENTICALGRIDGEOMETRY_IMPL_H_
#define TNLIDENTICALGRIDGEOMETRY_IMPL_H_
#include <core/tnlFile.h>
#include <core/tnlAssert.h>
template< typename Real,
typename Device,
typename Index >
void tnlIdenticalGridGeometry< 2, Real, Device, Index > :: setParametricStep( const tnlTuple< 2, Real >& parametricStep )
{
this -> parametricStep = parametricStep;
this -> elementMeasure - this -> parametricStep. x() * this -> parametricStep. y();
}
template< typename Real,
typename Device,
typename Index >
void tnlIdenticalGridGeometry< 2, Real, Device, Index > :: getElementCoordinates( const Index j,
const Index i,
tnlTuple< 2, Real >& coordinates ) const
{
coordinates. x() = i * parametricStep. x();
coordinates. y() = j * parametricStep. y();
}
template< typename Real,
typename Device,
typename Index >
Real tnlIdenticalGridGeometry< 2, Real, Device, Index > :: getElementMeasure( const Index j,
const Index i ) const
{
return elementMeasure;
}
template< typename Real,
typename Device,
typename Index >
template< Index dy, Index dx >
Real tnlIdenticalGridGeometry< 2, Real, Device, Index > :: getElementsDistance( const Index j,
const Index i ) const
{
if( dy == 0 && dx == 1 )
return parametricStep. x();
if( dy == 1 && dx == 0 )
return parametricStep. y();
const Real x = dx * parametricStep. x();
const Real y = dy * parametricStep. y();
return sqrt( dx * dx + dy * dy );
}
template< typename Real,
typename Device,
typename Index >
template< Index dy, Index dx >
void tnlIdenticalGridGeometry< 2, Real, Device, Index > :: getEdgeCoordinates( const Index j,
const Index i,
tnlTuple< 2, Real >& coordinates ) const
{
coordinates. x() = origin. x() + ( i + 0.5 * ( 1.0 + dx ) ) * parametricStep. x();
coordinates. y() = origin. y() + ( j + 0.5 * ( 1.0 + dy ) ) * parametricStep. y();
}
template< typename Real,
typename Device,
typename Index >
template< int dy, int dx >
Real tnlIdenticalGridGeometry< 2, Real, Device, Index > :: getEdgeLength( const Index j,
const Index i ) const
{
if( dy == 0 && dx == 1 )
return parametricStep. y();
if( dy == 1 && dx == 0 )
return parametricStep. x();
tnlAssert( false, cerr << "Bad values of dx and dy - dx = " << dx << " dy = " << dy );
}
template< typename Real,
typename Device,
typename Index >
template< int dy, int dx >
void tnlIdenticalGridGeometry< 2, Real, Device, Index > :: getEdgeNormal( const Index j,
const Index i,
tnlTuple< 2, Real >& normal ) const
{
tnlAssert( ( dx == 0 || dx == 1 || dx == -1 ||
dy == 0 || dy == 1 || dy == -1 ) &&
dx * dy == 0, cerr << " dx = " << dx << " dy = " << dy << endl );
normal. x() = dx;
normal. y() = dy;
}
template< typename Real,
typename Device,
typename Index >
bool tnlIdenticalGridGeometry< 2, Real, Device, Index > :: save( tnlFile& file ) const
{
return true;
};
template< typename Real,
typename Device,
typename Index >
bool tnlIdenticalGridGeometry< 2, Real, Device, Index > :: load( tnlFile& file )
{
return true;
};
#endif /* TNLIDENTICALGRIDGEOMETRY_IMPL_H_ */