added unit tests incl. test dataset
This commit is contained in:
@@ -422,6 +422,7 @@ if(ENABLE_ECL_OUTPUT)
|
||||
tests/test_AggregateWellData.cpp
|
||||
tests/test_AggregateGroupData.cpp
|
||||
tests/test_AggregateNetworkData.cpp
|
||||
tests/test_AggregateWListData.cpp
|
||||
tests/test_AggregateMSWData.cpp
|
||||
tests/test_AggregateConnectionData.cpp
|
||||
tests/test_AggregateUDQData.cpp
|
||||
@@ -489,6 +490,7 @@ if(ENABLE_ECL_OUTPUT)
|
||||
tests/0A4_GRCTRL_LRAT_LRAT_GGR_BASE_MODEL2_MSW_ALL.DATA
|
||||
tests/2_WLIFT_MODEL5_NOINC.DATA
|
||||
tests/TEST_NETWORK_ALL.DATA
|
||||
tests/TEST_WLIST.DATA
|
||||
tests/act1.py
|
||||
tests/MSW.DATA
|
||||
tests/EXIT_TEST.DATA
|
||||
|
||||
@@ -115,7 +115,7 @@ std::vector<std::vector<std::size_t>> wellOrderInWList(const Opm::Schedule& sc
|
||||
if (well_no) {
|
||||
std::cout << "well found in well list - well no: " << well_no.value() << " wlist.wells()[well_no.value()] " << wlist.wells()[well_no.value()] << std::endl;
|
||||
} else {
|
||||
std::cout << "well found in well list" << std::endl;
|
||||
std::cout << "well not found in well list" << std::endl;
|
||||
}
|
||||
if (well_no) well_order[iwlst] = well_no.value() + 1;
|
||||
std::cout << "WList-name: " << wlst_name << " iwlst: " << iwlst << " well_order[iwlst]: " << well_order[iwlst] << std::endl;
|
||||
@@ -134,50 +134,6 @@ std::vector<std::vector<std::size_t>> wellOrderInWList(const Opm::Schedule& sc
|
||||
}
|
||||
return curWelOrd;
|
||||
}
|
||||
/*
|
||||
std::map<std::size_t, std::vector<std::size_t>> wellOrderInWList(const Opm::Schedule& sched,
|
||||
const std::size_t sim_step,
|
||||
const std::vector<int>& inteHead ) {
|
||||
const auto& wells = sched.wellNames(sim_step);
|
||||
const auto& wlmngr = sched.getWListManager(sim_step);
|
||||
|
||||
std::map<std::size_t, std::vector<std::size_t>> curWelOrd;
|
||||
std::size_t iwlst;
|
||||
std::size_t iwell = 0;
|
||||
Opm::Wlist wlist;
|
||||
//std::vector<std::size_t> min_ind;
|
||||
//min_ind.resize(maxNoOfWellListsPrWell(inteHead), maxNoOfWellListsPrWell(inteHead));
|
||||
std::vector<std::size_t> well_order;
|
||||
well_order.resize(maxNoOfWellListsPrWell(inteHead), 0);
|
||||
|
||||
// loop over wells and establish map
|
||||
//
|
||||
for (const auto& wname : wells) {
|
||||
const auto& well = sched.getWell(wname, sim_step);
|
||||
const auto& wsind = well.seqIndex();
|
||||
|
||||
// loop over well lists for well - and assign well sequence in the different well lists
|
||||
//
|
||||
iwlst = 0;
|
||||
for ( const auto& wlst_name : well.wListNames()) {
|
||||
if (wlmngr.hasList(wlst_name)) {
|
||||
wlist = wlmngr.getList(wlst_name);
|
||||
auto well_no = findInVector<int>(wlist.wells(), wname);
|
||||
if (well_no) well_order[iwlst] = well_no.value() + 1;
|
||||
iwlst += 1;
|
||||
} else {
|
||||
auto msg = fmt::format("Well List Manager does not contain WLIST: {} ", wlst_name);
|
||||
throw std::logic_error(msg);
|
||||
}
|
||||
}
|
||||
//store vector in map
|
||||
curWelOrd.insert(std::pair<std::size_t, std::vector<std::size_t>> (iwell, well_order));
|
||||
iwell += 1;
|
||||
}
|
||||
return curWelOrd;
|
||||
}
|
||||
*/
|
||||
|
||||
|
||||
template <typename WellOp>
|
||||
void wellLoop(const std::vector<std::string>& wells,
|
||||
@@ -212,7 +168,7 @@ void staticContrib(const Opm::Well& well,
|
||||
{
|
||||
const auto& seq_ind = well.seqIndex();
|
||||
|
||||
// set values if iWls to the well order for all Wlists
|
||||
// set values for iWls to the well order for all Wlists
|
||||
//
|
||||
std::size_t ind = 0;
|
||||
std::cout << "Well-name: " << well.name() << " seq_ind: " << seq_ind << std::endl;
|
||||
@@ -287,8 +243,6 @@ captureDeclaredWListData(const Schedule& sched,
|
||||
// Static contributions to ZWLS array.
|
||||
|
||||
{
|
||||
//const auto actResStat = ZWell::act_res_stat(sched, action_state, smry, sim_step);
|
||||
|
||||
// Static contributions to ZWLS array.
|
||||
wellLoop(wells, sched, sim_step, [&welOrdLst, this]
|
||||
(const Well& well, const std::size_t wellID) -> void
|
||||
|
||||
2581
tests/TEST_WLIST.DATA
Normal file
2581
tests/TEST_WLIST.DATA
Normal file
File diff suppressed because it is too large
Load Diff
203
tests/test_AggregateWListData.cpp
Normal file
203
tests/test_AggregateWListData.cpp
Normal file
@@ -0,0 +1,203 @@
|
||||
/*
|
||||
Copyright 2018 Statoil ASA
|
||||
|
||||
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
|
||||
the Free Software Foundation, either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
OPM is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with OPM. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#define BOOST_TEST_MODULE Aggregate_Group_Data
|
||||
#include <opm/output/eclipse/AggregateGroupData.hpp>
|
||||
#include <opm/output/eclipse/AggregateNetworkData.hpp>
|
||||
#include <opm/output/eclipse/AggregateWListData.hpp>
|
||||
#include <opm/output/eclipse/WriteRestartHelpers.hpp>
|
||||
|
||||
#include <boost/test/unit_test.hpp>
|
||||
|
||||
#include <opm/output/eclipse/AggregateWellData.hpp>
|
||||
#include <opm/parser/eclipse/EclipseState/Schedule/Well/WList.hpp>
|
||||
|
||||
#include <opm/output/eclipse/VectorItems/intehead.hpp>
|
||||
#include <opm/output/eclipse/VectorItems/group.hpp>
|
||||
#include <opm/output/eclipse/VectorItems/well.hpp>
|
||||
#include <opm/parser/eclipse/Python/Python.hpp>
|
||||
|
||||
#include <opm/output/data/Wells.hpp>
|
||||
|
||||
#include <opm/parser/eclipse/Deck/Deck.hpp>
|
||||
#include <opm/parser/eclipse/Parser/Parser.hpp>
|
||||
#include <opm/parser/eclipse/EclipseState/EclipseState.hpp>
|
||||
#include <opm/parser/eclipse/EclipseState/Schedule/Schedule.hpp>
|
||||
#include <opm/parser/eclipse/EclipseState/Schedule/SummaryState.hpp>
|
||||
|
||||
#include <opm/io/eclipse/OutputStream.hpp>
|
||||
#include <opm/common/utility/TimeService.hpp>
|
||||
|
||||
#include <exception>
|
||||
#include <stdexcept>
|
||||
#include <utility>
|
||||
#include <vector>
|
||||
#include <iostream>
|
||||
#include <cstddef>
|
||||
|
||||
namespace {
|
||||
|
||||
|
||||
Opm::Deck first_sim(std::string fname) {
|
||||
return Opm::Parser{}.parseFile(fname);
|
||||
}
|
||||
|
||||
#if 0
|
||||
Opm::SummaryState sum_state()
|
||||
{
|
||||
auto state = Opm::SummaryState{Opm::TimeService::now()};
|
||||
|
||||
state.update_well_var("P1", "WOPR", 3342.673828);
|
||||
state.update_well_var("P1", "WWPR", 0.000005);
|
||||
state.update_well_var("P1", "WGPR", 334267.375);
|
||||
state.update_well_var("P1", "WGLIR", 111000.);
|
||||
|
||||
state.update_well_var("P2", "WOPR", 3882.443848);
|
||||
state.update_well_var("P2", "WWPR", 0.000002);
|
||||
state.update_well_var("P2", "WGPR", 672736.9375);
|
||||
state.update_well_var("P2", "WGLIR", 99666.);
|
||||
|
||||
state.update_well_var("P3", "WOPR", 3000.000000);
|
||||
state.update_well_var("P3", "WWPR", 0.000002);
|
||||
state.update_well_var("P3", "WGPR", 529658.8125);
|
||||
state.update_well_var("P3", "WGLIR", 55000.);
|
||||
|
||||
state.update_group_var("B1", "GPR", 81.6848);
|
||||
state.update_group_var("N1", "GPR", 72.);
|
||||
state.update_group_var("N2", "GPR", 69.);
|
||||
state.update_group_var("PLAT-A", "GPR", 67.);
|
||||
state.update_group_var("B2", "GPR", 79.0666);
|
||||
state.update_group_var("M1", "GPR", 72.);
|
||||
|
||||
return state;
|
||||
}
|
||||
#endif
|
||||
|
||||
std::string pad8(const std::string& s) {
|
||||
return s + std::string( 8 - s.size(), ' ');
|
||||
}
|
||||
}
|
||||
|
||||
struct SimulationCase
|
||||
{
|
||||
explicit SimulationCase(const Opm::Deck& deck)
|
||||
: es ( deck )
|
||||
, grid { deck }
|
||||
, python( std::make_shared<Opm::Python>() )
|
||||
, sched (deck, es, python )
|
||||
{}
|
||||
|
||||
// Order requirement: 'es' must be declared/initialised before 'sched'.
|
||||
Opm::EclipseState es;
|
||||
Opm::EclipseGrid grid;
|
||||
std::shared_ptr<Opm::Python> python;
|
||||
Opm::Schedule sched;
|
||||
};
|
||||
|
||||
// =====================================================================
|
||||
|
||||
BOOST_AUTO_TEST_SUITE(Aggregate_Network)
|
||||
|
||||
|
||||
// test dimensions of multisegment data
|
||||
BOOST_AUTO_TEST_CASE (Constructor)
|
||||
{
|
||||
namespace VI = ::Opm::RestartIO::Helpers::VectorItems;
|
||||
const auto simCase = SimulationCase{first_sim("TEST_WLIST.DATA")};
|
||||
|
||||
Opm::EclipseState es = simCase.es;
|
||||
//Opm::Runspec rspec = es.runspec();
|
||||
//Opm::SummaryState st = sum_state();
|
||||
Opm::Schedule sched = simCase.sched;
|
||||
Opm::EclipseGrid grid = simCase.grid;
|
||||
//const auto& ioConfig = es.getIOConfig();
|
||||
const auto& units = es.getUnits();
|
||||
|
||||
|
||||
// Report Step 1: 2008-10-10 --> 2011-01-20
|
||||
const auto rptStep = std::size_t{8};
|
||||
|
||||
double secs_elapsed = 3.1536E07;
|
||||
const auto ih = Opm::RestartIO::Helpers::
|
||||
createInteHead(es, grid, sched, secs_elapsed,
|
||||
rptStep, rptStep+1, rptStep);
|
||||
|
||||
auto wListData = Opm::RestartIO::Helpers::AggregateWListData(ih);
|
||||
wListData.captureDeclaredWListData(sched, rptStep, ih);
|
||||
|
||||
BOOST_CHECK_EQUAL(static_cast<int>(wListData.getIWls().size()), ih[VI::intehead::NWMAXZ] * ih[VI::intehead::MXWLSTPRWELL]);
|
||||
BOOST_CHECK_EQUAL(static_cast<int>(wListData.getZWls().size()), ih[VI::intehead::NWMAXZ] * ih[VI::intehead::MXWLSTPRWELL]);
|
||||
|
||||
//IWls-parameters
|
||||
const auto& iWLs = wListData.getIWls();
|
||||
auto start = 0*ih[VI::intehead::MXWLSTPRWELL];
|
||||
BOOST_CHECK_EQUAL(iWLs[start + 0], 2);
|
||||
BOOST_CHECK_EQUAL(iWLs[start + 1], 2);
|
||||
BOOST_CHECK_EQUAL(iWLs[start + 2], 0);
|
||||
BOOST_CHECK_EQUAL(iWLs[start + 3], 0);
|
||||
|
||||
start = 1*ih[VI::intehead::MXWLSTPRWELL];
|
||||
BOOST_CHECK_EQUAL(iWLs[start + 0], 3);
|
||||
BOOST_CHECK_EQUAL(iWLs[start + 1], 0);
|
||||
BOOST_CHECK_EQUAL(iWLs[start + 2], 0);
|
||||
BOOST_CHECK_EQUAL(iWLs[start + 3], 0);
|
||||
|
||||
start = 2*ih[VI::intehead::MXWLSTPRWELL];
|
||||
BOOST_CHECK_EQUAL(iWLs[start + 0], 1);
|
||||
BOOST_CHECK_EQUAL(iWLs[start + 1], 1);
|
||||
BOOST_CHECK_EQUAL(iWLs[start + 2], 0);
|
||||
BOOST_CHECK_EQUAL(iWLs[start + 3], 0);
|
||||
|
||||
start = 3*ih[VI::intehead::MXWLSTPRWELL];
|
||||
BOOST_CHECK_EQUAL(iWLs[start + 0], 1);
|
||||
BOOST_CHECK_EQUAL(iWLs[start + 1], 0);
|
||||
BOOST_CHECK_EQUAL(iWLs[start + 2], 0);
|
||||
BOOST_CHECK_EQUAL(iWLs[start + 3], 0);
|
||||
|
||||
//ZWLs-parameters
|
||||
const std::string blank8 = " ";
|
||||
|
||||
const auto& zWLs = wListData.getZWls();
|
||||
start = 0*ih[VI::intehead::MXWLSTPRWELL];
|
||||
BOOST_CHECK_EQUAL(zWLs[start + 0].c_str(), pad8("*PRD1"));
|
||||
BOOST_CHECK_EQUAL(zWLs[start + 1].c_str(), pad8("*PRD2"));
|
||||
BOOST_CHECK_EQUAL(zWLs[start + 2].c_str(), blank8);
|
||||
BOOST_CHECK_EQUAL(zWLs[start + 3].c_str(), blank8);
|
||||
|
||||
start = 1*ih[VI::intehead::MXWLSTPRWELL];
|
||||
BOOST_CHECK_EQUAL(zWLs[start + 0].c_str(), pad8("*PRD2"));
|
||||
BOOST_CHECK_EQUAL(zWLs[start + 1].c_str(), blank8);
|
||||
BOOST_CHECK_EQUAL(zWLs[start + 2].c_str(), blank8);
|
||||
BOOST_CHECK_EQUAL(zWLs[start + 3].c_str(), blank8);
|
||||
|
||||
start = 2*ih[VI::intehead::MXWLSTPRWELL];
|
||||
BOOST_CHECK_EQUAL(zWLs[start + 0].c_str(), pad8("*PRD2"));
|
||||
BOOST_CHECK_EQUAL(zWLs[start + 1].c_str(), pad8("*PRD1"));
|
||||
BOOST_CHECK_EQUAL(zWLs[start + 2].c_str(), blank8);
|
||||
BOOST_CHECK_EQUAL(zWLs[start + 3].c_str(), blank8);
|
||||
|
||||
start = 3*ih[VI::intehead::MXWLSTPRWELL];
|
||||
BOOST_CHECK_EQUAL(zWLs[start + 0].c_str(), pad8("*INJ1"));
|
||||
BOOST_CHECK_EQUAL(zWLs[start + 1].c_str(), blank8);
|
||||
BOOST_CHECK_EQUAL(zWLs[start + 2].c_str(), blank8);
|
||||
BOOST_CHECK_EQUAL(zWLs[start + 3].c_str(), blank8);
|
||||
|
||||
}
|
||||
|
||||
BOOST_AUTO_TEST_SUITE_END()
|
||||
Reference in New Issue
Block a user