mirror of
https://github.com/OPM/opm-simulators.git
synced 2025-01-13 09:51:57 -06:00
Use WellContainer to manage perf phase rates
This commit is contained in:
parent
76292552ec
commit
6a21371b59
@ -1996,7 +1996,7 @@ namespace Opm {
|
||||
|
||||
auto& perf_pressure = well_state.perfPress(well_index);
|
||||
auto& perf_rates = well_state.perfRates(well_index);
|
||||
auto * perf_phase_rates = well_state.perfPhaseRates(well_index);
|
||||
auto& perf_phase_rates = well_state.perfPhaseRates(well_index);
|
||||
const auto& perf_data = this->well_perf_data_[well_index];
|
||||
|
||||
for (std::size_t perf_index = 0; perf_index < perf_data.size(); perf_index++) {
|
||||
@ -3373,7 +3373,7 @@ namespace Opm {
|
||||
|
||||
auto& well_info = *local_parallel_well_info_[wellID];
|
||||
const int num_perf_this_well = well_info.communication().sum(well_perf_data_[wellID].size());
|
||||
auto * perf_phase_rate = this->wellState().perfPhaseRates(wellID);
|
||||
auto& perf_phase_rate = this->wellState().perfPhaseRates(wellID);
|
||||
|
||||
for (int perf = 0; perf < num_perf_this_well; ++perf) {
|
||||
const int cell_idx = well_perf_data_[wellID][perf].cell_index;
|
||||
|
@ -2637,7 +2637,7 @@ namespace Opm
|
||||
|
||||
// calculating the perforation rate for each perforation that belongs to this segment
|
||||
const EvalWell seg_pressure = getSegmentPressure(seg);
|
||||
auto * perf_rates = well_state.perfPhaseRates(this->index_of_well_);
|
||||
auto& perf_rates = well_state.perfPhaseRates(this->index_of_well_);
|
||||
auto& perf_press_state = well_state.perfPress(this->index_of_well_);
|
||||
for (const int perf : segment_perforations_[seg]) {
|
||||
const int cell_idx = well_cells_[perf];
|
||||
|
@ -591,7 +591,7 @@ namespace Opm
|
||||
const int np = number_of_phases_;
|
||||
|
||||
std::vector<RateVector> connectionRates = connectionRates_; // Copy to get right size.
|
||||
auto * perf_rates = well_state.perfPhaseRates(this->index_of_well_);
|
||||
auto& perf_rates = well_state.perfPhaseRates(this->index_of_well_);
|
||||
for (int perf = 0; perf < number_of_perforations_; ++perf) {
|
||||
// Calculate perforation quantities.
|
||||
std::vector<EvalWell> cq_s(num_components_, {numWellEq_ + numEq, 0.0});
|
||||
@ -2104,7 +2104,7 @@ namespace Opm
|
||||
const int nperf = number_of_perforations_;
|
||||
const int np = number_of_phases_;
|
||||
std::vector<double> perfRates(b_perf.size(),0.0);
|
||||
const auto * perf_rates_state = well_state.perfPhaseRates(this->index_of_well_);
|
||||
const auto& perf_rates_state = well_state.perfPhaseRates(this->index_of_well_);
|
||||
|
||||
for (int perf = 0; perf < nperf; ++perf) {
|
||||
for (int comp = 0; comp < np; ++comp) {
|
||||
|
@ -846,7 +846,7 @@ checkMaxRatioLimitCompletions(const WellState& well_state,
|
||||
double max_ratio_completion = 0;
|
||||
const int np = number_of_phases_;
|
||||
|
||||
const auto * perf_phase_rates = well_state.perfPhaseRates(this->index_of_well_);
|
||||
const auto& perf_phase_rates = well_state.perfPhaseRates(this->index_of_well_);
|
||||
// look for the worst_offending_completion
|
||||
for (const auto& completion : completions_) {
|
||||
std::vector<double> completion_rates(np, 0.0);
|
||||
|
@ -44,6 +44,7 @@ void WellState::base_init(const std::vector<double>& cellPressures,
|
||||
this->perf_skin_pressure_.clear();
|
||||
this->perf_water_throughput_.clear();
|
||||
this->perf_water_velocity_.clear();
|
||||
this->perfphaserates_.clear();
|
||||
this->perfrates_.clear();
|
||||
this->perfRateBrine_.clear();
|
||||
this->perfRateSolvent_.clear();
|
||||
@ -107,6 +108,7 @@ void WellState::initSingleWell(const std::vector<double>& cellPressures,
|
||||
this->segment_state.add(well.name(), SegmentState{});
|
||||
this->perfpress_.add(well.name(), std::vector<double>(num_perf_this_well, -1e100));
|
||||
this->perfrates_.add(well.name(), std::vector<double>(num_perf_this_well, 0));
|
||||
this->perfphaserates_.add(well.name(), std::vector<double>(np*num_perf_this_well, 0));
|
||||
this->perf_skin_pressure_.add(well.name(), std::vector<double>(num_perf_this_well, 0));
|
||||
this->perf_water_velocity_.add(well.name(), std::vector<double>(num_perf_this_well, 0));
|
||||
this->perf_water_throughput_.add(well.name(), std::vector<double>(num_perf_this_well, 0));
|
||||
@ -287,9 +289,6 @@ void WellState::init(const std::vector<double>& cellPressures,
|
||||
this->events_.add( wname, Events() );
|
||||
}
|
||||
}
|
||||
// Ensure that we start out with zero rates by default.
|
||||
perfphaserates_.clear();
|
||||
perfphaserates_.resize(nperf * this->numPhases(), 0.0);
|
||||
|
||||
first_perf_index_.resize(nw, 0);
|
||||
first_perf_index_[0] = 0;
|
||||
@ -304,7 +303,7 @@ void WellState::init(const std::vector<double>& cellPressures,
|
||||
auto& perf_press = this->perfPress(w);
|
||||
|
||||
first_perf_index_[w] = connpos;
|
||||
auto phase_rates = this->perfPhaseRates(w);
|
||||
auto& phase_rates = this->perfPhaseRates(w);
|
||||
|
||||
for (int perf = 0; perf < num_perf_this_well; ++perf) {
|
||||
if (wells_ecl[w].getStatus() == Well::Status::OPEN) {
|
||||
@ -432,8 +431,8 @@ void WellState::init(const std::vector<double>& cellPressures,
|
||||
// number of perforations.
|
||||
if (global_num_perf_same)
|
||||
{
|
||||
const auto * src_rates = prevState->perfPhaseRates(oldIndex);
|
||||
auto * target_rates = this->perfPhaseRates(newIndex);
|
||||
const auto& src_rates = prevState->perfPhaseRates(oldIndex);
|
||||
auto& target_rates = this->perfPhaseRates(newIndex);
|
||||
for (int perf_index = 0; perf_index < num_perf_this_well; perf_index++) {
|
||||
for (int p = 0; p < np; p++) {
|
||||
target_rates[perf_index*np + p] = src_rates[perf_index*np + p];
|
||||
@ -441,7 +440,7 @@ void WellState::init(const std::vector<double>& cellPressures,
|
||||
}
|
||||
} else {
|
||||
const int global_num_perf_this_well = parallel_well_info[w]->communication().sum(num_perf_this_well);
|
||||
auto * target_rates = this->perfPhaseRates(newIndex);
|
||||
auto& target_rates = this->perfPhaseRates(newIndex);
|
||||
for (int perf_index = 0; perf_index < num_perf_this_well; perf_index++) {
|
||||
for (int p = 0; p < np; ++p) {
|
||||
target_rates[perf_index*np + p] = wellRates(w)[p] / double(global_num_perf_this_well);
|
||||
@ -755,7 +754,7 @@ void WellState::reportConnections(data::Well& well,
|
||||
for( auto& comp : well.connections) {
|
||||
const auto connPhaseOffset = np * (wt.second[1] + local_comp_index);
|
||||
|
||||
const auto * rates = &this->perfPhaseRates(well_index)[np*local_comp_index];
|
||||
const auto& rates = &this->perfPhaseRates(well_index)[np*local_comp_index];
|
||||
const auto connPI = this->connectionProductivityIndex().begin() + connPhaseOffset;
|
||||
|
||||
for( int i = 0; i < np; ++i ) {
|
||||
@ -796,8 +795,6 @@ void WellState::initWellStateMSWell(const std::vector<Well>& wells_ecl,
|
||||
for (int w = 0; w < nw; ++w) {
|
||||
const auto& well_ecl = wells_ecl[w];
|
||||
const auto& wname = wells_ecl[w].name();
|
||||
const auto& well_info = this->wellMap().at(wname);
|
||||
const int num_perf_this_well = well_info[2];
|
||||
|
||||
if ( well_ecl.isMultiSegment() ) {
|
||||
const WellSegments& segment_set = well_ecl.getSegments();
|
||||
@ -840,7 +837,7 @@ void WellState::initWellStateMSWell(const std::vector<Well>& wells_ecl,
|
||||
"Inconsistent number of reservoir connections in well");
|
||||
|
||||
if (pu.phase_used[Gas]) {
|
||||
auto * perf_rates = this->perfPhaseRates(w);
|
||||
auto& perf_rates = this->perfPhaseRates(w);
|
||||
const int gaspos = pu.phase_pos[Gas];
|
||||
// scale the phase rates for Gas to avoid too bad initial guess for gas fraction
|
||||
// it will probably benefit the standard well too, while it needs to be justified
|
||||
@ -851,8 +848,8 @@ void WellState::initWellStateMSWell(const std::vector<Well>& wells_ecl,
|
||||
perf_rates[perf*np + gaspos] *= 100;
|
||||
}
|
||||
|
||||
const auto * perf_rates = this->perfPhaseRates(w);
|
||||
std::vector<double> perforation_rates(perf_rates, perf_rates + num_perf_this_well*np);
|
||||
const auto& perf_rates = this->perfPhaseRates(w);
|
||||
std::vector<double> perforation_rates(perf_rates.begin(), perf_rates.end());
|
||||
|
||||
auto& segments = this->segments(w);
|
||||
calculateSegmentRates(segment_inlets, segment_perforations, perforation_rates, np, 0 /* top segment */, segments.rates);
|
||||
|
@ -81,7 +81,7 @@ public:
|
||||
|
||||
/// Allocate and initialize if wells is non-null. Also tries
|
||||
/// to give useful initial values to the bhp(), wellRates()
|
||||
/// and perfPhaseRates() fields, depending on controls
|
||||
/// and perfPhaseRatesORG() fields, depending on controls
|
||||
void init(const std::vector<double>& cellPressures,
|
||||
const Schedule& schedule,
|
||||
const std::vector<Well>& wells_ecl,
|
||||
@ -100,12 +100,13 @@ public:
|
||||
const SummaryState& summary_state);
|
||||
|
||||
/// One rate per phase and well connection.
|
||||
double * perfPhaseRates(std::size_t well_index) {
|
||||
return &this->perfphaserates_[this->first_perf_index_[well_index] * this->numPhases()];
|
||||
|
||||
std::vector<double>& perfPhaseRates(std::size_t well_index) {
|
||||
return this->perfphaserates_[well_index];
|
||||
}
|
||||
|
||||
const double * perfPhaseRates(std::size_t well_index) const {
|
||||
return &this->perfphaserates_[this->first_perf_index_[well_index] * this->numPhases()];
|
||||
const std::vector<double>& perfPhaseRates(std::size_t well_index) const {
|
||||
return this->perfphaserates_[well_index];
|
||||
}
|
||||
|
||||
/// One current control per injecting well.
|
||||
@ -436,7 +437,7 @@ private:
|
||||
WellContainer<std::vector<double>> perfrates_;
|
||||
WellContainer<std::vector<double>> perfpress_;
|
||||
|
||||
std::vector<double> perfphaserates_;
|
||||
WellContainer<std::vector<double>> perfphaserates_;
|
||||
WellContainer<int> is_producer_; // Size equal to number of local wells.
|
||||
|
||||
// vector with size number of wells +1.
|
||||
|
Loading…
Reference in New Issue
Block a user