Add SegmentState member to SingleWellState

This commit is contained in:
Joakim Hove
2021-08-05 12:55:18 +02:00
parent 67bd2fd333
commit 77a9fd352b
8 changed files with 42 additions and 74 deletions

View File

@@ -43,7 +43,6 @@ void WellState::base_init(const std::vector<double>& cellPressures,
this->perfdata.clear();
this->parallel_well_info_.clear();
this->wellrates_.clear();
this->segment_state.clear();
this->wells_.clear();
{
// const int nw = wells->number_of_wells;
@@ -92,7 +91,6 @@ void WellState::initSingleWell(const std::vector<double>& cellPressures,
this->parallel_well_info_.add(well.name(), well_info);
this->wellrates_.add(well.name(), std::vector<double>(np, 0));
const int num_perf_this_well = well_info->communication().sum(well_perf_data.size());
this->segment_state.add(well.name(), SegmentState{});
this->perfdata.add(well.name(), PerfData{static_cast<std::size_t>(num_perf_this_well), well.isInjector(), this->phase_usage_});
if ( num_perf_this_well == 0 )
@@ -325,7 +323,6 @@ void WellState::init(const std::vector<double>& cellPressures,
if (well.getStatus() == Well::Status::SHUT) {
continue;
}
const auto& wname = well.name();
auto& new_well = this->well(w);
auto it = prevState->wellMap().find(well.name());
if (it != end)
@@ -651,7 +648,7 @@ void WellState::initWellStateMSWell(const std::vector<Well>& wells_ecl,
// assuming the order of the perforations in well_ecl is the same with Wells
const WellConnections& completion_set = well_ecl.getConnections();
// number of segment for this single well
this->segment_state.update(w, SegmentState{np, segment_set});
ws.segments = SegmentState{np, segment_set};
const int well_nseg = segment_set.size();
int n_activeperf = 0;
@@ -702,8 +699,7 @@ void WellState::initWellStateMSWell(const std::vector<Well>& wells_ecl,
const auto& perf_rates = perf_data.phase_rates;
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);
calculateSegmentRates(segment_inlets, segment_perforations, perforation_rates, np, 0 /* top segment */, ws.segments.rates);
}
// for the segment pressure, the segment pressure is the same with the first perforation belongs to the segment
// if there is no perforation associated with this segment, it uses the pressure from the outlet segment
@@ -712,7 +708,7 @@ void WellState::initWellStateMSWell(const std::vector<Well>& wells_ecl,
// improved during the solveWellEq process
{
// top segment is always the first one, and its pressure is the well bhp
auto& segment_pressure = this->segments(w).pressure;
auto& segment_pressure = ws.segments.pressure;
segment_pressure[0] = ws.bhp;
const auto& perf_press = perf_data.pressure;
for (int seg = 1; seg < well_nseg; ++seg) {
@@ -741,7 +737,8 @@ void WellState::initWellStateMSWell(const std::vector<Well>& wells_ecl,
continue;
const auto& wname = well.name();
if (prev_well_state->segment_state.has(wname)) {
if (prev_well_state->has(wname)) {
auto& ws = this->well(w);
const auto& prev_ws = prev_well_state->well(wname);
if (prev_ws.status == Well::Status::SHUT) {
continue;
@@ -750,7 +747,7 @@ void WellState::initWellStateMSWell(const std::vector<Well>& wells_ecl,
// TODO: the well with same name can change a lot, like they might not have same number of segments
// we need to handle that later.
// for now, we just copy them.
this->segment_state.copy_welldata(prev_well_state->segment_state, wname);
ws.segments = prev_ws.segments;
}
}
}
@@ -917,7 +914,7 @@ WellState::reportSegmentResults(const PhaseUsage& pu,
const int seg_ix,
const int seg_no) const
{
const auto& segments = this->segments(well_id);
const auto& segments = this->well(well_id).segments;
if (segments.empty())
return {};
@@ -983,14 +980,14 @@ int WellState::wellIndex(const std::string& wellName) const
int WellState::numSegments(const int well_id) const
{
const auto& segments = this->segments(well_id);
return segments.size();
const auto& ws = this->well(well_id);
return ws.segments.size();
}
int WellState::segmentNumber(const int well_id, const int seg_id) const
{
const auto& segments = this->segment_state[well_id];
return segments.segment_number()[seg_id];
const auto& ws = this->well(well_id);
return ws.segments.segment_number()[seg_id];
}
void WellState::updateWellsDefaultALQ( const std::vector<Well>& wells_ecl )