opm-grid
Toggle main menu visibility
Loading...
Searching...
No Matches
cartesianindexmapper.hh
1
#ifndef OPM_POLYHEDRALCARTESIANINDEXMAPPER_HEADER
2
#define OPM_POLYHEDRALCARTESIANINDEXMAPPER_HEADER
3
4
#include <opm/grid/common/CartesianIndexMapper.hpp>
5
#include <opm/grid/polyhedralgrid.hh>
6
7
namespace
Dune
8
{
9
template
<
int
dim,
int
dimworld,
typename
coord_t >
10
class
CartesianIndexMapper<
PolyhedralGrid
< dim, dimworld, coord_t > >
11
{
12
typedef
PolyhedralGrid< dim, dimworld, coord_t >
Grid;
13
14
const
Grid& grid_;
15
const
int
cartesianSize_;
16
17
int
computeCartesianSize()
const
18
{
19
int
size =
cartesianDimensions
()[ 0 ];
20
for
(
int
d=1; d<dim; ++d )
21
size *=
cartesianDimensions
()[ d ];
22
return
size ;
23
}
24
public
:
25
static
const
int
dimension = Grid :: dimension ;
26
27
explicit
CartesianIndexMapper
(
const
Grid& grid )
28
: grid_( grid ),
29
cartesianSize_( computeCartesianSize() )
30
{}
31
32
const
std::array<int, dimension>&
cartesianDimensions
()
const
33
{
34
return
grid_.logicalCartesianSize();
35
}
36
37
int
cartesianSize
()
const
38
{
39
return
cartesianSize_;
40
}
41
42
int
compressedSize
()
const
43
{
44
return
grid_.size( 0 );
45
}
46
47
int
cartesianIndex
(
const
int
compressedElementIndex )
const
48
{
49
assert( compressedElementIndex >= 0 && compressedElementIndex <
compressedSize
() );
50
return
grid_.globalCell()[ compressedElementIndex ];
51
}
52
53
void
cartesianCoordinate
(
const
int
compressedElementIndex, std::array<int,dimension>& coords)
const
54
{
55
int
gc =
cartesianIndex
( compressedElementIndex );
56
if
( dimension >=2 )
57
{
58
for
(
int
d=0; d<dimension-2; ++d )
59
{
60
coords[d] = gc %
cartesianDimensions
()[d]; gc /=
cartesianDimensions
()[d];
61
}
62
63
coords[dimension-2] = gc %
cartesianDimensions
()[dimension-2];
64
coords[dimension-1] = gc /
cartesianDimensions
()[dimension-1];
65
}
66
else
67
coords[ 0 ] = gc ;
68
}
69
};
70
71
}
// end namespace Opm
72
#endif
Dune::CartesianIndexMapper::cartesianIndex
int cartesianIndex(const int) const
return index of the cells in the logical Cartesian grid
Definition
CartesianIndexMapper.hpp:47
Dune::CartesianIndexMapper::compressedSize
int compressedSize() const
return number of cells in the active grid
Definition
CartesianIndexMapper.hpp:41
Dune::CartesianIndexMapper::cartesianDimensions
const std::array< int, dimension > & cartesianDimensions() const
return Cartesian dimensions, i.e.
Definition
CartesianIndexMapper.hpp:28
Dune::CartesianIndexMapper::CartesianIndexMapper
CartesianIndexMapper(const Grid &)
constructor taking grid
Definition
CartesianIndexMapper.hpp:22
Dune::CartesianIndexMapper::cartesianSize
int cartesianSize() const
return total number of cells in the logical Cartesian grid
Definition
CartesianIndexMapper.hpp:35
Dune::CartesianIndexMapper::cartesianCoordinate
void cartesianCoordinate(const int, std::array< int, dimension > &) const
return Cartesian coordinate, i.e.
Definition
CartesianIndexMapper.hpp:53
Dune::PolyhedralGrid
identical grid wrapper
Definition
grid.hh:159
Dune
The namespace Dune is the main namespace for all Dune code.
Definition
CartesianIndexMapper.hpp:10
opm
grid
polyhedralgrid
cartesianindexmapper.hh
Generated by
1.17.0