Merge pull request #3299 from akva2/gasliftstage2_break_circular

GasLiftStage2: drop circular dependency for BlackoilWellModel
This commit is contained in:
Bård Skaflestad 2021-05-27 18:31:44 +02:00 committed by GitHub
commit 66443c63fb
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 14 additions and 25 deletions

View File

@ -108,9 +108,8 @@ namespace Opm {
typedef typename BaseAuxiliaryModule<TypeTag>::NeighborSet NeighborSet; typedef typename BaseAuxiliaryModule<TypeTag>::NeighborSet NeighborSet;
using GasLiftSingleWell = ::Opm::GasLiftSingleWell<TypeTag>; using GasLiftSingleWell = ::Opm::GasLiftSingleWell<TypeTag>;
using GasLiftStage2 = ::Opm::GasLiftStage2<TypeTag>; using GasLiftStage2 = ::Opm::GasLiftStage2<TypeTag>;
using GLiftWellState = GasLiftWellState;
using GLiftWellStateMap = using GLiftWellStateMap =
std::map<std::string,std::unique_ptr<GLiftWellState>>; std::map<std::string,std::unique_ptr<GasLiftWellState>>;
using GLiftOptWells = using GLiftOptWells =
std::map<std::string,std::unique_ptr<GasLiftSingleWell>>; std::map<std::string,std::unique_ptr<GasLiftSingleWell>>;
using GLiftProdWells = using GLiftProdWells =

View File

@ -1108,7 +1108,7 @@ namespace Opm {
GLiftWellStateMap &glift_well_state_map) GLiftWellStateMap &glift_well_state_map)
{ {
GasLiftStage2 glift {*this, ebosSimulator_, deferred_logger, this->wellState(), GasLiftStage2 glift {this->phaseUsage(), ebosSimulator_, deferred_logger, this->wellState(),
prod_wells, glift_wells, glift_well_state_map}; prod_wells, glift_wells, glift_well_state_map};
glift.runOptimize(); glift.runOptimize();
} }

View File

@ -34,12 +34,6 @@
#include <opm/simulators/wells/GasLiftWellState.hpp> #include <opm/simulators/wells/GasLiftWellState.hpp>
#include <opm/simulators/utils/DeferredLogger.hpp> #include <opm/simulators/utils/DeferredLogger.hpp>
#include <opm/simulators/wells/WellState.hpp> #include <opm/simulators/wells/WellState.hpp>
// NOTE: BlackoilWellModel.hpp includes ourself (GasLiftStage2.hpp), so we need
// to forward declare BlackoilWellModel for it to be defined in this file.
namespace Opm {
template<typename TypeTag> class BlackoilWellModel;
}
#include <opm/simulators/wells/BlackoilWellModel.hpp>
#include <cassert> #include <cassert>
#include <functional> #include <functional>
@ -58,12 +52,10 @@ namespace Opm
template<class TypeTag> template<class TypeTag>
class GasLiftStage2 { class GasLiftStage2 {
using Simulator = GetPropType<TypeTag, Properties::Simulator>; using Simulator = GetPropType<TypeTag, Properties::Simulator>;
using BlackoilWellModel = ::Opm::BlackoilWellModel<TypeTag>;
using GasLiftSingleWell = ::Opm::GasLiftSingleWell<TypeTag>; using GasLiftSingleWell = ::Opm::GasLiftSingleWell<TypeTag>;
using GLiftWellState = GasLiftWellState; using GLiftOptWells = std::map<std::string,std::unique_ptr<GasLiftSingleWell>>;
using GLiftOptWells = typename BlackoilWellModel::GLiftOptWells; using GLiftProdWells = std::map<std::string,const WellInterface<TypeTag> *>;
using GLiftProdWells = typename BlackoilWellModel::GLiftProdWells; using GLiftWellStateMap = std::map<std::string,std::unique_ptr<GasLiftWellState>>;
using GLiftWellStateMap = typename BlackoilWellModel::GLiftWellStateMap;
using GradPair = std::pair<std::string, double>; using GradPair = std::pair<std::string, double>;
using GradPairItr = std::vector<GradPair>::iterator; using GradPairItr = std::vector<GradPair>::iterator;
using GradInfo = typename GasLiftSingleWell::GradInfo; using GradInfo = typename GasLiftSingleWell::GradInfo;
@ -79,7 +71,7 @@ namespace Opm
static const int Gas = BlackoilPhases::Vapour; static const int Gas = BlackoilPhases::Vapour;
public: public:
GasLiftStage2( GasLiftStage2(
const BlackoilWellModel &well_model, const PhaseUsage& phase_usage,
const Simulator &ebos_simulator, const Simulator &ebos_simulator,
DeferredLogger &deferred_logger, DeferredLogger &deferred_logger,
WellState &well_state, WellState &well_state,
@ -93,7 +85,7 @@ namespace Opm
GradMap &grad_map, const std::string well_name, bool add); GradMap &grad_map, const std::string well_name, bool add);
std::optional<GradInfo> calcIncOrDecGrad_( std::optional<GradInfo> calcIncOrDecGrad_(
const std::string name, const GasLiftSingleWell &gs_well, bool increase); const std::string name, const GasLiftSingleWell &gs_well, bool increase);
bool checkRateAlreadyLimited_(GLiftWellState &state, bool increase); bool checkRateAlreadyLimited_(GasLiftWellState &state, bool increase);
GradInfo deleteDecGradItem_(const std::string &name); GradInfo deleteDecGradItem_(const std::string &name);
GradInfo deleteIncGradItem_(const std::string &name); GradInfo deleteIncGradItem_(const std::string &name);
GradInfo deleteGrad_(const std::string &name, bool increase); GradInfo deleteGrad_(const std::string &name, bool increase);
@ -140,7 +132,6 @@ namespace Opm
DeferredLogger &deferred_logger_; DeferredLogger &deferred_logger_;
const Simulator &ebos_simulator_; const Simulator &ebos_simulator_;
const BlackoilWellModel &well_model_;
WellState &well_state_; WellState &well_state_;
GLiftProdWells &prod_wells_; GLiftProdWells &prod_wells_;
GLiftOptWells &stage1_wells_; GLiftOptWells &stage1_wells_;

View File

@ -36,7 +36,7 @@ namespace Opm {
template<typename TypeTag> template<typename TypeTag>
GasLiftStage2<TypeTag>:: GasLiftStage2<TypeTag>::
GasLiftStage2( GasLiftStage2(
const BlackoilWellModel &well_model, const PhaseUsage& phase_usage,
const Simulator &ebos_simulator, const Simulator &ebos_simulator,
DeferredLogger &deferred_logger, DeferredLogger &deferred_logger,
WellState &well_state, WellState &well_state,
@ -46,7 +46,6 @@ GasLiftStage2(
) : ) :
deferred_logger_{deferred_logger}, deferred_logger_{deferred_logger},
ebos_simulator_{ebos_simulator}, ebos_simulator_{ebos_simulator},
well_model_{well_model},
well_state_{well_state}, well_state_{well_state},
prod_wells_{prod_wells}, prod_wells_{prod_wells},
stage1_wells_{glift_wells}, stage1_wells_{glift_wells},
@ -54,7 +53,7 @@ GasLiftStage2(
report_step_idx_{ebos_simulator_.episodeIndex()}, report_step_idx_{ebos_simulator_.episodeIndex()},
summary_state_{ebos_simulator_.vanguard().summaryState()}, summary_state_{ebos_simulator_.vanguard().summaryState()},
schedule_{ebos_simulator.vanguard().schedule()}, schedule_{ebos_simulator.vanguard().schedule()},
phase_usage_{well_model_.phaseUsage()}, phase_usage_{phase_usage},
glo_{schedule_.glo(report_step_idx_)}, glo_{schedule_.glo(report_step_idx_)},
comm_{ebos_simulator.vanguard().grid().comm()}, comm_{ebos_simulator.vanguard().grid().comm()},
debug_{false} debug_{false}
@ -108,7 +107,7 @@ addOrRemoveALQincrement_(GradMap &grad_map, const std::string well_name, bool ad
if (it == this->well_state_map_.end()) if (it == this->well_state_map_.end())
return; return;
GLiftWellState &state = *(it->second.get()); GasLiftWellState &state = *(it->second.get());
const GradInfo &gi = grad_map.at(well_name); const GradInfo &gi = grad_map.at(well_name);
if (this->debug_) { if (this->debug_) {
auto new_alq = gi.alq; auto new_alq = gi.alq;
@ -135,7 +134,7 @@ calcIncOrDecGrad_(
if(this->well_state_map_.count(well_name) == 0) if(this->well_state_map_.count(well_name) == 0)
return std::nullopt; return std::nullopt;
GLiftWellState &state = *(this->well_state_map_.at(well_name).get()); GasLiftWellState &state = *(this->well_state_map_.at(well_name).get());
if (checkRateAlreadyLimited_(state, increase)) { if (checkRateAlreadyLimited_(state, increase)) {
/* /*
const std::string msg = fmt::format( const std::string msg = fmt::format(
@ -167,7 +166,7 @@ calcIncOrDecGrad_(
template<typename TypeTag> template<typename TypeTag>
bool bool
GasLiftStage2<TypeTag>:: GasLiftStage2<TypeTag>::
checkRateAlreadyLimited_(GLiftWellState &state, bool increase) checkRateAlreadyLimited_(GasLiftWellState &state, bool increase)
{ {
auto current_increase = state.increase(); auto current_increase = state.increase();
bool do_check = false; bool do_check = false;
@ -354,7 +353,7 @@ getCurrentWellRates_(const std::string &well_name, const std::string &group_name
GasLiftSingleWell &gs_well = *(this->stage1_wells_.at(well_name).get()); GasLiftSingleWell &gs_well = *(this->stage1_wells_.at(well_name).get());
const WellInterface<TypeTag> &well = gs_well.getStdWell(); const WellInterface<TypeTag> &well = gs_well.getStdWell();
well_ptr = &well; well_ptr = &well;
GLiftWellState &state = *(this->well_state_map_.at(well_name).get()); GasLiftWellState &state = *(this->well_state_map_.at(well_name).get());
std::tie(oil_rate, gas_rate) = state.getRates(); std::tie(oil_rate, gas_rate) = state.getRates();
success = true; success = true;
if ( this->debug_) debug_info = "(A)"; if ( this->debug_) debug_info = "(A)";
@ -1135,7 +1134,7 @@ updateRates(const std::string &well_name)
// compute the delta on wells on own rank // compute the delta on wells on own rank
if (this->parent.well_state_map_.count(well_name) > 0) { if (this->parent.well_state_map_.count(well_name) > 0) {
const GradInfo &gi = this->parent.dec_grads_.at(well_name); const GradInfo &gi = this->parent.dec_grads_.at(well_name);
GLiftWellState &state = *(this->parent.well_state_map_.at(well_name).get()); GasLiftWellState &state = *(this->parent.well_state_map_.at(well_name).get());
GasLiftSingleWell &gs_well = *(this->parent.stage1_wells_.at(well_name).get()); GasLiftSingleWell &gs_well = *(this->parent.stage1_wells_.at(well_name).get());
const WellInterface<TypeTag> &well = gs_well.getStdWell(); const WellInterface<TypeTag> &well = gs_well.getStdWell();
// only get deltas for wells owned by this rank // only get deltas for wells owned by this rank