opm-grid
Toggle main menu visibility
Loading...
Searching...
No Matches
CartesianIndexMapper.hpp
1
#ifndef OPM_CPGRIDCARTESIANINDEXMAPPER_HEADER
2
#define OPM_CPGRIDCARTESIANINDEXMAPPER_HEADER
3
4
#include <array>
5
#include <cassert>
6
#include <stdexcept>
7
8
#include <opm/grid/common/CartesianIndexMapper.hpp>
9
#include <opm/grid/CpGrid.hpp>
10
11
namespace
Dune
12
{
13
template
<>
14
class
CartesianIndexMapper<
CpGrid
>
15
{
16
public
:
17
static
const
int
dimension = 3 ;
18
protected
:
19
typedef
CpGrid
Grid;
20
const
Grid& grid_;
21
const
int
cartesianSize_;
22
23
int
computeCartesianSize()
const
24
{
25
int
size =
cartesianDimensions
()[ 0 ];
26
for
(
int
d=1; d<dimension; ++d )
27
size *=
cartesianDimensions
()[ d ];
28
return
size;
29
}
30
31
public
:
32
explicit
CartesianIndexMapper
(
const
Grid& grid )
33
: grid_( grid ),
34
cartesianSize_( computeCartesianSize() )
35
{
36
}
37
38
const
std::array<int, dimension>&
cartesianDimensions
()
const
39
{
40
// For now, return the level-zero logical Cartesian size.
41
// Note: grid_.logicalCartesianSize() can vary depending on how refinement was applied
42
// (e.g., via addLgrsUpdateLeafView(...), adapt(), or globalRefine()).
43
// This includes cases where all elements of the level-zero grid have been refined.
44
return
grid_.currentData().front()->logicalCartesianSize();
45
}
46
47
int
cartesianSize
()
const
48
{
49
return
cartesianSize_;
50
}
51
52
int
compressedSize
()
const
53
{
54
return
grid_.globalCell().size();
55
}
56
57
int
cartesianIndex
(
const
int
compressedElementIndex )
const
58
{
59
assert( compressedElementIndex >= 0 && compressedElementIndex <
compressedSize
() );
60
return
grid_.globalCell()[ compressedElementIndex ];
61
}
62
63
void
cartesianCoordinate
(
const
int
compressedElementIndex, std::array<int,dimension>& coords)
const
64
{
65
grid_.getIJK( compressedElementIndex, coords );
66
}
67
};
68
69
}
// end namespace Opm
70
#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::CpGrid
[ provides Dune::Grid ]
Definition
CpGrid.hpp:203
Dune
The namespace Dune is the main namespace for all Dune code.
Definition
CartesianIndexMapper.hpp:10
opm
grid
cpgrid
CartesianIndexMapper.hpp
Generated by
1.17.0