diff --git a/opm/autodiff/WellStateFullyImplicitBlackoil.hpp b/opm/autodiff/WellStateFullyImplicitBlackoil.hpp index 5507e16ca..d5ec6b868 100644 --- a/opm/autodiff/WellStateFullyImplicitBlackoil.hpp +++ b/opm/autodiff/WellStateFullyImplicitBlackoil.hpp @@ -80,11 +80,17 @@ namespace Opm } const int nw = wells->number_of_wells; + if( nw == 0 ) return ; // Initialize perfphaserates_, which must be done here. const int np = wells->number_of_phases; const int nperf = wells->well_connpos[nw]; + + well_reservoir_rates_.resize(nw * np, 0.0); + well_dissolved_gas_rates_.resize(nw, 0.0); + well_vaporized_oil_rates_.resize(nw, 0.0); + // Ensure that we start out with zero rates by default. perfphaserates_.clear(); perfphaserates_.resize(nperf * np, 0.0); @@ -279,6 +285,23 @@ namespace Opm auto& well = res.at( wt.first ); well.control = this->currentControls()[ w ]; + const int well_rate_index = w * pu.num_phases; + + if ( pu.phase_used[Water] ) { + well.rates.set( rt::reservoir_water, this->well_reservoir_rates_[well_rate_index + pu.phase_pos[Water]] ); + } + + if ( pu.phase_used[Oil] ) { + well.rates.set( rt::reservoir_oil, this->well_reservoir_rates_[well_rate_index + pu.phase_pos[Oil]] ); + } + + if ( pu.phase_used[Gas] ) { + well.rates.set( rt::reservoir_oil, this->well_reservoir_rates_[well_rate_index + pu.phase_pos[Gas]] ); + } + + well.rates.set( rt::dissolved_gas, this->well_dissolved_gas_rates_[w] ); + well.rates.set( rt::vaporized_oil, this->well_vaporized_oil_rates_[w] ); + int local_comp_index = 0; for( auto& comp : well.completions ) { const auto rates = this->perfPhaseRates().begin() @@ -511,6 +534,37 @@ namespace Opm return solvent_well_rate; } + /* const std::vector& wellReservoirRates() const + { + return well_reservoir_rates_; + } */ + + std::vector& wellReservoirRates() + { + return well_reservoir_rates_; + } + + /* const std::vector& wellDissolvedGasRates() const + { + return well_dissolved_gas_rates_; + } */ + + std::vector& wellDissolvedGasRates() + { + return well_dissolved_gas_rates_; + } + + /* const std::vector& wellVaporizedOilRates() const + { + return well_vaporized_oil_rates_; + } */ + + std::vector& wellVaporizedOilRates() + { + return well_vaporized_oil_rates_; + } + + const std::vector& segRates() const { return segrates_; @@ -548,6 +602,18 @@ namespace Opm std::vector current_controls_; std::vector perfRateSolvent_; + // phase rates under reservoir condition for wells + // or voidage phase rates + std::vector well_reservoir_rates_; + + // dissolved gas rates or solution gas production rates + // should be zero for injection wells + std::vector well_dissolved_gas_rates_; + + // vaporized oil rates or solution oil producation rates + // should be zero for injection wells + std::vector well_vaporized_oil_rates_; + // marking whether the well is just added // for newly added well, the current initialized rates from WellState // will have very wrong compositions for production wells, will mostly cause