Merge pull request #2201 from joakim-hove/sched-wtest-config

Handle well test configuration with ScheduleState
This commit is contained in:
Joakim Hove
2021-01-12 17:50:27 +01:00
committed by GitHub
6 changed files with 38 additions and 32 deletions

View File

@@ -236,7 +236,6 @@ namespace Opm
Well::ProducerCMode getGlobalWhistctlMmode(std::size_t timestep) const;
const UDQActive& udqActive(std::size_t timeStep) const;
const WellTestConfig& wtestConfig(std::size_t timestep) const;
const GConSale& gConSale(std::size_t timestep) const;
const GConSump& gConSump(std::size_t timestep) const;
const WListManager& getWListManager(std::size_t timeStep) const;
@@ -318,7 +317,6 @@ namespace Opm
auto splitvfpinj = splitDynMap<Map2>(vfpinj_tables);
serializer.vector(splitvfpinj.first);
serializer(splitvfpinj.second);
wtest_config.serializeOp(serializer);
wlist_manager.serializeOp(serializer);
udq_config.serializeOp(serializer);
udq_active.serializeOp(serializer);
@@ -353,7 +351,6 @@ namespace Opm
VFPProdMap vfpprod_tables;
VFPInjMap vfpinj_tables;
MessageLimits m_deck_message_limits;
DynamicState<std::shared_ptr<WellTestConfig>> wtest_config;
DynamicState<std::shared_ptr<WListManager>> wlist_manager;
DynamicState<std::shared_ptr<UDQConfig>> udq_config;
DynamicState<std::shared_ptr<UDQActive>> udq_active;

View File

@@ -42,6 +42,7 @@ namespace Opm {
is handled by the Schedule instance owning the ScheduleState instance.
*/
class WellTestConfig;
class ScheduleState {
public:
@@ -92,6 +93,9 @@ namespace Opm {
Well::ProducerCMode whistctl() const;
void whistctl(Well::ProducerCMode whistctl);
const WellTestConfig& wtest_config() const;
void wtest_config(WellTestConfig wtest_config);
template<class Serializer>
void serializeOp(Serializer& serializer) {
serializer(m_start_time);
@@ -105,6 +109,7 @@ namespace Opm {
serializer.vector(m_geo_keywords);
m_message_limits.serializeOp(serializer);
serializer(m_whistctl_mode);
serializer(m_wtest_config);
}
private:
@@ -120,6 +125,7 @@ namespace Opm {
std::vector<DeckKeyword> m_geo_keywords;
MessageLimits m_message_limits;
Well::ProducerCMode m_whistctl_mode = Well::ProducerCMode::CMODE_UNDEFINED;
std::shared_ptr<WellTestConfig> m_wtest_config;
};
}

View File

@@ -1772,8 +1772,7 @@ namespace {
}
void Schedule::handleWTEST(const HandlerContext& handlerContext, const ParseContext& parseContext, ErrorGuard& errors) {
const auto& current = *this->wtest_config.get(handlerContext.currentStep);
std::shared_ptr<WellTestConfig> new_config(new WellTestConfig(current));
auto new_config = this->snapshots.back().wtest_config();
for (const auto& record : handlerContext.keyword) {
const std::string& wellNamePattern = record.getItem("WELL").getTrimmedString(0);
const auto well_names = wellNames(wellNamePattern, handlerContext.currentStep);
@@ -1787,12 +1786,12 @@ namespace {
for (const auto& well_name : well_names) {
if (reasons.empty())
new_config->drop_well(well_name);
new_config.drop_well(well_name);
else
new_config->add_well(well_name, reasons, test_interval, num_test, startup_time, handlerContext.currentStep);
new_config.add_well(well_name, reasons, test_interval, num_test, startup_time, handlerContext.currentStep);
}
}
this->wtest_config.update(handlerContext.currentStep, new_config);
this->snapshots.back().wtest_config( std::move(new_config) );
}
void Schedule::handleWTRACER(const HandlerContext& handlerContext, const ParseContext& parseContext, ErrorGuard& errors) {

View File

@@ -114,7 +114,6 @@ namespace {
m_timeMap( deck , restart_info( rst )),
m_runspec( runspec ),
m_deck_message_limits( MessageLimits(deck) ),
wtest_config(this->m_timeMap, std::make_shared<WellTestConfig>() ),
wlist_manager( this->m_timeMap, std::make_shared<WListManager>()),
udq_config(this->m_timeMap, std::make_shared<UDQConfig>(deck)),
udq_active(this->m_timeMap, std::make_shared<UDQActive>()),
@@ -265,7 +264,6 @@ namespace {
result.m_runspec = Runspec::serializeObject();
result.vfpprod_tables = {{1, {{std::make_shared<VFPProdTable>(VFPProdTable::serializeObject())}, 1}}};
result.vfpinj_tables = {{2, {{std::make_shared<VFPInjTable>(VFPInjTable::serializeObject())}, 1}}};
result.wtest_config = {{std::make_shared<WellTestConfig>(WellTestConfig::serializeObject())}, 1};
result.wlist_manager = {{std::make_shared<WListManager>(WListManager::serializeObject())}, 1};
result.udq_config = {{std::make_shared<UDQConfig>(UDQConfig::serializeObject())}, 1};
result.m_network = {{std::make_shared<Network::ExtNetwork>(Network::ExtNetwork::serializeObject())}, 1};
@@ -1461,11 +1459,6 @@ void Schedule::iterateScheduleSection(std::optional<std::size_t> load_offset,
this->udq_active.update(timeStep, udq);
}
const WellTestConfig& Schedule::wtestConfig(std::size_t timeStep) const {
const auto& ptr = this->wtest_config.get(timeStep);
return *ptr;
}
const GConSale& Schedule::gConSale(std::size_t timeStep) const {
const auto& ptr = this->gconsale.get(timeStep);
return *ptr;
@@ -1668,7 +1661,6 @@ void Schedule::iterateScheduleSection(std::optional<std::size_t> load_offset,
compareMap(this->vfpinj_tables, data.vfpinj_tables) &&
compareDynState(this->m_network, data.m_network) &&
compareDynState(this->m_glo, data.m_glo) &&
compareDynState(this->wtest_config, data.wtest_config) &&
compareDynState(this->wlist_manager, data.wlist_manager) &&
compareDynState(this->udq_config, data.udq_config) &&
compareDynState(this->udq_active, data.udq_active) &&
@@ -1679,7 +1671,8 @@ void Schedule::iterateScheduleSection(std::optional<std::size_t> load_offset,
compareDynState(this->rpt_config, data.rpt_config) &&
rft_config == data.rft_config &&
this->restart_config == data.restart_config &&
this->unit_system == data.unit_system;
this->unit_system == data.unit_system &&
this->snapshots == data.snapshots;
}
@@ -2091,6 +2084,7 @@ void Schedule::create_first(const std::chrono::system_clock::time_point& start_t
sched_state.nupcol( this->m_runspec.nupcol() );
sched_state.oilvap( OilVaporizationProperties( this->m_runspec.tabdims().getNumPVTTables() ));
sched_state.message_limits( this->m_deck_message_limits );
sched_state.wtest_config( WellTestConfig() );
this->addGroup("FIELD", 0);
}

View File

@@ -18,6 +18,7 @@
*/
#include <opm/parser/eclipse/EclipseState/Schedule/ScheduleState.hpp>
#include <opm/parser/eclipse/EclipseState/Schedule/Well/WellTestConfig.hpp>
namespace Opm {
@@ -138,17 +139,17 @@ void ScheduleState::whistctl(Well::ProducerCMode whistctl) {
}
bool ScheduleState::operator==(const ScheduleState& other) const {
return
this->m_start_time == other.m_start_time &&
this->m_oilvap == other.m_oilvap &&
this->m_tuning == other.m_tuning &&
this->m_end_time == other.m_end_time &&
this->m_events == other.m_events &&
this->m_wellgroup_events == other.m_wellgroup_events &&
this->m_geo_keywords == other.m_geo_keywords &&
this->m_message_limits == other.m_message_limits &&
this->m_whistctl_mode == other.m_whistctl_mode &&
this->m_nupcol == other.m_nupcol;
return this->m_start_time == other.m_start_time &&
this->m_oilvap == other.m_oilvap &&
this->m_tuning == other.m_tuning &&
this->m_end_time == other.m_end_time &&
this->m_events == other.m_events &&
this->m_wellgroup_events == other.m_wellgroup_events &&
this->m_geo_keywords == other.m_geo_keywords &&
this->m_message_limits == other.m_message_limits &&
this->m_whistctl_mode == other.m_whistctl_mode &&
*this->m_wtest_config == *other.m_wtest_config &&
this->m_nupcol == other.m_nupcol;
}
ScheduleState ScheduleState::serializeObject() {
@@ -160,6 +161,7 @@ ScheduleState ScheduleState::serializeObject() {
ts.oilvap( Opm::OilVaporizationProperties::serializeObject() );
ts.m_message_limits = MessageLimits::serializeObject();
ts.m_whistctl_mode = Well::ProducerCMode::THP;
ts.m_wtest_config = std::make_shared<WellTestConfig>( WellTestConfig::serializeObject() );
return ts;
}
@@ -199,4 +201,12 @@ const WellGroupEvents& ScheduleState::wellgroup_events() const {
return this->m_wellgroup_events;
}
const WellTestConfig& ScheduleState::wtest_config() const {
return *this->m_wtest_config;
}
void ScheduleState::wtest_config(WellTestConfig wtest_config) {
this->m_wtest_config = std::make_shared<WellTestConfig>( std::move(wtest_config) );
}
}

View File

@@ -2894,12 +2894,12 @@ WCONINJH
BOOST_CHECK_CLOSE( 0.0 * 1e5, pro1.THPH, 1e-5 );
{
const auto& wtest_config = schedule.wtestConfig(0);
const auto& wtest_config = schedule[0].wtest_config();
BOOST_CHECK_EQUAL(wtest_config.size(), 0U);
}
{
const auto& wtest_config = schedule.wtestConfig(1);
const auto& wtest_config = schedule[1].wtest_config();
BOOST_CHECK_EQUAL(wtest_config.size(), 0U);
}
}
@@ -3197,12 +3197,12 @@ TSTEP
BOOST_AUTO_TEST_CASE(WTEST_CONFIG) {
const auto& schedule = make_schedule(createDeckWTEST());
const auto& wtest_config1 = schedule.wtestConfig(0);
const auto& wtest_config1 = schedule[0].wtest_config();
BOOST_CHECK_EQUAL(wtest_config1.size(), 2U);
BOOST_CHECK(wtest_config1.has("ALLOW"));
BOOST_CHECK(!wtest_config1.has("BAN"));
const auto& wtest_config2 = schedule.wtestConfig(1);
const auto& wtest_config2 = schedule[1].wtest_config();
BOOST_CHECK_EQUAL(wtest_config2.size(), 3U);
BOOST_CHECK(!wtest_config2.has("ALLOW"));
BOOST_CHECK(wtest_config2.has("BAN"));