From b2cbf04a9220ada31e608de58fd0e433356c0b6c Mon Sep 17 00:00:00 2001 From: arturcastiel Date: Fri, 19 Dec 2025 10:07:38 +0000 Subject: [PATCH 1/2] remove obsolete LGR functions --- .../eclipse/EclipseState/Grid/EclipseGrid.cpp | 81 ++----------------- .../eclipse/EclipseState/Grid/EclipseGrid.hpp | 5 -- opm/input/eclipse/Schedule/ScheduleGrid.cpp | 10 +-- 3 files changed, 8 insertions(+), 88 deletions(-) diff --git a/opm/input/eclipse/EclipseState/Grid/EclipseGrid.cpp b/opm/input/eclipse/EclipseState/Grid/EclipseGrid.cpp index a73ccc1625c..a66c19669e9 100644 --- a/opm/input/eclipse/EclipseState/Grid/EclipseGrid.cpp +++ b/opm/input/eclipse/EclipseState/Grid/EclipseGrid.cpp @@ -2048,81 +2048,6 @@ std::vector EclipseGrid::createDVector(const std::array& dims, st return this->getIJK(global_id); } - - /** - * @brief Computes the dimensions of a local grid refinement (LGR) cell. - * - * This function calculates the dimensions of an LGR cell by dividing - * the parent cell's dimensions by the subdivision ratio for the given - * LGR tag. - * - * @param i Local index of the parent cell in the x-direction. - * @param j Local index of the parent cell in the y-direction. - * @param k Local index of the parent cell in the z-direction. - * @param lgr_tag Identifier for the LGR region. - * @return std::array The computed dimensions of the LGR cell - * in the x, y, and z directions. - */ - std::array EclipseGrid::getCellDimensionsLGR(const std::size_t i, - const std::size_t j, - const std::size_t k, - const std::string& lgr_tag) const - { - std::array subdivision = getCellSubdivisionRatioLGR(lgr_tag); - std::array cell_dims = getCellDims(i, j, k); - - return {cell_dims[0] / static_cast(subdivision[0]), - cell_dims[1] / static_cast(subdivision[1]), - cell_dims[2] / static_cast(subdivision[2])}; - } - - double EclipseGrid::getCellDepthLGR(size_t i, size_t j, size_t k, const std::string& lgr_tag) const - { - auto split_domain = [](double start_val, double end_val, int num_points, int index) { - if (index < 0 || index >= num_points) - { - throw std::out_of_range("Index must be between 1 and num_points."); - } - double step = (end_val - start_val) / (num_points - 1); - return start_val + (index * step); - }; - - auto refine_cell = [&split_domain](std::array& Z, int nz, int k_pos) { - std::array Zdiv; - for (int index = 0; index < 4; index++) - { - Zdiv[index] = split_domain(Z[index], Z[index + 4], nz + 1, k_pos); - Zdiv[index + 4] = split_domain(Z[index], Z[index + 4], nz + 1, k_pos + 1); - } - Z = Zdiv; - }; - - std::vector> label_list; - std::vector recurrent_global_index; - std::size_t fater_global_index; - - std::array X; - std::array Y; - std::array Z; - - getLGRCell(lgr_tag).get_label_child_to_top_father(label_list); - getLGRCell(lgr_tag).get_global_index_child_to_top_father(recurrent_global_index, i,j,k); - fater_global_index = recurrent_global_index.back(); - recurrent_global_index.pop_back(); - - this->getCellCorners(fater_global_index, X, Y, Z ); - for (size_t index = 0; index < label_list.size(); index++) - { - int nz = getLGRCell(label_list[index].get()).getNZ(); - int k_pos = getLGRCell(label_list[index].get()).getIJK(recurrent_global_index[index])[2]; - refine_cell(Z, nz, k_pos); - } - double z1 = (Z[0]+Z[1]+Z[2]+Z[3])/4.0; - double z2 = (Z[4]+Z[5]+Z[6]+Z[7])/4.0; - return (z1 + z2) / 2.0; - } - - std::array EclipseGrid::getCellSubdivisionRatioLGR(const std::string& lgr_tag, std::array acum ) const { @@ -2714,9 +2639,13 @@ namespace Opm { const std::size_t n = getCartesianSize(); const auto& lgr_label_ref = get_lgr_tag(); std::vector lgr_depths(n); + + const auto& local_lgr_grid = father_grid.getLGRCell(lgr_label_ref); + for (std::size_t index = 0; index < n; ++index) { auto [i, j, k] = getIJK(index); - lgr_depths[index] = father_grid.getCellDepthLGR(i,j,k, lgr_label_ref); + + lgr_depths[index] = local_lgr_grid.getCellDepth(i,j,k); } return lgr_depths; } diff --git a/opm/input/eclipse/EclipseState/Grid/EclipseGrid.hpp b/opm/input/eclipse/EclipseState/Grid/EclipseGrid.hpp index 3e1a42885ee..afbc2606fe2 100644 --- a/opm/input/eclipse/EclipseState/Grid/EclipseGrid.hpp +++ b/opm/input/eclipse/EclipseState/Grid/EclipseGrid.hpp @@ -257,11 +257,6 @@ namespace Opm { std::array getCellDimensions(size_t i, size_t j, size_t k) const { return getCellDims(i, j, k); } - std::array getCellDimensionsLGR(const std::size_t i, - const std::size_t j, - const std::size_t k, - const std::string& lgr_tag) const; - double getCellDepthLGR(size_t i, size_t j, size_t k, const std::string& lgr_tag) const; bool isCellActive(size_t i, size_t j, size_t k) const { diff --git a/opm/input/eclipse/Schedule/ScheduleGrid.cpp b/opm/input/eclipse/Schedule/ScheduleGrid.cpp index 1a61f145c6d..85acad241ad 100644 --- a/opm/input/eclipse/Schedule/ScheduleGrid.cpp +++ b/opm/input/eclipse/Schedule/ScheduleGrid.cpp @@ -270,14 +270,10 @@ populate_props_lgr(const std::string& tag, CompletedCells::Cell& cell) const auto [fi, fj, fk] = this->grid->getIJK(father_global_id); - // This part relies on the ZCORN and COORDS of the host cells that - // have not been parsed yet. The following implementations are a - // path that compute depths and dimensions of the LGR cells based on - // the host cells. - cell.depth = this->grid->getCellDepthLGR(cell.i, cell.j, cell.k, tag); - cell.dimensions = this->grid->getCellDimensionsLGR(fi, fj, fk, tag); - const auto& lgr_grid = this->grid->getLGRCell(tag); + cell.depth = lgr_grid.getCellDepth(cell.i, cell.j, cell.k); + cell.dimensions = lgr_grid.getCellDims(cell.i, cell.j, cell.k); + if (!this->grid->cellActive(fi, fj, fk) || !lgr_grid.cellActive(cell.i, cell.j, cell.k)) From ed7112fcc9a5781aa947c3373a2f75fb2491d76e Mon Sep 17 00:00:00 2001 From: arturcastiel Date: Fri, 19 Dec 2025 10:48:02 +0000 Subject: [PATCH 2/2] WellTestLGR considers float point tolerance in WellLGRDepthThird review suggestions --- tests/parser/WellTestsLGR.cpp | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/tests/parser/WellTestsLGR.cpp b/tests/parser/WellTestsLGR.cpp index 6af130c3c9b..56a01831574 100644 --- a/tests/parser/WellTestsLGR.cpp +++ b/tests/parser/WellTestsLGR.cpp @@ -277,8 +277,14 @@ COMPDATL BOOST_CHECK_CLOSE(cell1.depth, 8333.333333, TOLERANCE_PERCENT); BOOST_CHECK_CLOSE(cell2.depth,8366.666666, TOLERANCE_PERCENT); - BOOST_CHECK_EQUAL(dim_original[0]/3,dim_cell1[0]); - BOOST_CHECK_EQUAL(dim_original[1]/1,dim_cell1[1]); - BOOST_CHECK_EQUAL(dim_original[2]/3,dim_cell1[2]); - BOOST_CHECK_EQUAL_COLLECTIONS(dim_cell1.begin(), dim_cell1.end(), dim_cell2.begin(), dim_cell2.end()); + const auto tol = 1e-8; + BOOST_CHECK_CLOSE(dim_original[0]/3,dim_cell1[0],tol); + BOOST_CHECK_CLOSE(dim_original[1]/1,dim_cell1[1],tol); + BOOST_CHECK_CLOSE(dim_original[2]/3,dim_cell1[2], tol); + BOOST_REQUIRE_EQUAL(dim_cell1.size(), dim_cell2.size()); + + for (std::size_t i = 0; i < dim_cell1.size(); ++i) { + BOOST_TEST_MESSAGE("Cell dimension " << i); + BOOST_CHECK_CLOSE(dim_cell1[i], dim_cell2[i], tol); + } }