changed: store rates in an array in SingleWellState

introduce an enum for indexing into the array. this again
allows us to coalesce 4 parallel reductions into one.
This commit is contained in:
Arne Morten Kvarving 2023-05-04 13:24:23 +02:00
parent a306efa7e6
commit c18fb6a577
5 changed files with 25 additions and 34 deletions

View File

@ -1560,10 +1560,7 @@ namespace Opm
this->linSys_.clear(); this->linSys_.clear();
auto& ws = well_state.well(this->index_of_well_); auto& ws = well_state.well(this->index_of_well_);
ws.dissolved_gas_rate = 0; ws.phase_mixing_rates.fill(0.0);
ws.dissolved_gas_rate_in_water = 0;
ws.vaporized_oil_rate = 0;
ws.vaporized_wat_rate = 0;
// for the black oil cases, there will be four equations, // for the black oil cases, there will be four equations,
// the first three of them are the mass balance equations, the last one is the pressure equations. // the first three of them are the mass balance equations, the last one is the pressure equations.
@ -1642,8 +1639,8 @@ namespace Opm
// updating the solution gas rate and solution oil rate // updating the solution gas rate and solution oil rate
if (this->isProducer()) { if (this->isProducer()) {
ws.dissolved_gas_rate += perfRates.dis_gas; ws.phase_mixing_rates[ws.dissolved_gas] += perfRates.dis_gas;
ws.vaporized_oil_rate += perfRates.vap_oil; ws.phase_mixing_rates[ws.vaporized_oil] += perfRates.vap_oil;
} }
// store the perf pressure and rates // store the perf pressure and rates

View File

@ -291,10 +291,7 @@ bool SingleWellState::operator==(const SingleWellState& rhs) const
this->bhp == rhs.bhp && this->bhp == rhs.bhp &&
this->thp == rhs.thp && this->thp == rhs.thp &&
this->temperature == rhs.temperature && this->temperature == rhs.temperature &&
this->dissolved_gas_rate == rhs.dissolved_gas_rate && this->phase_mixing_rates == rhs.phase_mixing_rates &&
this->dissolved_gas_rate_in_water == rhs.dissolved_gas_rate_in_water &&
this->vaporized_oil_rate == rhs.vaporized_oil_rate &&
this->vaporized_wat_rate == rhs.vaporized_wat_rate &&
this->well_potentials == rhs.well_potentials && this->well_potentials == rhs.well_potentials &&
this->productivity_index == rhs.productivity_index && this->productivity_index == rhs.productivity_index &&
this->surface_rates == rhs.surface_rates && this->surface_rates == rhs.surface_rates &&

View File

@ -58,10 +58,7 @@ public:
serializer(bhp); serializer(bhp);
serializer(thp); serializer(thp);
serializer(temperature); serializer(temperature);
serializer(dissolved_gas_rate); serializer(phase_mixing_rates);
serializer(dissolved_gas_rate_in_water);
serializer(vaporized_oil_rate);
serializer(vaporized_wat_rate);
serializer(well_potentials); serializer(well_potentials);
serializer(productivity_index); serializer(productivity_index);
serializer(surface_rates); serializer(surface_rates);
@ -85,10 +82,15 @@ public:
double bhp{0}; double bhp{0};
double thp{0}; double thp{0};
double temperature{0}; double temperature{0};
double dissolved_gas_rate{0};
double dissolved_gas_rate_in_water{0}; std::array<double,4> phase_mixing_rates{};
double vaporized_oil_rate{0}; enum RateIndices {
double vaporized_wat_rate{0}; dissolved_gas = 0,
dissolved_gas_in_water = 1,
vaporized_oil = 2,
vaporized_water = 3
};
std::vector<double> well_potentials; std::vector<double> well_potentials;
std::vector<double> productivity_index; std::vector<double> productivity_index;
std::vector<double> surface_rates; std::vector<double> surface_rates;

View File

@ -496,11 +496,7 @@ namespace Opm
const double volume = 0.1 * unit::cubic(unit::feet) * regularization_factor; const double volume = 0.1 * unit::cubic(unit::feet) * regularization_factor;
auto& ws = well_state.well(this->index_of_well_); auto& ws = well_state.well(this->index_of_well_);
ws.phase_mixing_rates.fill(0.0);
ws.vaporized_oil_rate = 0;
ws.dissolved_gas_rate = 0;
ws.dissolved_gas_rate_in_water = 0;
ws.vaporized_wat_rate = 0;
const int np = this->number_of_phases_; const int np = this->number_of_phases_;
@ -558,10 +554,7 @@ namespace Opm
// ranks sharing this well (this->index_of_well_). // ranks sharing this well (this->index_of_well_).
{ {
const auto& comm = this->parallel_well_info_.communication(); const auto& comm = this->parallel_well_info_.communication();
ws.dissolved_gas_rate = comm.sum(ws.dissolved_gas_rate); comm.sum(ws.phase_mixing_rates.data(), ws.phase_mixing_rates.size());
ws.dissolved_gas_rate_in_water = comm.sum(ws.dissolved_gas_rate_in_water);
ws.vaporized_oil_rate = comm.sum(ws.vaporized_oil_rate);
ws.vaporized_wat_rate = comm.sum(ws.vaporized_wat_rate);
} }
// accumulate resWell_ and duneD_ in parallel to get effects of all perforations (might be distributed) // accumulate resWell_ and duneD_ in parallel to get effects of all perforations (might be distributed)
@ -649,10 +642,10 @@ namespace Opm
// updating the solution gas rate and solution oil rate // updating the solution gas rate and solution oil rate
if (this->isProducer()) { if (this->isProducer()) {
ws.dissolved_gas_rate += perf_rates.dis_gas; ws.phase_mixing_rates[ws.dissolved_gas] += perf_rates.dis_gas;
ws.dissolved_gas_rate_in_water += perf_rates.dis_gas_in_water; ws.phase_mixing_rates[ws.dissolved_gas_in_water] += perf_rates.dis_gas_in_water;
ws.vaporized_oil_rate += perf_rates.vap_oil; ws.phase_mixing_rates[ws.vaporized_oil] += perf_rates.vap_oil;
ws.vaporized_wat_rate += perf_rates.vap_wat; ws.phase_mixing_rates[ws.vaporized_water] += perf_rates.vap_wat;
} }
if constexpr (has_energy) { if constexpr (has_energy) {

View File

@ -540,9 +540,11 @@ WellState::report(const int* globalCellIdxMap,
well.rates.set(rt::alq, 0.0); well.rates.set(rt::alq, 0.0);
} }
well.rates.set(rt::dissolved_gas, ws.dissolved_gas_rate + ws.dissolved_gas_rate_in_water); well.rates.set(rt::dissolved_gas,
well.rates.set(rt::vaporized_oil, ws.vaporized_oil_rate); ws.phase_mixing_rates[ws.dissolved_gas] +
well.rates.set(rt::vaporized_water, ws.vaporized_wat_rate); ws.phase_mixing_rates[ws.dissolved_gas_in_water]);
well.rates.set(rt::vaporized_oil, ws.phase_mixing_rates[ws.vaporized_oil]);
well.rates.set(rt::vaporized_water, ws.phase_mixing_rates[ws.vaporized_water]);
{ {
auto& curr = well.current_control; auto& curr = well.current_control;