diff --git a/opm/core/grid/GridManager.cpp b/opm/core/grid/GridManager.cpp index bcfbda60..621a3192 100644 --- a/opm/core/grid/GridManager.cpp +++ b/opm/core/grid/GridManager.cpp @@ -159,7 +159,8 @@ namespace Opm if (!poreVolumes.empty() && (eclipseGrid->getMinpvMode() != MinpvMode::ModeEnum::Inactive)) { MinpvProcessor mp(g.dims[0], g.dims[1], g.dims[2]); const double minpv_value = eclipseGrid->getMinpvValue(); - mp.process(poreVolumes, minpv_value, actnum, zcorn.data()); + bool opmfil = eclipseGrid->getMinpvMode() == MinpvMode::OpmFIL; + mp.process(poreVolumes, minpv_value, actnum, opmfil, zcorn.data()); } const double z_tolerance = eclipseGrid->isPinchActive() ? diff --git a/opm/core/grid/MinpvProcessor.hpp b/opm/core/grid/MinpvProcessor.hpp index 56d98707..21ba691a 100644 --- a/opm/core/grid/MinpvProcessor.hpp +++ b/opm/core/grid/MinpvProcessor.hpp @@ -41,13 +41,17 @@ namespace Opm /// \param[in] pv pore volumes of all logical cartesian cells /// \param[in] minpv minimum pore volume to accept a cell /// \param[in] actnum active cells, inactive cells are not considered + /// \param[in] mergeMinPVCells flag to determine whether cells below minpv + /// should be included in the cell below /// \param[in, out] zcorn ZCORN array to be manipulated /// After processing, all cells that have lower pore volume than minpv /// will have the zcorn numbers changed so they are zero-thickness. Any - /// cell below will be changed to include the deleted volume. + /// cell below will be changed to include the deleted volume if mergeMinPCCells is true + /// els the volume will be lost void process(const std::vector& pv, const double minpv, const std::vector& actnum, + const bool mergeMinPVCells, double* zcorn) const; private: std::array cornerIndices(const int i, const int j, const int k) const; @@ -74,6 +78,7 @@ namespace Opm inline void MinpvProcessor::process(const std::vector& pv, const double minpv, const std::vector& actnum, + const bool mergeMinPVCells, double* zcorn) const { // Algorithm: @@ -83,9 +88,9 @@ namespace Opm // pv[c] is less than minpv. // 3. If below the minpv threshold, move the lower four // zcorn associated with the cell c to coincide with - // the upper four (so it becomes degenerate). Also move - // the higher four zcorn associated with the cell below - // to these values (so it gains the deleted volume). + // the upper four (so it becomes degenerate). If mergeMinPVcells + // is true, the higher four zcorn associated with the cell below + // is moved to these values (so it gains the deleted volume). // Check for sane input sizes. const size_t log_size = dims_[0] * dims_[1] * dims_[2]; @@ -108,14 +113,18 @@ namespace Opm cz[count + 4] = cz[count]; } setCellZcorn(ii, jj, kk, cz, zcorn); - // Check if there is a cell below. - if (pv[c] > 0.0 && kk < dims_[2] - 1) { - // Set lower k coordinates of cell below to upper cells's coordinates. - std::array cz_below = getCellZcorn(ii, jj, kk + 1, zcorn); - for (int count = 0; count < 4; ++count) { - cz_below[count] = cz[count]; + + // optionally add removed volume to the cell below. + if (mergeMinPVCells) { + // Check if there is a cell below. + if (pv[c] > 0.0 && kk < dims_[2] - 1) { + // Set lower k coordinates of cell below to upper cells's coordinates. + std::array cz_below = getCellZcorn(ii, jj, kk + 1, zcorn); + for (int count = 0; count < 4; ++count) { + cz_below[count] = cz[count]; + } + setCellZcorn(ii, jj, kk + 1, cz_below, zcorn); } - setCellZcorn(ii, jj, kk + 1, cz_below, zcorn); } } } diff --git a/tests/test_minpvprocessor.cpp b/tests/test_minpvprocessor.cpp index 48bcaec0..e8774000 100644 --- a/tests/test_minpvprocessor.cpp +++ b/tests/test_minpvprocessor.cpp @@ -50,21 +50,45 @@ BOOST_AUTO_TEST_CASE(Processing) 0, 0, 0, 0, 0, 0, 0, 0, 6, 6, 6, 6 }; + std::vector zcorn4after = { 0, 0, 0, 0, + 0, 0, 0, 0, + 1, 1, 1, 1, + 3, 3, 3, 3, + 3, 3, 3, 3, + 6, 6, 6, 6 }; + std::vector zcorn5after = { 0, 0, 0, 0, + 0, 0, 0, 0, + 1, 1, 1, 1, + 1, 1, 1, 1, + 3, 3, 3, 3, + 6, 6, 6, 6 }; + std::vector pv = { 1, 2, 3 }; std::vector actnum = { 1, 1, 1 }; Opm::MinpvProcessor mp1(1, 1, 3); auto z1 = zcorn; - mp1.process(pv, 0.5, actnum, z1.data()); + bool fill_removed_cells = true; + mp1.process(pv, 0.5, actnum, fill_removed_cells, z1.data()); BOOST_CHECK_EQUAL_COLLECTIONS(z1.begin(), z1.end(), zcorn.begin(), zcorn.end()); Opm::MinpvProcessor mp2(1, 1, 3); auto z2 = zcorn; - mp2.process(pv, 1.5, actnum, z2.data()); + mp2.process(pv, 1.5, actnum, fill_removed_cells, z2.data()); BOOST_CHECK_EQUAL_COLLECTIONS(z2.begin(), z2.end(), zcorn2after.begin(), zcorn2after.end()); Opm::MinpvProcessor mp3(1, 1, 3); auto z3 = zcorn; - mp3.process(pv, 2.5, actnum, z3.data()); + mp3.process(pv, 2.5, actnum, fill_removed_cells, z3.data()); BOOST_CHECK_EQUAL_COLLECTIONS(z3.begin(), z3.end(), zcorn3after.begin(), zcorn3after.end()); + + Opm::MinpvProcessor mp4(1, 1, 3); + auto z4 = zcorn; + mp4.process(pv, 1.5, actnum, !fill_removed_cells, z4.data()); + BOOST_CHECK_EQUAL_COLLECTIONS(z4.begin(), z4.end(), zcorn4after.begin(), zcorn4after.end()); + + Opm::MinpvProcessor mp5(1, 1, 3); + auto z5 = zcorn; + mp5.process(pv, 2.5, actnum, !fill_removed_cells, z5.data()); + BOOST_CHECK_EQUAL_COLLECTIONS(z5.begin(), z5.end(), zcorn5after.begin(), zcorn5after.end()); }