diff --git a/CMakeLists_files.cmake b/CMakeLists_files.cmake index 79d61c427..6dd57a5db 100644 --- a/CMakeLists_files.cmake +++ b/CMakeLists_files.cmake @@ -37,6 +37,7 @@ list (APPEND MAIN_SOURCE_FILES opm/grid/cpgrid/Iterators.cpp opm/grid/cpgrid/Indexsets.cpp opm/grid/cpgrid/PartitionTypeIndicator.cpp + opm/grid/cpgrid/CpGridUtilities.cpp opm/grid/cpgrid/processEclipseFormat.cpp opm/grid/common/GeometryHelpers.cpp opm/grid/common/GridPartitioning.cpp @@ -191,6 +192,7 @@ list (APPEND PUBLIC_HEADER_FILES opm/grid/cpgrid/CartesianIndexMapper.hpp opm/grid/cpgrid/CpGridData.hpp opm/grid/cpgrid/CpGridDataTraits.hpp + opm/grid/cpgrid/CpGridUtilities.hpp opm/grid/cpgrid/DataHandleWrappers.hpp opm/grid/cpgrid/DefaultGeometryPolicy.hpp opm/grid/cpgrid/dgfparser.hh diff --git a/opm/grid/CpGrid.hpp b/opm/grid/CpGrid.hpp index dce2a00b9..5562fc1b7 100644 --- a/opm/grid/CpGrid.hpp +++ b/opm/grid/CpGrid.hpp @@ -1194,15 +1194,6 @@ namespace Dune /// @brief Reverse map: from leaf index cell to { level, local/level Cartesian index of the cell } std::vector> mapLeafIndexSetToLocalCartesianIndexSets() const; - /// @brief Retrieves the local IJKs of cells within a specified LGR. - /// - /// This method returns a vector of IJK indices corresponding to underlying Cartesian grid of the local - /// grid refinement (LGR) specified by its name. If the specified LGR name is not found, it throws. - /// - /// @param lgr_name The name of the LGR whose local IJK coordinates are requested. - /// @return std::vector> A list of (i, j, k)'s for each cell in the LGR. - std::vector> localIJK(const std::string& lgr_name) const; - /// \brief Size of the overlap on the leaf level unsigned int overlapSize(int) const; diff --git a/opm/grid/cpgrid/CpGrid.cpp b/opm/grid/cpgrid/CpGrid.cpp index a9aae908f..610187425 100644 --- a/opm/grid/cpgrid/CpGrid.cpp +++ b/opm/grid/cpgrid/CpGrid.cpp @@ -54,7 +54,6 @@ #include "ParentToChildCellToPointGlobalIdHandle.hpp" #include #include -#include #include //#include #include @@ -714,30 +713,6 @@ std::vector> CpGrid::mapLeafIndexSetToLocalCartesianIndexSets( return leafIdx_to_localCartesianIdxSets; } -std::vector> CpGrid::localIJK(const std::string& lgr_name) const -{ - // Check lgr_name exists in lgr_names_ - auto it = lgr_names_.find(lgr_name); - if (it == lgr_names_.end()) { - OPM_THROW(std::runtime_error, "LGR name not found: " + lgr_name); - } - - const Opm::LevelCartesianIndexMapper levelCartMapp(*this); - const auto& level = it->second; - - std::vector> localIJK; - localIJK.reserve(levelGridView(level).size(0)); - - for (const auto& element : elements(levelGridView(level))) { - std::array local_ijk; - levelCartMapp.cartesianCoordinate(element.index(), local_ijk, level); - localIJK.emplace_back(local_ijk); - } - - return localIJK; -} - - void CpGrid::getIJK(const int c, std::array& ijk) const { current_view_data_->getIJK(c, ijk); diff --git a/tests/cpgrid/localIJK_test.cpp b/tests/cpgrid/localIJK_test.cpp index 2a5b8dff6..46479d584 100644 --- a/tests/cpgrid/localIJK_test.cpp +++ b/tests/cpgrid/localIJK_test.cpp @@ -41,15 +41,13 @@ #endif -#include +#include #include #include #include #include #include -//#include -//#include #include #include @@ -147,8 +145,8 @@ BOOST_AUTO_TEST_CASE(localIJK_in_allActiveCellLGRs) const int lgr2_level = lgr_name_to_level.at("LGR2"); // Get vector of local ijk for each LGR - std::vector> ijk_lgr1 = grid.localIJK("LGR1"); - std::vector> ijk_lgr2 = grid.localIJK("LGR2"); + std::vector> ijk_lgr1 = Opm::localIJK(grid, "LGR1"); + std::vector> ijk_lgr2 = Opm::localIJK(grid, "LGR2"); // Ensure it's not empty BOOST_TEST(!ijk_lgr1.empty()); // 2 active parent cell refined into 2x2x2 refined cells @@ -170,7 +168,7 @@ BOOST_AUTO_TEST_CASE(localIJK_in_allActiveCellLGRs) } // Invalid LGR should throw an exception - BOOST_CHECK_THROW(grid.localIJK("LGR3DOESNOTEXIST"), std::runtime_error); + BOOST_CHECK_THROW(Opm::localIJK(grid, "LGR3DOESNOTEXIST"), std::runtime_error); // LGR1 Dimension: 2x2x4 (Width x Height x Depth) // Visual representation of local cell indices per k-layer: