Merge pull request #3155 from bska/support-rft-seg-option

Internalise WRFTPLT Segment Option
This commit is contained in:
Bård Skaflestad 2022-09-27 18:07:45 +02:00 committed by GitHub
commit c5158a1c24
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 156 additions and 30 deletions

View File

@ -52,6 +52,7 @@ public:
void first_open(bool on);
void update(const std::string& wname, const PLT mode);
void update(const std::string& wname, const RFT mode);
void update_segment(const std::string& wname, const PLT mode);
bool active() const;
@ -61,26 +62,41 @@ public:
bool plt() const;
bool plt(const std::string& wname) const;
bool segment() const;
bool segment(const std::string& wname) const;
std::optional<RFTConfig> next() const;
std::optional<RFTConfig> well_open(const std::string& wname) const;
static RFTConfig serializeObject();
bool operator==(const RFTConfig& data) const;
template<class Serializer>
template <class Serializer>
void serializeOp(Serializer& serializer)
{
serializer(first_open_rft);
serializer(rft_state);
serializer(plt_state);
serializer(open_wells);
serializer(this->first_open_rft);
serializer(this->rft_state);
serializer(this->plt_state);
serializer(this->seg_state);
serializer(this->open_wells);
}
private:
template <typename Kind>
using StateMap = std::unordered_map<std::string, Kind>;
// Please make sure that member functions serializeOp(), operator==(),
// and serializeObject() are also up to date when changing this list of
// data members.
bool first_open_rft = false;
std::unordered_map<std::string, RFT> rft_state;
std::unordered_map<std::string, PLT> plt_state;
std::unordered_map<std::string, bool> open_wells;
StateMap<RFT> rft_state{};
StateMap<PLT> plt_state{};
StateMap<PLT> seg_state{};
std::unordered_map<std::string, bool> open_wells{};
void update_state(const std::string& wname,
const PLT mode,
StateMap<PLT>& state);
};
} // namespace Opm

View File

@ -2160,10 +2160,12 @@ Well{0} entered with disallowed 'FIELD' parent group:
const auto RFTKey = rftKey(record.getItem<ParserKeywords::WRFTPLT::OUTPUT_RFT>());
const auto PLTKey = pltKey(record.getItem<ParserKeywords::WRFTPLT::OUTPUT_PLT>());
const auto SEGKey = pltKey(record.getItem<ParserKeywords::WRFTPLT::OUTPUT_SEGMENT>());
for (const auto& well_name : well_names) {
new_rft.update(well_name, RFTKey);
new_rft.update(well_name, PLTKey);
new_rft.update_segment(well_name, SEGKey);
}
}

View File

@ -140,11 +140,7 @@ void RFTConfig::first_open(const bool on)
void RFTConfig::update(const std::string& wname, RFT mode)
{
if (mode == RFT::NO) {
auto iter = this->rft_state.find(wname);
if (iter != this->rft_state.end()) {
this->rft_state.erase(iter);
}
this->rft_state.erase(wname);
return;
}
@ -160,23 +156,33 @@ void RFTConfig::update(const std::string& wname, RFT mode)
this->rft_state.insert_or_assign(wname, mode);
}
void RFTConfig::update(const std::string& wname, const PLT mode)
void RFTConfig::update_state(const std::string& wname,
const PLT mode,
StateMap<PLT>& state)
{
if (mode == PLT::NO) {
auto iter = this->plt_state.find(wname);
if (iter != this->plt_state.end()) {
this->plt_state.erase(iter);
}
return;
// Remove 'wname' from list of wells for which to output PLT-type
// data.
state.erase(wname);
}
else {
state.insert_or_assign(wname, mode);
}
}
this->plt_state[wname] = mode;
void RFTConfig::update(const std::string& wname, const PLT mode)
{
this->update_state(wname, mode, this->plt_state);
}
void RFTConfig::update_segment(const std::string& wname, const PLT mode)
{
this->update_state(wname, mode, this->seg_state);
}
bool RFTConfig::active() const
{
return this->rft() || this->plt();
return this->rft() || this->plt() || this->segment();
}
bool RFTConfig::rft() const
@ -206,6 +212,16 @@ bool RFTConfig::plt(const std::string& wname) const
return this->plt_state.find(wname) != this->plt_state.end();
}
bool RFTConfig::segment() const
{
return ! this->seg_state.empty();
}
bool RFTConfig::segment(const std::string& wname) const
{
return this->seg_state.find(wname) != this->seg_state.end();
}
std::optional<RFTConfig>
RFTConfig::well_open(const std::string& wname) const
{
@ -256,9 +272,10 @@ std::optional<RFTConfig> RFTConfig::next() const
const auto rft_has_yes = mapContains(this->rft_state, rft_is_yes);
const auto plt_has_yes = mapContains(this->plt_state, plt_is_yes);
const auto seg_has_yes = mapContains(this->seg_state, plt_is_yes);
if (! (rft_has_yes || plt_has_yes)) {
// No 'YES' node in either the RFT or the PLT states. Return
if (! (rft_has_yes || plt_has_yes || seg_has_yes)) {
// No 'YES' node in either the RFT, PLT, or SEG states. Return
// nullopt to signify that next block is unchanged from current.
return {};
}
@ -274,6 +291,10 @@ std::optional<RFTConfig> RFTConfig::next() const
pruneFromMapIf(new_rft->plt_state, plt_is_yes);
}
if (seg_has_yes) {
pruneFromMapIf(new_rft->seg_state, plt_is_yes);
}
return new_rft;
}
@ -282,6 +303,7 @@ bool RFTConfig::operator==(const RFTConfig& data) const
return (this->first_open_rft == data.first_open_rft)
&& (this->rft_state == data.rft_state)
&& (this->plt_state == data.plt_state)
&& (this->seg_state == data.seg_state)
&& (this->open_wells == data.open_wells);
}
@ -301,6 +323,9 @@ RFTConfig RFTConfig::serializeObject()
// Trigger PLT output for P-2 at every timestep.
rft_config.update("P-2", PLT::TIMESTEP);
// Trigger SEG output for P-3 at every report step.
rft_config.update_segment("P-3", PLT::REPT);
// I-1 is an open well at this time.
rft_config.open_wells.emplace("I-1", true);

View File

@ -409,7 +409,7 @@ TSTEP
3*30 /
WRFTPLT
'P' YES /
'P' YES NO REPT /
'I' NO YES /
/
@ -418,7 +418,7 @@ TSTEP
3*30 /
WRFTPLT
'*' TIMESTEP /
'*' TIMESTEP NO TIMESTEP /
/
TSTEP
@ -459,7 +459,7 @@ TSTEP
30 30 30 /
WRFTPLT
'P' 1* YES /
'P' 1* YES YES /
'I' REPT /
/
@ -493,7 +493,7 @@ TSTEP
30 30 /
WRFTPLT
'*' TIMESTEP /
'*' TIMESTEP NO REPT /
/
TSTEP
@ -543,6 +543,23 @@ BOOST_AUTO_TEST_CASE(All_Open)
BOOST_CHECK_MESSAGE(!sched[14].rft_config().plt("P"), R"(Should NOT Output PLT Data for "P" at Step 14)");
BOOST_CHECK_MESSAGE(!sched[15].rft_config().plt("P"), R"(Should NOT Output PLT Data for "P" at Step 15)");
BOOST_CHECK_MESSAGE(!sched[ 0].rft_config().segment("P"), R"(Should NOT Output SEGMENT Data for "P" at Step 0)");
BOOST_CHECK_MESSAGE(!sched[ 1].rft_config().segment("P"), R"(Should NOT Output SEGMENT Data for "P" at Step 1)");
BOOST_CHECK_MESSAGE(!sched[ 2].rft_config().segment("P"), R"(Should NOT Output SEGMENT Data for "P" at Step 2)");
BOOST_CHECK_MESSAGE(!sched[ 3].rft_config().segment("P"), R"(Should NOT Output SEGMENT Data for "P" at Step 3)");
BOOST_CHECK_MESSAGE(!sched[ 4].rft_config().segment("P"), R"(Should NOT Output SEGMENT Data for "P" at Step 4)");
BOOST_CHECK_MESSAGE(!sched[ 5].rft_config().segment("P"), R"(Should NOT Output SEGMENT Data for "P" at Step 5)");
BOOST_CHECK_MESSAGE(!sched[ 6].rft_config().segment("P"), R"(Should NOT Output SEGMENT Data for "P" at Step 6)");
BOOST_CHECK_MESSAGE(!sched[ 7].rft_config().segment("P"), R"(Should NOT Output SEGMENT Data for "P" at Step 7)");
BOOST_CHECK_MESSAGE(!sched[ 8].rft_config().segment("P"), R"(Should NOT Output SEGMENT Data for "P" at Step 8)");
BOOST_CHECK_MESSAGE(!sched[ 9].rft_config().segment("P"), R"(Should NOT Output SEGMENT Data for "P" at Step 9)");
BOOST_CHECK_MESSAGE( sched[10].rft_config().segment("P"), R"(Should Output SEGMENT Data for "P" at Step 10)");
BOOST_CHECK_MESSAGE( sched[11].rft_config().segment("P"), R"(Should Output SEGMENT Data for "P" at Step 11)");
BOOST_CHECK_MESSAGE( sched[12].rft_config().segment("P"), R"(Should Output SEGMENT Data for "P" at Step 12)");
BOOST_CHECK_MESSAGE( sched[13].rft_config().segment("P"), R"(Should Output SEGMENT Data for "P" at Step 13)");
BOOST_CHECK_MESSAGE( sched[14].rft_config().segment("P"), R"(Should Output SEGMENT Data for "P" at Step 14)");
BOOST_CHECK_MESSAGE( sched[15].rft_config().segment("P"), R"(Should Output SEGMENT Data for "P" at Step 15)");
BOOST_CHECK_MESSAGE(!sched[ 0].rft_config().rft("I"), R"(Should NOT Output RFT Data for "I" at Step 0)");
BOOST_CHECK_MESSAGE(!sched[ 1].rft_config().rft("I"), R"(Should NOT Output RFT Data for "I" at Step 1)");
BOOST_CHECK_MESSAGE(!sched[ 2].rft_config().rft("I"), R"(Should NOT Output RFT Data for "I" at Step 2)");
@ -588,8 +605,8 @@ BOOST_AUTO_TEST_CASE(All_Open)
BOOST_CHECK_MESSAGE( sched[ 8].rft_config().active(), R"(RFT Config must be Active at Step 8)");
BOOST_CHECK_MESSAGE( sched[ 9].rft_config().active(), R"(RFT Config must be Active at Step 9)");
BOOST_CHECK_MESSAGE( sched[10].rft_config().active(), R"(RFT Config must be Active at Step 10)");
BOOST_CHECK_MESSAGE(!sched[11].rft_config().active(), R"(RFT Config must be Inactive at Step 11)");
BOOST_CHECK_MESSAGE(!sched[12].rft_config().active(), R"(RFT Config must be Inactive at Step 12)");
BOOST_CHECK_MESSAGE( sched[11].rft_config().active(), R"(RFT Config must be Active at Step 11)");
BOOST_CHECK_MESSAGE( sched[12].rft_config().active(), R"(RFT Config must be Active at Step 12)");
BOOST_CHECK_MESSAGE( sched[13].rft_config().active(), R"(RFT Config must be Active at Step 13)");
BOOST_CHECK_MESSAGE( sched[14].rft_config().active(), R"(RFT Config must be Active at Step 14)");
BOOST_CHECK_MESSAGE( sched[15].rft_config().active(), R"(RFT Config must be Active at Step 15)");
@ -646,6 +663,28 @@ BOOST_AUTO_TEST_CASE(Deferred_Open)
BOOST_CHECK_MESSAGE(!sched[19].rft_config().plt("P"), R"(Should NOT Output PLT Data for "P" at Step 19)");
BOOST_CHECK_MESSAGE(!sched[20].rft_config().plt("P"), R"(Should NOT Output PLT Data for "P" at Step 20)");
BOOST_CHECK_MESSAGE(!sched[ 0].rft_config().segment("P"), R"(Should NOT Output SEGMENT Data for "P" at Step 0)");
BOOST_CHECK_MESSAGE(!sched[ 1].rft_config().segment("P"), R"(Should NOT Output SEGMENT Data for "P" at Step 1)");
BOOST_CHECK_MESSAGE(!sched[ 2].rft_config().segment("P"), R"(Should NOT Output SEGMENT Data for "P" at Step 2)");
BOOST_CHECK_MESSAGE(!sched[ 3].rft_config().segment("P"), R"(Should NOT Output SEGMENT Data for "P" at Step 3)");
BOOST_CHECK_MESSAGE(!sched[ 4].rft_config().segment("P"), R"(Should NOT Output SEGMENT Data for "P" at Step 4)");
BOOST_CHECK_MESSAGE(!sched[ 5].rft_config().segment("P"), R"(Should NOT Output SEGMENT Data for "P" at Step 5)");
BOOST_CHECK_MESSAGE(!sched[ 6].rft_config().segment("P"), R"(Should NOT Output SEGMENT Data for "P" at Step 6)");
BOOST_CHECK_MESSAGE(!sched[ 7].rft_config().segment("P"), R"(Should NOT Output SEGMENT Data for "P" at Step 7)");
BOOST_CHECK_MESSAGE(!sched[ 8].rft_config().segment("P"), R"(Should NOT Output SEGMENT Data for "P" at Step 8)");
BOOST_CHECK_MESSAGE(!sched[ 9].rft_config().segment("P"), R"(Should NOT Output SEGMENT Data for "P" at Step 9)");
BOOST_CHECK_MESSAGE( sched[10].rft_config().segment("P"), R"(Should Output SEGMENT Data for "P" at Step 10)");
BOOST_CHECK_MESSAGE(!sched[11].rft_config().segment("P"), R"(Should NOT Output SEGMENT Data for "P" at Step 11)");
BOOST_CHECK_MESSAGE(!sched[12].rft_config().segment("P"), R"(Should NOT Output SEGMENT Data for "P" at Step 12)");
BOOST_CHECK_MESSAGE(!sched[13].rft_config().segment("P"), R"(Should NOT Output SEGMENT Data for "P" at Step 13)");
BOOST_CHECK_MESSAGE(!sched[14].rft_config().segment("P"), R"(Should NOT Output SEGMENT Data for "P" at Step 14)");
BOOST_CHECK_MESSAGE(!sched[15].rft_config().segment("P"), R"(Should NOT Output SEGMENT Data for "P" at Step 15)");
BOOST_CHECK_MESSAGE(!sched[16].rft_config().segment("P"), R"(Should NOT Output SEGMENT Data for "P" at Step 16)");
BOOST_CHECK_MESSAGE(!sched[17].rft_config().segment("P"), R"(Should NOT Output SEGMENT Data for "P" at Step 17)");
BOOST_CHECK_MESSAGE( sched[18].rft_config().segment("P"), R"(Should Output SEGMENT Data for "P" at Step 18)");
BOOST_CHECK_MESSAGE( sched[19].rft_config().segment("P"), R"(Should Output SEGMENT Data for "P" at Step 19)");
BOOST_CHECK_MESSAGE( sched[20].rft_config().segment("P"), R"(Should Output SEGMENT Data for "P" at Step 20)");
BOOST_CHECK_MESSAGE(!sched[ 0].rft_config().rft("I"), R"(Should NOT Output RFT Data for "I" at Step 0)");
BOOST_CHECK_MESSAGE(!sched[ 1].rft_config().rft("I"), R"(Should NOT Output RFT Data for "I" at Step 1)");
BOOST_CHECK_MESSAGE(!sched[ 2].rft_config().rft("I"), R"(Should NOT Output RFT Data for "I" at Step 2)");
@ -690,6 +729,28 @@ BOOST_AUTO_TEST_CASE(Deferred_Open)
BOOST_CHECK_MESSAGE(!sched[19].rft_config().plt("I"), R"(Should NOT Output PLT Data for "I" at Step 19)");
BOOST_CHECK_MESSAGE(!sched[20].rft_config().plt("I"), R"(Should NOT Output PLT Data for "I" at Step 20)");
BOOST_CHECK_MESSAGE(!sched[ 0].rft_config().segment("I"), R"(Should NOT Output SEGMENT Data for "I" at Step 0)");
BOOST_CHECK_MESSAGE(!sched[ 1].rft_config().segment("I"), R"(Should NOT Output SEGMENT Data for "I" at Step 1)");
BOOST_CHECK_MESSAGE(!sched[ 2].rft_config().segment("I"), R"(Should NOT Output SEGMENT Data for "I" at Step 2)");
BOOST_CHECK_MESSAGE(!sched[ 3].rft_config().segment("I"), R"(Should NOT Output SEGMENT Data for "I" at Step 3)");
BOOST_CHECK_MESSAGE(!sched[ 4].rft_config().segment("I"), R"(Should NOT Output SEGMENT Data for "I" at Step 4)");
BOOST_CHECK_MESSAGE(!sched[ 5].rft_config().segment("I"), R"(Should NOT Output SEGMENT Data for "I" at Step 5)");
BOOST_CHECK_MESSAGE(!sched[ 6].rft_config().segment("I"), R"(Should NOT Output SEGMENT Data for "I" at Step 6)");
BOOST_CHECK_MESSAGE(!sched[ 7].rft_config().segment("I"), R"(Should NOT Output SEGMENT Data for "I" at Step 7)");
BOOST_CHECK_MESSAGE(!sched[ 8].rft_config().segment("I"), R"(Should NOT Output SEGMENT Data for "I" at Step 8)");
BOOST_CHECK_MESSAGE(!sched[ 9].rft_config().segment("I"), R"(Should NOT Output SEGMENT Data for "I" at Step 9)");
BOOST_CHECK_MESSAGE(!sched[10].rft_config().segment("I"), R"(Should NOT Output SEGMENT Data for "I" at Step 10)");
BOOST_CHECK_MESSAGE(!sched[11].rft_config().segment("I"), R"(Should NOT Output SEGMENT Data for "I" at Step 11)");
BOOST_CHECK_MESSAGE(!sched[12].rft_config().segment("I"), R"(Should NOT Output SEGMENT Data for "I" at Step 12)");
BOOST_CHECK_MESSAGE(!sched[13].rft_config().segment("I"), R"(Should NOT Output SEGMENT Data for "I" at Step 13)");
BOOST_CHECK_MESSAGE(!sched[14].rft_config().segment("I"), R"(Should NOT Output SEGMENT Data for "I" at Step 14)");
BOOST_CHECK_MESSAGE(!sched[15].rft_config().segment("I"), R"(Should NOT Output SEGMENT Data for "I" at Step 15)");
BOOST_CHECK_MESSAGE(!sched[16].rft_config().segment("I"), R"(Should NOT Output SEGMENT Data for "I" at Step 16)");
BOOST_CHECK_MESSAGE(!sched[17].rft_config().segment("I"), R"(Should NOT Output SEGMENT Data for "I" at Step 17)");
BOOST_CHECK_MESSAGE( sched[18].rft_config().segment("I"), R"(Should Output SEGMENT Data for "I" at Step 18)");
BOOST_CHECK_MESSAGE( sched[19].rft_config().segment("I"), R"(Should Output SEGMENT Data for "I" at Step 19)");
BOOST_CHECK_MESSAGE( sched[20].rft_config().segment("I"), R"(Should Output SEGMENT Data for "I" at Step 20)");
BOOST_CHECK_MESSAGE(!sched[ 0].rft_config().rft("P2"), R"(Should NOT Output RFT Data for "P2" at Step 0)");
BOOST_CHECK_MESSAGE(!sched[ 1].rft_config().rft("P2"), R"(Should NOT Output RFT Data for "P2" at Step 1)");
BOOST_CHECK_MESSAGE(!sched[ 2].rft_config().rft("P2"), R"(Should NOT Output RFT Data for "P2" at Step 2)");
@ -737,6 +798,28 @@ BOOST_AUTO_TEST_CASE(Deferred_Open)
BOOST_CHECK_MESSAGE(!sched[19].rft_config().plt("P2"), R"(Should NOT Output PLT Data for "P2" at Step 19)");
BOOST_CHECK_MESSAGE(!sched[20].rft_config().plt("P2"), R"(Should NOT Output PLT Data for "P2" at Step 20)");
BOOST_CHECK_MESSAGE(!sched[ 0].rft_config().segment("P2"), R"(Should NOT Output SEGMENT Data for "P2" at Step 0)");
BOOST_CHECK_MESSAGE(!sched[ 1].rft_config().segment("P2"), R"(Should NOT Output SEGMENT Data for "P2" at Step 1)");
BOOST_CHECK_MESSAGE(!sched[ 2].rft_config().segment("P2"), R"(Should NOT Output SEGMENT Data for "P2" at Step 2)");
BOOST_CHECK_MESSAGE(!sched[ 3].rft_config().segment("P2"), R"(Should NOT Output SEGMENT Data for "P2" at Step 3)");
BOOST_CHECK_MESSAGE(!sched[ 4].rft_config().segment("P2"), R"(Should NOT Output SEGMENT Data for "P2" at Step 4)");
BOOST_CHECK_MESSAGE(!sched[ 5].rft_config().segment("P2"), R"(Should NOT Output SEGMENT Data for "P2" at Step 5)");
BOOST_CHECK_MESSAGE(!sched[ 6].rft_config().segment("P2"), R"(Should NOT Output SEGMENT Data for "P2" at Step 6)");
BOOST_CHECK_MESSAGE(!sched[ 7].rft_config().segment("P2"), R"(Should NOT Output SEGMENT Data for "P2" at Step 7)");
BOOST_CHECK_MESSAGE(!sched[ 8].rft_config().segment("P2"), R"(Should NOT Output SEGMENT Data for "P2" at Step 8)");
BOOST_CHECK_MESSAGE(!sched[ 9].rft_config().segment("P2"), R"(Should NOT Output SEGMENT Data for "P2" at Step 9)");
BOOST_CHECK_MESSAGE(!sched[10].rft_config().segment("P2"), R"(Should NOT Output SEGMENT Data for "P2" at Step 10)");
BOOST_CHECK_MESSAGE(!sched[11].rft_config().segment("P2"), R"(Should NOT Output SEGMENT Data for "P2" at Step 11)");
BOOST_CHECK_MESSAGE(!sched[12].rft_config().segment("P2"), R"(Should NOT Output SEGMENT Data for "P2" at Step 12)");
BOOST_CHECK_MESSAGE(!sched[13].rft_config().segment("P2"), R"(Should NOT Output SEGMENT Data for "P2" at Step 13)");
BOOST_CHECK_MESSAGE(!sched[14].rft_config().segment("P2"), R"(Should NOT Output SEGMENT Data for "P2" at Step 14)");
BOOST_CHECK_MESSAGE(!sched[15].rft_config().segment("P2"), R"(Should NOT Output SEGMENT Data for "P2" at Step 15)");
BOOST_CHECK_MESSAGE(!sched[16].rft_config().segment("P2"), R"(Should NOT Output SEGMENT Data for "P2" at Step 16)");
BOOST_CHECK_MESSAGE(!sched[17].rft_config().segment("P2"), R"(Should NOT Output SEGMENT Data for "P2" at Step 17)");
BOOST_CHECK_MESSAGE( sched[18].rft_config().segment("P2"), R"(Should Output SEGMENT Data for "P2" at Step 18)");
BOOST_CHECK_MESSAGE( sched[19].rft_config().segment("P2"), R"(Should Output SEGMENT Data for "P2" at Step 19)");
BOOST_CHECK_MESSAGE( sched[20].rft_config().segment("P2"), R"(Should Output SEGMENT Data for "P2" at Step 20)");
BOOST_CHECK_MESSAGE(!sched[ 0].rft_config().active(), R"(RFT Config must be Inactive at Step 0)");
BOOST_CHECK_MESSAGE(!sched[ 1].rft_config().active(), R"(RFT Config must be Inactive at Step 1)");
BOOST_CHECK_MESSAGE(!sched[ 2].rft_config().active(), R"(RFT Config must be Inactive at Step 2)");