From 3fdf28508fc4209786a2a1992cea894b78e2c02d Mon Sep 17 00:00:00 2001 From: Arne Morten Kvarving Date: Mon, 24 Oct 2022 09:36:05 +0200 Subject: [PATCH] move loadRestartData into BlackoilWellModelRestart --- .../wells/BlackoilWellModelGeneric.cpp | 49 ++----------------- .../wells/BlackoilWellModelGeneric.hpp | 11 ++--- .../wells/BlackoilWellModelRestart.cpp | 41 ++++++++++++++++ .../wells/BlackoilWellModelRestart.hpp | 36 +++++++++----- 4 files changed, 73 insertions(+), 64 deletions(-) diff --git a/opm/simulators/wells/BlackoilWellModelGeneric.cpp b/opm/simulators/wells/BlackoilWellModelGeneric.cpp index 991a233f9..552aa9923 100644 --- a/opm/simulators/wells/BlackoilWellModelGeneric.cpp +++ b/opm/simulators/wells/BlackoilWellModelGeneric.cpp @@ -385,48 +385,6 @@ getWellEcl(const std::string& well_name) const return *well_ecl; } -void -BlackoilWellModelGeneric:: -loadRestartData(const data::Wells& rst_wells, - const data::GroupAndNetworkValues& grpNwrkValues, - const PhaseUsage& phases, - const bool handle_ms_well, - WellState& well_state) -{ - using rt = data::Rates::opt; - const auto np = phases.num_phases; - - std::vector phs(np); - if (phases.phase_used[BlackoilPhases::Aqua]) { - phs.at(phases.phase_pos[BlackoilPhases::Aqua]) = rt::wat; - } - - if (phases.phase_used[BlackoilPhases::Liquid]) { - phs.at( phases.phase_pos[BlackoilPhases::Liquid] ) = rt::oil; - } - - if (phases.phase_used[BlackoilPhases::Vapour]) { - phs.at( phases.phase_pos[BlackoilPhases::Vapour] ) = rt::gas; - } - - for (auto well_index = 0*well_state.size(); - well_index < well_state.size(); - ++well_index) - { - const auto& well_name = well_state.name(well_index); - - BlackoilWellModelRestart(*this). - loadRestartWellData(well_name, handle_ms_well, phs, - rst_wells.at(well_name), - this->well_perf_data_[well_index], - well_state.well(well_index)); - } - - for (const auto& [group, value] : grpNwrkValues.groupData) { - BlackoilWellModelRestart(*this).loadRestartGroupData(group, value, this->groupState()); - } -} - void BlackoilWellModelGeneric:: initFromRestartFile(const RestartValue& restartValues, @@ -456,8 +414,11 @@ initFromRestartFile(const RestartValue& restartValues, this->schedule(), handle_ms_well, numCells, this->well_perf_data_, this->summaryState_); - loadRestartData(restartValues.wells, restartValues.grp_nwrk, - this->phase_usage_, handle_ms_well, this->wellState()); + BlackoilWellModelRestart(*this).loadRestartData(restartValues.wells, + restartValues.grp_nwrk, + handle_ms_well, + this->wellState(), + this->groupState()); if (config.has_model()) { BlackoilWellModelRestart(*this).loadRestartGuideRates(report_step, diff --git a/opm/simulators/wells/BlackoilWellModelGeneric.hpp b/opm/simulators/wells/BlackoilWellModelGeneric.hpp index 933f410dd..79dea87f6 100644 --- a/opm/simulators/wells/BlackoilWellModelGeneric.hpp +++ b/opm/simulators/wells/BlackoilWellModelGeneric.hpp @@ -130,13 +130,6 @@ public: const std::unordered_set& wells, const SummaryState& st); - - void loadRestartData(const data::Wells& rst_wells, - const data::GroupAndNetworkValues& grpNwrkValues, - const PhaseUsage& phases, - const bool handle_ms_well, - WellState& well_state); - void initFromRestartFile(const RestartValue& restartValues, WellTestState wtestState, const size_t numCells, @@ -163,6 +156,10 @@ public: bool forceShutWellByName(const std::string& wellname, const double simulation_time); + + const std::vector& perfData(const int well_idx) const + { return well_perf_data_[well_idx]; } + protected: /* diff --git a/opm/simulators/wells/BlackoilWellModelRestart.cpp b/opm/simulators/wells/BlackoilWellModelRestart.cpp index 357d30dcb..03b84f53b 100644 --- a/opm/simulators/wells/BlackoilWellModelRestart.cpp +++ b/opm/simulators/wells/BlackoilWellModelRestart.cpp @@ -217,4 +217,45 @@ loadRestartGuideRates(const int report_step, } } +void BlackoilWellModelRestart:: +loadRestartData(const data::Wells& rst_wells, + const data::GroupAndNetworkValues& grpNwrkValues, + const bool handle_ms_well, + WellState& well_state, + GroupState& grpState) const +{ + using rt = data::Rates::opt; + const auto& phases = wellModel_.phaseUsage(); + const auto np = phases.num_phases; + + std::vector phs(np); + if (phases.phase_used[BlackoilPhases::Aqua]) { + phs.at(phases.phase_pos[BlackoilPhases::Aqua]) = rt::wat; + } + + if (phases.phase_used[BlackoilPhases::Liquid]) { + phs.at( phases.phase_pos[BlackoilPhases::Liquid] ) = rt::oil; + } + + if (phases.phase_used[BlackoilPhases::Vapour]) { + phs.at( phases.phase_pos[BlackoilPhases::Vapour] ) = rt::gas; + } + + for (auto well_index = 0*well_state.size(); + well_index < well_state.size(); + ++well_index) + { + const auto& well_name = well_state.name(well_index); + + this->loadRestartWellData(well_name, handle_ms_well, phs, + rst_wells.at(well_name), + wellModel_.perfData(well_index), + well_state.well(well_index)); + } + + for (const auto& [group, value] : grpNwrkValues.groupData) { + this->loadRestartGroupData(group, value, grpState); + } +} + } // namespace Opm diff --git a/opm/simulators/wells/BlackoilWellModelRestart.hpp b/opm/simulators/wells/BlackoilWellModelRestart.hpp index 444c5b344..09e6e4c41 100644 --- a/opm/simulators/wells/BlackoilWellModelRestart.hpp +++ b/opm/simulators/wells/BlackoilWellModelRestart.hpp @@ -33,12 +33,15 @@ namespace Opm { class BlackoilWellModelGeneric; namespace data { class GroupData; +class GroupAndNetworkValues; } class GroupState; class GuideRate; class GuideRateConfig; struct PerforationData; +class PhaseUsage; class SingleWellState; +class WellState; /// Class for restarting the blackoil well model. class BlackoilWellModelRestart @@ -49,19 +52,6 @@ public: : wellModel_(wellModel) {} - //! \brief Loads per-well data from restart structures. - void loadRestartWellData(const std::string& well_name, - const bool handle_ms_well, - const std::vector& phs, - const data::Well& rst_well, - const std::vector& old_perf_data, - SingleWellState& ws) const; - - //! \brief Loads per-group data from restart structures. - void loadRestartGroupData(const std::string& group, - const data::GroupData& value, - GroupState& grpState) const; - //! \brief Loads guide rates from restart structures. void loadRestartGuideRates(const int report_step, const GuideRateModel::Target target, @@ -74,6 +64,13 @@ public: const std::map& rst_groups, GuideRate& guide_rate) const; + //! \brief Loads well data from restart structures. + void loadRestartData(const data::Wells& rst_wells, + const data::GroupAndNetworkValues& grpNwrkValues, + const bool handle_ms_well, + WellState& well_state, + GroupState& grpState) const; + private: //! \brief Loads per-connection data from restart structures. void loadRestartConnectionData(const std::vector& phs, @@ -87,6 +84,19 @@ private: const data::Well& rst_well, SingleWellState& ws) const; + //! \brief Loads per-well data from restart structures. + void loadRestartWellData(const std::string& well_name, + const bool handle_ms_well, + const std::vector& phs, + const data::Well& rst_well, + const std::vector& old_perf_data, + SingleWellState& ws) const; + + //! \brief Loads per-group data from restart structures. + void loadRestartGroupData(const std::string& group, + const data::GroupData& value, + GroupState& grpState) const; + const BlackoilWellModelGeneric& wellModel_; //!< Reference to well model };