Load WLIST from restart file

This commit is contained in:
Joakim Hove 2021-10-14 21:00:56 +02:00
parent 0f0dcea773
commit 091ec36c28
10 changed files with 67 additions and 9 deletions

View File

@ -91,6 +91,7 @@ struct RstHeader {
int nfield_udq;
int num_action;
int guide_rate_nominated_phase;
int max_wlist;
bool e300_radial;
bool e100_radial;

View File

@ -21,6 +21,7 @@
#include <memory>
#include <string>
#include <unordered_map>
#include <vector>
#include <opm/io/eclipse/rst/header.hpp>
@ -67,6 +68,7 @@ struct RstState {
RstUDQActive udq_active;
std::vector<RstAction> actions;
Tuning tuning;
std::unordered_map<std::string, std::vector<std::string>> wlists;
private:
void load_tuning(const std::vector<int>& intehead,
@ -113,6 +115,9 @@ private:
const std::vector<double>& sacn,
const std::vector<std::string>& zlact);
void add_wlist(const std::vector<std::string>& zwls,
const std::vector<int>& iwls);
};
}} // namespace Opm::RestartIO

View File

@ -27,10 +27,14 @@
namespace Opm {
namespace RestartIO {
class RstState;
}
class WListManager {
public:
WListManager() = default;
explicit WListManager(const RestartIO::RstState& rst_state);
static WListManager serializeObject();
std::size_t WListSize() const;

View File

@ -92,6 +92,7 @@ RstHeader::RstHeader(const Opm::UnitSystem& unit_system, const std::vector<int>&
nfield_udq(intehead[VI::intehead::NO_FIELD_UDQS]),
num_action(intehead[VI::intehead::NOOFACTIONS]),
guide_rate_nominated_phase(intehead[VI::intehead::NGRNPH]),
max_wlist(intehead[VI::intehead::MXWLSTPRWELL]),
//
e300_radial(logihead[VI::logihead::E300Radial]),
e100_radial(logihead[VI::logihead::E100Radial]),

View File

@ -347,6 +347,25 @@ void RstState::add_actions(const Parser& parser,
}
}
void RstState::add_wlist(const std::vector<std::string>& zwls,
const std::vector<int>& iwls)
{
for (std::size_t well_index = 0; well_index < this->header.num_wells; well_index++) {
const auto zwls_offset = this->header.max_wlist * well_index;
const auto iwls_offset = this->header.max_wlist * well_index;
const auto& well_name = this->wells[well_index].name;
for (std::size_t wlist_index = 0; wlist_index < this->header.max_wlist; wlist_index++) {
int well_order = iwls[iwls_offset + wlist_index];
if (well_order != 0) {
const auto& wlist_name = zwls[zwls_offset + wlist_index];
auto& wlist = this->wlists[wlist_name];
wlist.resize( well_order );
wlist[well_order - 1] = well_name;
}
}
}
}
const RstWell& RstState::get_well(const std::string& wname) const {
const auto well_iter = std::find_if(this->wells.begin(),
@ -395,6 +414,13 @@ RstState RstState::load(std::shared_ptr<EclIO::RestartFileView> rstView,
} else
state.add_wells(zwel, iwel, swel, xwel,
icon, scon, xcon);
if (rstView->hasKeyword<int>("IWLS")) {
const auto& iwls = rstView->getKeyword<int>("IWLS");
const auto& zwls = rstView->getKeyword<std::string>("ZWLS");
state.add_wlist(zwls, iwls);
}
}
if (state.header.num_udq() > 0) {

View File

@ -133,14 +133,14 @@ void staticContrib(const Opm::Well& well,
const std::vector<std::vector<std::size_t>> & welOrdLst,
IWlsArray& iWls)
{
const auto& seq_ind = well.seqIndex();
const auto& well_index = well.seqIndex();
// set values for iWls to the well order for all Wlists
//
std::size_t ind = 0;
for (const auto& wlist_vec : welOrdLst[seq_ind]) {
iWls[ind] = wlist_vec;
ind += 1;
std::size_t output_index = 0;
for (const auto& wlist_index : welOrdLst[well_index]) {
iWls[output_index] = wlist_index;
output_index += 1;
}
}

View File

@ -1489,6 +1489,10 @@ namespace {
this->snapshots.back().actions.update( std::move(actions) );
}
this->snapshots.back().wtest_config.update( WellTestConfig{rst_state, report_step});
if (!rst_state.wlists.empty())
this->snapshots.back().wlist_manager.update( WListManager(rst_state) );
}
std::shared_ptr<const Python> Schedule::python() const

View File

@ -21,8 +21,10 @@
#include <unordered_set>
#include <algorithm>
#include <opm/io/eclipse/rst/state.hpp>
#include <opm/parser/eclipse/EclipseState/Schedule/Well/WList.hpp>
#include <opm/parser/eclipse/EclipseState/Schedule/Well/WListManager.hpp>
namespace Opm {
WListManager WListManager::serializeObject()
@ -33,6 +35,11 @@ namespace Opm {
return result;
}
WListManager::WListManager(const RestartIO::RstState& rst_state) {
for (const auto& [wlist, wells] : rst_state.wlists)
this->newList(wlist, wells);
}
std::size_t WListManager::WListSize() const {
return (this->wlists.size());
}

View File

@ -1559,8 +1559,8 @@ EQUALS
/
SOLUTION
RESTART
'RESTART' 10 1* 'UNFORMATTED' /
/
'ACTIONX_M1' 10 1* 'UNFORMATTED' /
SUMMARY
FPR
WBHP
@ -1595,7 +1595,7 @@ GVIR
FUINJLIM
SCHEDULE
SKIPREST
/
TUNING
0.5 5 /
/

View File

@ -228,6 +228,16 @@ BOOST_AUTO_TEST_CASE(LoadUDQRestartSim0) {
BOOST_CHECK_THROW( group.injectionProperties(Phase::WATER), std::exception );
}
BOOST_AUTO_TEST_CASE(LoadWLISTRestartSim) {
const auto& [sched, restart_sched, _] = load_schedule_pair("ACTIONX_M1.DATA", "ACTIONX_M1_RESTART.DATA", "ACTIONX_M1.X0010", 10);
(void)_;
std::size_t report_step = 12;
const auto& wlm = sched[report_step].wlist_manager();
const auto& rst_wlm = restart_sched[report_step].wlist_manager();
BOOST_CHECK(wlm == rst_wlm);
}
BOOST_AUTO_TEST_CASE(TestFileDeck)