diff --git a/opm/parser/eclipse/EclipseState/Schedule/ScheduleGrid.hpp b/opm/parser/eclipse/EclipseState/Schedule/ScheduleGrid.hpp index 5c0579111..b52597215 100644 --- a/opm/parser/eclipse/EclipseState/Schedule/ScheduleGrid.hpp +++ b/opm/parser/eclipse/EclipseState/Schedule/ScheduleGrid.hpp @@ -30,16 +30,9 @@ public: ScheduleGrid(const EclipseGrid& ecl_grid, CompletedCells& completed_cells); explicit ScheduleGrid(CompletedCells& completed_cells); - std::size_t getActiveIndex(std::size_t i, std::size_t j, std::size_t k) const; - bool isCellActive(std::size_t i, std::size_t j, std::size_t k) const; - std::size_t getGlobalIndex(std::size_t i, std::size_t j, std::size_t k) const; - double getCellDepth(std::size_t i, std::size_t j, std::size_t k) const; - std::array getCellDimensions(std::size_t i, std::size_t j, std::size_t k) const; - -private: - const CompletedCells::Cell& get_cell(std::size_t i, std::size_t j, std::size_t k) const; +private: const EclipseGrid* grid{nullptr}; CompletedCells& cells; }; diff --git a/src/opm/parser/eclipse/EclipseState/Schedule/MSW/Compsegs.cpp b/src/opm/parser/eclipse/EclipseState/Schedule/MSW/Compsegs.cpp index f80ec25a8..b19645a58 100644 --- a/src/opm/parser/eclipse/EclipseState/Schedule/MSW/Compsegs.cpp +++ b/src/opm/parser/eclipse/EclipseState/Schedule/MSW/Compsegs.cpp @@ -281,8 +281,7 @@ namespace { // will decide the segment number based on the distance in a process later. } if (!record.getItem().hasValue(0)) { // only one compsegs - - if (grid.isCellActive(I, J, K)) { + if (grid.get_cell(I, J, K).active_index.has_value()) { std::size_t seqIndex = compsegs.size(); compsegs.emplace_back( I, J, K, branch, @@ -323,7 +322,7 @@ namespace { const int i = compseg.m_i; const int j = compseg.m_j; const int k = compseg.m_k; - if (grid.isCellActive(i, j, k)) { + if (grid.get_cell(i, j, k).active_index.has_value()) { Connection& connection = new_connection_set.getFromIJK(i, j, k); connection.updateSegment(compseg.segment_number, compseg.center_depth, diff --git a/src/opm/parser/eclipse/EclipseState/Schedule/ScheduleGrid.cpp b/src/opm/parser/eclipse/EclipseState/Schedule/ScheduleGrid.cpp index 22458e2d4..b8d31c8f4 100644 --- a/src/opm/parser/eclipse/EclipseState/Schedule/ScheduleGrid.cpp +++ b/src/opm/parser/eclipse/EclipseState/Schedule/ScheduleGrid.cpp @@ -30,32 +30,6 @@ Opm::ScheduleGrid::ScheduleGrid(Opm::CompletedCells& completed_cells) : cells(completed_cells) {} -std::size_t Opm::ScheduleGrid::getActiveIndex(std::size_t i, std::size_t j, std::size_t k) const { - const auto& cell = this->get_cell(i,j,k); - return cell.active_index.value(); -} - -bool Opm::ScheduleGrid::isCellActive(std::size_t i, std::size_t j, std::size_t k) const { - const auto& cell = this->get_cell(i,j,k); - return cell.active_index.has_value(); -} - -std::size_t Opm::ScheduleGrid::getGlobalIndex(std::size_t i, std::size_t j, std::size_t k) const { - const auto& cell = this->get_cell(i,j,k); - return cell.global_index; -} - -double Opm::ScheduleGrid::getCellDepth(std::size_t i, std::size_t j, std::size_t k) const { - const auto& cell = this->get_cell(i,j,k); - return cell.depth; -} - -std::array Opm::ScheduleGrid::getCellDimensions(std::size_t i, std::size_t j, std::size_t k) const { - const auto& cell = this->get_cell(i,j,k); - return cell.dimensions; -} - - const Opm::CompletedCells::Cell& Opm::ScheduleGrid::get_cell(std::size_t i, std::size_t j, std::size_t k) const { if (this->grid) { auto [valid, cell] = this->cells.try_get(i,j,k); diff --git a/src/opm/parser/eclipse/EclipseState/Schedule/Well/Connection.cpp b/src/opm/parser/eclipse/EclipseState/Schedule/Well/Connection.cpp index be6d24b7a..8fc4ea206 100644 --- a/src/opm/parser/eclipse/EclipseState/Schedule/Well/Connection.cpp +++ b/src/opm/parser/eclipse/EclipseState/Schedule/Well/Connection.cpp @@ -94,14 +94,14 @@ Connection::Connection(const RestartIO::RstConnection& rst_connection, const Sch m_skin_factor(rst_connection.skin_factor), ijk(rst_connection.ijk), m_ctfkind(rst_connection.cf_kind), - m_global_index(grid.getGlobalIndex(this->ijk[0], this->ijk[1], this->ijk[2])), + m_global_index(grid.get_cell(this->ijk[0], this->ijk[1], this->ijk[2]).global_index), m_sort_value(rst_connection.rst_index), m_defaultSatTabId(defaultSatTabId), segment_number(rst_connection.segment) { if (this->m_defaultSatTabId) { const auto& satnum = fp.get_int("SATNUM"); - auto active_index = grid.getActiveIndex(this->ijk[0], this->ijk[1], this->ijk[2]); + auto active_index = grid.get_cell(this->ijk[0], this->ijk[1], this->ijk[2]).active_index.value(); this->sat_tableId = satnum[active_index]; } if (this->segment_number > 0) diff --git a/src/opm/parser/eclipse/EclipseState/Schedule/Well/Well.cpp b/src/opm/parser/eclipse/EclipseState/Schedule/Well/Well.cpp index 73699e717..da3c676e2 100644 --- a/src/opm/parser/eclipse/EclipseState/Schedule/Well/Well.cpp +++ b/src/opm/parser/eclipse/EclipseState/Schedule/Well/Well.cpp @@ -693,7 +693,7 @@ bool Well::updateConnections(std::shared_ptr connections_arg, c bool update = this->updateConnections(connections_arg, false); if (this->pvt_table == 0 && !this->connections->empty()) { const auto& lowest = this->connections->lowest(); - auto active_index = grid.getActiveIndex(lowest.getI(), lowest.getJ(), lowest.getK()); + auto active_index = grid.get_cell(lowest.getI(), lowest.getJ(), lowest.getK()).active_index.value(); this->pvt_table = pvtnum[active_index]; update = true; } diff --git a/src/opm/parser/eclipse/EclipseState/Schedule/Well/WellConnections.cpp b/src/opm/parser/eclipse/EclipseState/Schedule/Well/WellConnections.cpp index 8856425b2..6b571ee31 100644 --- a/src/opm/parser/eclipse/EclipseState/Schedule/Well/WellConnections.cpp +++ b/src/opm/parser/eclipse/EclipseState/Schedule/Well/WellConnections.cpp @@ -327,7 +327,8 @@ inline std::array< size_t, 3> directionIndices(const Opm::Connection::Direction rw = 0.5*unit::feet; for (int k = K1; k <= K2; k++) { - if (!grid.isCellActive(I, J, k)) { + const CompletedCells::Cell& cell = grid.get_cell(I, J, k); + if (!cell.active_index.has_value()) { auto msg = fmt::format("Problem with COMPDAT keyword\n" "In {} line {}\n" "The cell ({},{},{}) in well {} is not active and the connection will be ignored", location.filename, location.lineno, I,J,k, wname); @@ -335,7 +336,7 @@ inline std::array< size_t, 3> directionIndices(const Opm::Connection::Direction continue; } - size_t active_index = grid.getActiveIndex(I,J,k); + size_t active_index = cell.active_index.value(); double CF = -1; double Kh = -1; double r0 = -1; @@ -360,7 +361,7 @@ inline std::array< size_t, 3> directionIndices(const Opm::Connection::Direction // Angle of completion exposed to flow. We assume centre // placement so there's complete exposure (= 2\pi). const double angle = 6.2831853071795864769252867665590057683943387987502116419498; - std::array cell_size = grid.getCellDimensions(I,J,k); + std::array cell_size = cell.dimensions; const auto& D = effectiveExtent(direction, ntg[active_index], cell_size); /* We start with the absolute happy path; both CF and Kh are explicitly given in the deck. */ @@ -407,8 +408,8 @@ inline std::array< size_t, 3> directionIndices(const Opm::Connection::Direction if (prev == this->m_connections.end()) { std::size_t noConn = this->m_connections.size(); this->addConnection(I,J,k, - grid.getGlobalIndex(I,J,k), - grid.getCellDepth( I,J,k ), + cell.global_index, + cell.depth, state, CF, Kh, @@ -426,9 +427,9 @@ inline std::array< size_t, 3> directionIndices(const Opm::Connection::Direction std::size_t css_ind = prev->sort_value(); int conSegNo = prev->segment(); const auto& perf_range = prev->perf_range(); - double depth = grid.getCellDepth(I,J,k); + double depth = cell.depth; *prev = Connection(I,J,k, - grid.getGlobalIndex(I,J,k), + cell.global_index, prev->complnum(), depth, state, diff --git a/tests/parser/ScheduleTests.cpp b/tests/parser/ScheduleTests.cpp index d3dbe8d11..713973e12 100644 --- a/tests/parser/ScheduleTests.cpp +++ b/tests/parser/ScheduleTests.cpp @@ -4813,13 +4813,13 @@ BOOST_AUTO_TEST_CASE(TestScheduleGrid) { { ScheduleGrid sched_grid(grid, cells); - auto depth = sched_grid.getCellDepth(1,1,1); + auto depth = sched_grid.get_cell(1,1,1).depth; BOOST_CHECK_EQUAL(depth, 1.50); } { ScheduleGrid sched_grid(cells); - auto depth = sched_grid.getCellDepth(1,1,1); + auto depth = sched_grid.get_cell(1,1,1).depth; BOOST_CHECK_EQUAL(depth, 1.50); - BOOST_CHECK_THROW(sched_grid.getCellDepth(2,2,2), std::exception); + BOOST_CHECK_THROW(sched_grid.get_cell(2,2,2), std::exception); } }