Merge pull request #1143 from joakim-hove/box-data-index
Add data_index to Box::index_list
This commit is contained in:
@@ -29,9 +29,10 @@ namespace Opm {
|
||||
class Box {
|
||||
public:
|
||||
|
||||
struct index_pair {
|
||||
std::size_t global;
|
||||
std::size_t active;
|
||||
struct cell_index {
|
||||
std::size_t global_index;
|
||||
std::size_t active_index;
|
||||
std::size_t data_index;
|
||||
};
|
||||
|
||||
Box(const EclipseGrid& grid);
|
||||
@@ -39,7 +40,7 @@ namespace Opm {
|
||||
size_t size() const;
|
||||
bool isGlobal() const;
|
||||
size_t getDim(size_t idim) const;
|
||||
const std::vector<index_pair>& index_list() const;
|
||||
const std::vector<cell_index>& index_list() const;
|
||||
const std::vector<size_t>& getIndexList() const;
|
||||
bool equal(const Box& other) const;
|
||||
|
||||
@@ -60,7 +61,7 @@ namespace Opm {
|
||||
|
||||
bool m_isGlobal;
|
||||
std::vector<size_t> global_index_list;
|
||||
std::vector<index_pair> m_index_list;
|
||||
std::vector<cell_index> m_index_list;
|
||||
|
||||
int lower(int dim) const;
|
||||
int upper(int dim) const;
|
||||
|
||||
@@ -116,7 +116,7 @@ namespace Opm {
|
||||
return global_index_list;
|
||||
}
|
||||
|
||||
const std::vector<Box::index_pair>& Box::index_list() const {
|
||||
const std::vector<Box::cell_index>& Box::index_list() const {
|
||||
return m_index_list;
|
||||
}
|
||||
|
||||
@@ -135,8 +135,12 @@ namespace Opm {
|
||||
size_t g = i * m_stride[0] + j*m_stride[1] + k*m_stride[2];
|
||||
|
||||
global_index_list.push_back(g);
|
||||
if (this->grid.cellActive(g))
|
||||
m_index_list.push_back({g,this->grid.activeIndex(g)});
|
||||
if (this->grid.cellActive(g)) {
|
||||
std::size_t global_index = g;
|
||||
std::size_t active_index = this->grid.activeIndex(g);
|
||||
std::size_t data_index = ii + ij*this->m_dims[0] + ik*this->m_dims[0]*this->m_dims[1];
|
||||
m_index_list.push_back({global_index, active_index, data_index});
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -189,6 +189,17 @@ BOOST_AUTO_TEST_CASE(TestKeywordBox2) {
|
||||
const auto& box = boxManager.getActiveBox();
|
||||
|
||||
for (const auto& p : box.index_list())
|
||||
BOOST_CHECK_EQUAL(p.active + 1, p.global);
|
||||
BOOST_CHECK_EQUAL(p.active_index + 1, p.global_index);
|
||||
BOOST_CHECK_EQUAL(box.index_list().size() + 1, grid.getCartesianSize());
|
||||
|
||||
|
||||
Opm::Box box2(grid,9,9,9,9,0,9);
|
||||
const auto& il = box2.index_list();
|
||||
BOOST_CHECK_EQUAL(il.size(), 10);
|
||||
|
||||
for (std::size_t i=0; i < 10; i++) {
|
||||
BOOST_CHECK_EQUAL(il[i].data_index, i);
|
||||
BOOST_CHECK_EQUAL(il[i].global_index, 99 + i*100);
|
||||
BOOST_CHECK_EQUAL(il[i].active_index, 98 + i*100);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user