From 873102e9eae50a9f2804d0fa77fdb034c796dd6b Mon Sep 17 00:00:00 2001 From: Arne Morten Kvarving Date: Mon, 22 Jan 2024 09:58:06 +0100 Subject: [PATCH] added: RST CONV support for polymer, solvent and brine --- ebos/eclgenericoutputblackoilmodule.cc | 5 +-- opm/simulators/flow/BlackoilModelEbos.hpp | 5 ++- opm/simulators/flow/RSTConv.cpp | 8 ++--- opm/simulators/flow/RSTConv.hpp | 6 ++-- tests/test_rstconv.cpp | 41 ++++++++++++----------- 5 files changed, 35 insertions(+), 30 deletions(-) diff --git a/ebos/eclgenericoutputblackoilmodule.cc b/ebos/eclgenericoutputblackoilmodule.cc index 2b98cd3c3..ae85af539 100644 --- a/ebos/eclgenericoutputblackoilmodule.cc +++ b/ebos/eclgenericoutputblackoilmodule.cc @@ -1504,8 +1504,9 @@ void EclGenericOutputBlackoilModule:: assignGlobalFieldsToSolution(data::Solution& sol) { if (!this->cnvData_.empty()) { - constexpr std::array names = {"CNV_OIL", "CNV_GAS", "CNV_WAT"}; - for (size_t i = 0; i < 3; ++i) { + constexpr const std::array names{"CNV_OIL", "CNV_GAS", "CNV_WAT", + "CNV_PLY", "CNV_SAL", "CNV_SOL"}; + for (std::size_t i = 0; i < names.size(); ++i) { if (!this->cnvData_[i].empty()) { sol.insert(names[i], this->cnvData_[i], data::TargetType::RESTART_SOLUTION); } diff --git a/opm/simulators/flow/BlackoilModelEbos.hpp b/opm/simulators/flow/BlackoilModelEbos.hpp index e514bd495..fa5e753df 100644 --- a/opm/simulators/flow/BlackoilModelEbos.hpp +++ b/opm/simulators/flow/BlackoilModelEbos.hpp @@ -320,7 +320,10 @@ namespace Opm { schedule[timer.reportStepNum()].rst_config(), {getIdx(FluidSystem::oilPhaseIdx), getIdx(FluidSystem::gasPhaseIdx), - getIdx(FluidSystem::waterPhaseIdx)}); + getIdx(FluidSystem::waterPhaseIdx), + contiPolymerEqIdx, + contiBrineEqIdx, + contiSolventEqIdx}); return report; } diff --git a/opm/simulators/flow/RSTConv.cpp b/opm/simulators/flow/RSTConv.cpp index b306f5060..a7947aff4 100644 --- a/opm/simulators/flow/RSTConv.cpp +++ b/opm/simulators/flow/RSTConv.cpp @@ -34,7 +34,7 @@ namespace Opm { void RSTConv::init(const std::size_t numCells, const RSTConfig& rst_config, - const std::array& compIdx) + const std::array& compIdx) { const auto kw = rst_config.keywords.find("CONV"); if (kw == rst_config.keywords.end()) { @@ -46,9 +46,9 @@ void RSTConv::init(const std::size_t numCells, N_ = kw->second; compIdx_ = compIdx; - cnv_X_.resize(3); - for (std::size_t i = 0; i < 3; ++i) { - if (compIdx_[i] != -1) { + cnv_X_.resize(6); + for (std::size_t i = 0; i < 6; ++i) { + if (compIdx_[i] > -1) { cnv_X_[i].resize(numCells); } } diff --git a/opm/simulators/flow/RSTConv.hpp b/opm/simulators/flow/RSTConv.hpp index 3054ffcab..20140f6b9 100644 --- a/opm/simulators/flow/RSTConv.hpp +++ b/opm/simulators/flow/RSTConv.hpp @@ -45,10 +45,10 @@ public: //! \brief Init state at beginning of step. //! \param numCells Global number of active cells in the model //! \param rst_config RPTRST configuration - //! \param compIdx Component index for phases {OIL, GAS, WAT}, -1 if inactive + //! \param compIdx Component index for phases {OIL, GAS, WAT, POLYMER, BRINE, SOLVENT}, negative if inactive void init(const std::size_t numCells, const RSTConfig& rst_config, - const std::array& compIdx); + const std::array& compIdx); //! \brief Adds the CONV output for given residual vector. template @@ -71,7 +71,7 @@ private: const std::vector& globalCell_; //!< Global cell indices Parallel::Communication comm_; //!< Communicator std::vector> cnv_X_; //!< Counts of worst cells for RPTRST CONV - std::array compIdx_; //!< Component indices + std::array compIdx_; //!< Component indices int N_ = 0; //!< Number of cells to consider }; diff --git a/tests/test_rstconv.cpp b/tests/test_rstconv.cpp index cfda5cee2..ee38c9148 100644 --- a/tests/test_rstconv.cpp +++ b/tests/test_rstconv.cpp @@ -68,7 +68,7 @@ init_unit_test_func() struct TestCase { std::size_t N; - std::array phase; + std::array phase; }; std::ostream& operator<<(std::ostream& os, const TestCase& t) @@ -82,12 +82,15 @@ std::ostream& operator<<(std::ostream& os, const TestCase& t) } static const std::vector tests = { - {1, {0, 1, 2}}, - {3, {0, 1, 2}}, - {1, {0, -1, 1}}, - {5, {0, -1, 1}}, - {1, {-1, -1, 0}}, - {4, {-1, -1, 0}}, + {1, { 0, 1, 2, -1, -1, -1}}, + {3, { 0, 1, 2, -1, -1, -1}}, + {1, { 0, -1, 1, -1, -1, -1}}, + {5, { 0, -1, 1, -1, -1, -1}}, + {1, {-1, -1, 0, -1, -1, -1}}, + {4, {-1, -1, 0, -1, -1, -1}}, + {1, { 0, 1, -1, 2, -1, -1}}, + {1, { 0, 1, -1, -1, 2, -1}}, + {1, { 0, 1, -1, -1, -1, 2}}, }; #if BOOST_VERSION / 100000 == 1 && BOOST_VERSION / 100 % 1000 > 66 @@ -107,16 +110,16 @@ BOOST_AUTO_TEST_CASE(RstConvTest) std::vector cellMapping(10); std::iota(cellMapping.begin(), cellMapping.end(), cc.rank()*10); - Dune::BlockVector> residual(10); + Dune::BlockVector> residual(10); // generate data - std::vector> max(3); + std::vector> max(6); if (cc.rank() == 0) { std::random_device rng_device; std::mt19937 mersenne_engine{rng_device()}; std::uniform_int_distribution dist{0, 10*cc.size()-1}; - for (int c = 0; c < 3; ++c) { + for (int c = 0; c < 6; ++c) { if (sample.phase[c] == -1) { continue; } @@ -130,7 +133,7 @@ BOOST_AUTO_TEST_CASE(RstConvTest) } } - for (int c = 0; c < 3; ++c) { + for (int c = 0; c < 6; ++c) { std::size_t size = max[c].size(); cc.broadcast(&size, 1, 0); if (cc.rank() != 0) { @@ -140,7 +143,7 @@ BOOST_AUTO_TEST_CASE(RstConvTest) } for (int i = 0; i < 10; ++i) { - for (int c = 0; c < 3; ++c) { + for (int c = 0; c < 6; ++c) { if (sample.phase[c] != -1) { bool inMax = std::find(max[c].begin(), max[c].end(), @@ -157,16 +160,14 @@ BOOST_AUTO_TEST_CASE(RstConvTest) cnv.update(residual); if (cc.rank() == 0) { - BOOST_CHECK_EQUAL(cnv.getData().size(), 3); - BOOST_CHECK_EQUAL(cnv.getData()[0].size(), - sample.phase[0] == -1 ? 0 : cc.size() * 10); - BOOST_CHECK_EQUAL(cnv.getData()[1].size(), - sample.phase[1] == -1 ? 0 : cc.size() * 10); - BOOST_CHECK_EQUAL(cnv.getData()[2].size(), - sample.phase[2] == -1 ? 0 : cc.size() * 10); + BOOST_CHECK_EQUAL(cnv.getData().size(), 6); + for (std::size_t i = 0; i < 6; ++i) { + BOOST_CHECK_EQUAL(cnv.getData()[i].size(), + sample.phase[i] == -1 ? 0 : cc.size() * 10); + } for (int i = 0; i < cc.size() * 10; ++i) { - for (int c = 0; c < 3; ++c) { + for (int c = 0; c < 6; ++c) { if (sample.phase[c] != -1) { bool inMax = std::find(max[c].begin(), max[c].end(), i) != max[c].end();