From 862b7b759161ca6979c01b41ddb5b427988f7c91 Mon Sep 17 00:00:00 2001 From: Jostein Alvestad Date: Fri, 5 Jun 2020 16:02:32 +0200 Subject: [PATCH] clean up code - correct unit tests --- src/opm/output/eclipse/AggregateGroupData.cpp | 61 +------ src/opm/output/eclipse/CreateInteHead.cpp | 1 - tests/test_AggregateMSWData.cpp | 4 +- tests/test_AggregateWellData.cpp | 168 ++++++++++++++++-- 4 files changed, 166 insertions(+), 68 deletions(-) diff --git a/src/opm/output/eclipse/AggregateGroupData.cpp b/src/opm/output/eclipse/AggregateGroupData.cpp index 3a6a70e0c..02897d836 100644 --- a/src/opm/output/eclipse/AggregateGroupData.cpp +++ b/src/opm/output/eclipse/AggregateGroupData.cpp @@ -1,7 +1,7 @@ /* Copyright 2018 Statoil ASA - This file is part of the Open Porous Media project (OPM). + This file is part of the|| Open Porous Media project (OPM). OPM is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by @@ -323,45 +323,7 @@ int higherLevelInjControlGroupSeqIndex(const Opm::Schedule& sched, } } -int higherLevelInjControlMode(const Opm::Schedule& sched, - const Opm::SummaryState& sumState, - const Opm::Group& group, - const std::string curInjCtrlKey, - const size_t simStep) -// -// returns the sequence number of higher (highest) level group with active control different from (NONE or FLD) -// -{ - int ctrl_mode = -1; - if (group.defined( simStep )) { - auto current = group; - double cur_inj_ctrl = -1.; - while (current.name() != "FIELD" && ctrl_mode < 0) { - current = sched.getGroup(current.parent(), simStep); - cur_inj_ctrl = -1.; - std::string group_key = gf_key(curInjCtrlKey, current.name()); - if (sumState.has(group_key)) { - cur_inj_ctrl = sumState.get(group_key); - } - else { - std::cout << "Current injection group control: " << curInjCtrlKey << " is not defined for group: " << current.name() << " at timestep: " << simStep << std::endl; - cur_inj_ctrl = 0.; - } - if (cur_inj_ctrl > 0. && ctrl_mode < 0) { - ctrl_mode = static_cast(cur_inj_ctrl); - } - } - return ctrl_mode; - } - else { - std::stringstream str; - str << "actual group has not been defined at report time: " << simStep; - throw std::invalid_argument(str.str()); - } -} - std::vector groupParentSeqIndex(const Opm::Schedule& sched, - const Opm::SummaryState& sumState, const Opm::Group& group, const size_t simStep) // @@ -479,10 +441,8 @@ void staticContrib(const Opm::Schedule& sched, const int ngmaxz, const std::size_t simStep, const Opm::SummaryState& sumState, - const std::map& iCtrlToICMode, const std::map& pCtrlToPCmode, const std::map& cmodeToNum, - const Opm::UnitSystem& units, IGrpArray& iGrp) { if (group.wellgroup()) { @@ -743,7 +703,8 @@ void staticContrib(const Opm::Schedule& sched, iGrp[nwgmax + 10] = 5; break; case Opm::Group::ProductionCMode::FLD: - iGrp[nwgmax + 10] = 0; // need to be checked!! + iGrp[nwgmax + 10] = 0; + break; default: iGrp[nwgmax + 10] = 0; } @@ -753,7 +714,7 @@ void staticContrib(const Opm::Schedule& sched, iGrp[nwgmax + 17] = -1; iGrp[nwgmax + 22] = -1; if (group.isInjectionGroup() || (group.getGroupType() == Opm::Group::GroupType::MIXED) || (group.getGroupType() == Opm::Group::GroupType::NONE)) { - auto group_parent_list = groupParentSeqIndex(sched, sumState, group, simStep); + auto group_parent_list = groupParentSeqIndex(sched, group, simStep); //set "default value" in case a group is only injection group if (group.isInjectionGroup() && !group.isProductionGroup()) { @@ -768,13 +729,8 @@ void staticContrib(const Opm::Schedule& sched, double cur_winj_ctrl = -1.; const auto& winj_cmode = (group.hasInjectionControl(Opm::Phase::WATER))? group.injectionControls(Opm::Phase::WATER, sumState).cmode : Opm::Group::InjectionCMode::NONE; - Opm::Group::InjectionCMode wictl_mode = Opm::Group::InjectionCMode::NONE; if (sumState.has(group_key_w)) { cur_winj_ctrl = sumState.get(group_key_w); - const auto it_ctrl = iCtrlToICMode.find(cur_winj_ctrl); - if (it_ctrl != iCtrlToICMode.end()) { - wictl_mode = it_ctrl->second; - } } else { std::cout << "Current group water injection control is not defined for group: " << group.name() << " at timestep: " << simStep << std::endl; @@ -865,13 +821,8 @@ void staticContrib(const Opm::Schedule& sched, double cur_ginj_ctrl = -1.; const auto& ginj_cmode = (group.hasInjectionControl(Opm::Phase::GAS))? group.injectionControls(Opm::Phase::GAS, sumState).cmode : Opm::Group::InjectionCMode::NONE; - Opm::Group::InjectionCMode gictl_mode = Opm::Group::InjectionCMode::NONE; if (sumState.has(group_key_g)) { cur_ginj_ctrl = sumState.get(group_key_g); - const auto it_ctrl = iCtrlToICMode.find(cur_ginj_ctrl); - if (it_ctrl != iCtrlToICMode.end()) { - gictl_mode = it_ctrl->second; - } } else { std::cout << "Current group gas injection control is not defined for group: " << group.name() << " at timestep: " << simStep << std::endl; @@ -1286,13 +1237,13 @@ captureDeclaredGroupData(const Opm::Schedule& sched, curGroups[ind] = std::addressof(group); } - groupLoop(curGroups, [&sched, &units, simStep, sumState, this] + groupLoop(curGroups, [&sched, simStep, sumState, this] (const Group& group, const std::size_t groupID) -> void { auto ig = this->iGroup_[groupID]; IGrp::staticContrib(sched, group, this->nWGMax_, this->nGMaxz_, - simStep, sumState, this->ICntlModeToiCMode, this->PCntlModeToPCMode, this->cmodeToNum, units, ig); + simStep, sumState, this->PCntlModeToPCMode, this->cmodeToNum, ig); }); // Define Static Contributions to SGrp Array. diff --git a/src/opm/output/eclipse/CreateInteHead.cpp b/src/opm/output/eclipse/CreateInteHead.cpp index 794d84903..2e18ad34e 100755 --- a/src/opm/output/eclipse/CreateInteHead.cpp +++ b/src/opm/output/eclipse/CreateInteHead.cpp @@ -316,7 +316,6 @@ namespace { } const auto& udq_par = rspec.udqParams(); - const auto& udqActive = sched.udqActive(simStep); const auto r_seed = udq_par.rand_seed(); const auto no_wudq = noWellUdqs(sched, rptStep, simStep); const auto no_gudq = noGroupUdqs(sched, rptStep, simStep); diff --git a/tests/test_AggregateMSWData.cpp b/tests/test_AggregateMSWData.cpp index b805c86d1..b495febda 100644 --- a/tests/test_AggregateMSWData.cpp +++ b/tests/test_AggregateMSWData.cpp @@ -323,8 +323,8 @@ RPTREGS SOLUTION ============================================================ EQUIL - 7020.00 2700.00 7990.00 .00000 7020.00 .00000 0 0 5 / - 7200.00 3700.00 7300.00 .00000 7000.00 .00000 1 0 5 / + 7020.00 2700.00 7990.00 .00000 7200.00 .00000 0 0 5 / + 7200.00 3700.00 7300.00 .00000 7100.00 .00000 1 0 5 / RSVD 2 TABLES 3 NODES IN EACH FIELD 12:00 17 AUG 83 7000.0 1.0000 diff --git a/tests/test_AggregateWellData.cpp b/tests/test_AggregateWellData.cpp index 9c24348cf..dee11d110 100644 --- a/tests/test_AggregateWellData.cpp +++ b/tests/test_AggregateWellData.cpp @@ -92,30 +92,178 @@ OIL GAS WATER DISGAS -VAPOIL UNIFOUT UNIFIN DIMENS 10 10 10 / +WELLDIMS + 6 20 1 6 / +TABDIMS + 1 1 15 15 2 15 / +FIELD +EQLDIMS + 1 / GRID DXV -10*0.25 / +10*100. / DYV -10*0.25 / +10*100. / DZV -10*0.25 / +10*100. / TOPS -100*0.25 / +100*7000. / PORO 1000*0.2 / -SOLUTION +PERMX +1000*100. / + +PERMY +1000*100. / + +PERMZ +1000*10. / -START -- 0 -1 NOV 1979 / +PROPS ========================================================== + +-- WATER RELATIVE PERMEABILITY AND CAPILLARY PRESSURE ARE TABULATED AS +-- A FUNCTION OF WATER SATURATION. +-- +-- SWAT KRW PCOW +SWFN + + 0.12 0 0 + 1.0 0.00001 0 / + +-- SIMILARLY FOR GAS +-- +-- SGAS KRG PCOG +SGFN + + 0 0 0 + 0.02 0 0 + 0.05 0.005 0 + 0.12 0.025 0 + 0.2 0.075 0 + 0.25 0.125 0 + 0.3 0.19 0 + 0.4 0.41 0 + 0.45 0.6 0 + 0.5 0.72 0 + 0.6 0.87 0 + 0.7 0.94 0 + 0.85 0.98 0 + 1.0 1.0 0 +/ + +-- OIL RELATIVE PERMEABILITY IS TABULATED AGAINST OIL SATURATION +-- FOR OIL-WATER AND OIL-GAS-CONNATE WATER CASES +-- +-- SOIL KROW KROG +SOF3 + + 0 0 0 + 0.18 0 0 + 0.28 0.0001 0.0001 + 0.38 0.001 0.001 + 0.43 0.01 0.01 + 0.48 0.021 0.021 + 0.58 0.09 0.09 + 0.63 0.2 0.2 + 0.68 0.35 0.35 + 0.76 0.7 0.7 + 0.83 0.98 0.98 + 0.86 0.997 0.997 + 0.879 1 1 + 0.88 1 1 / + + +-- PVT PROPERTIES OF WATER +-- +-- REF. PRES. REF. FVF COMPRESSIBILITY REF VISCOSITY VISCOSIBILITY +PVTW + 4014.7 1.029 3.13D-6 0.31 0 / + +-- ROCK COMPRESSIBILITY +-- +-- REF. PRES COMPRESSIBILITY +ROCK + 14.7 3.0D-6 / + +-- SURFACE DENSITIES OF RESERVOIR FLUIDS +-- +-- OIL WATER GAS +DENSITY + 49.1 64.79 0.06054 / + +-- PVT PROPERTIES OF DRY GAS (NO VAPOURISED OIL) +-- WE WOULD USE PVTG TO SPECIFY THE PROPERTIES OF WET GAS +-- +-- PGAS BGAS VISGAS +PVDG + 14.7 166.666 0.008 + 264.7 12.093 0.0096 + 514.7 6.274 0.0112 + 1014.7 3.197 0.014 + 2014.7 1.614 0.0189 + 2514.7 1.294 0.0208 + 3014.7 1.080 0.0228 + 4014.7 0.811 0.0268 + 5014.7 0.649 0.0309 + 9014.7 0.386 0.047 / + +-- PVT PROPERTIES OF LIVE OIL (WITH DISSOLVED GAS) +-- WE WOULD USE PVDO TO SPECIFY THE PROPERTIES OF DEAD OIL +-- +-- FOR EACH VALUE OF RS THE SATURATION PRESSURE, FVF AND VISCOSITY +-- ARE SPECIFIED. FOR RS=1.27 AND 1.618, THE FVF AND VISCOSITY OF +-- UNDERSATURATED OIL ARE DEFINED AS A FUNCTION OF PRESSURE. DATA +-- FOR UNDERSATURATED OIL MAY BE SUPPLIED FOR ANY RS, BUT MUST BE +-- SUPPLIED FOR THE HIGHEST RS (1.618). +-- +-- RS POIL FVFO VISO +PVTO + 0.001 14.7 1.062 1.04 / + 0.0905 264.7 1.15 0.975 / + 0.18 514.7 1.207 0.91 / + 0.371 1014.7 1.295 0.83 / + 0.636 2014.7 1.435 0.695 / + 0.775 2514.7 1.5 0.641 / + 0.93 3014.7 1.565 0.594 / + 1.270 4014.7 1.695 0.51 + 5014.7 1.671 0.549 + 9014.7 1.579 0.74 / + 1.618 5014.7 1.827 0.449 + 9014.7 1.726 0.605 / +/ + + +REGIONS =========================================================== + + +FIPNUM + + 1000*1 +/ + +EQLNUM + + 1000*1 +/ + + +SOLUTION ============================================================ + +EQUIL +7020.00 2700.00 7990.00 .00000 7200.00 .00000 0 0 5 / + +RSVD 2 TABLES 3 NODES IN EACH FIELD 12:00 17 AUG 83 + 7000.0 1.0000 + 7990.0 1.0000 +/ SCHEDULE RPTRST @@ -511,7 +659,7 @@ BOOST_AUTO_TEST_CASE (Declared_Well_Data) // No THP limit BOOST_CHECK_CLOSE(swell[i0 + Ix::THPTarget] , 0.0f, 1.0e-7f); BOOST_CHECK_CLOSE(swell[i0 + Ix::BHPTarget] , 1000.0f, 1.0e-7f); - BOOST_CHECK_CLOSE(swell[i0 + Ix::DatumDepth], 0.375f, 1.0e-7f); + BOOST_CHECK_CLOSE(swell[i0 + Ix::DatumDepth], 7050.00049f, 1.0e-7f); } // SWEL (OP_2) @@ -524,7 +672,7 @@ BOOST_AUTO_TEST_CASE (Declared_Well_Data) BOOST_CHECK_CLOSE(swell[i1 + Ix::THPTarget], 1.0e20f, 1.0e-7f); BOOST_CHECK_CLOSE(swell[i1 + Ix::BHPTarget], 400.0f, 1.0e-7f); - BOOST_CHECK_CLOSE(swell[i1 + Ix::DatumDepth], 0.625f, 1.0e-7f); + BOOST_CHECK_CLOSE(swell[i1 + Ix::DatumDepth], 7150.0f, 1.0e-7f); } // XWEL (OP_1)