Use well index for segment pressure

This commit is contained in:
Joakim Hove 2021-05-26 08:17:46 +02:00
parent 3025bf3280
commit 34ef516472
5 changed files with 17 additions and 17 deletions

View File

@ -2017,8 +2017,8 @@ namespace Opm {
// \Note: eventually we need to hanlde the situations that some segments are shut
assert(0u + segment_set.size() == rst_segments.size());
auto * segment_pressure = &well_state.segPress()[top_segment_index];
auto * segment_rates = &well_state.segRates()[top_segment_index*np];
auto segment_pressure = well_state.segPress(well_index);
for (const auto& rst_segment : rst_segments) {
const int segment_index = segment_set.segmentNumberToIndex(rst_segment.first);

View File

@ -318,7 +318,7 @@ namespace Opm
//scale segment pressures
const int top_segment_index = well_state.topSegmentIndex(index_of_well_);
const double bhp = well_state.bhp(index_of_well_);
auto * segment_pressure = &well_state.segPress()[top_segment_index];
auto segment_pressure = well_state.segPress(index_of_well_);
const double unscaled_top_seg_pressure = segment_pressure[0];
for (int seg = 0; seg < numberOfSegments(); ++seg) {
segment_pressure[seg] *= bhp/unscaled_top_seg_pressure;
@ -724,7 +724,7 @@ namespace Opm
// the index of the top segment in the WellState
const int top_segment_index = well_state.topSegmentIndex(index_of_well_);
const auto * segment_rates = &well_state.segRates()[top_segment_index * this->number_of_phases_];
const auto * segment_pressure = &well_state.segPress()[top_segment_index];
const auto segment_pressure = well_state.segPress(index_of_well_);
const PhaseUsage& pu = phaseUsage();
for (int seg = 0; seg < numberOfSegments(); ++seg) {
@ -2341,7 +2341,7 @@ namespace Opm
const int oil_pos = pu.phase_pos[Oil];
auto * segment_rates = &well_state.segRates()[well_state.topSegmentIndex(this->index_of_well_) * this->number_of_phases_];
auto * segment_pressure = &well_state.segPress()[well_state.topSegmentIndex(this->index_of_well_)];
auto segment_pressure = well_state.segPress(this->index_of_well_);
for (int seg = 0; seg < numberOfSegments(); ++seg) {
std::vector<double> fractions(number_of_phases_, 0.0);
fractions[oil_pos] = 1.0;

View File

@ -976,10 +976,10 @@ void WellState::initWellStateMSWell(const std::vector<Well>& wells_ecl,
}
auto * segment_rates = &this->seg_rates_[new_top_segment_index*np];
auto * segment_pressure = &this->seg_press_[new_top_segment_index];
auto segment_pressure = this->segPress(w);
const auto * prev_segment_rates = &prev_well_state->segRates()[old_top_segment_index*np];
const auto * prev_segment_pressure = &prev_well_state->segPress()[new_top_segment_index];
const auto prev_segment_pressure = prev_well_state->segPress(old_index_well);
for (int seg=0; seg < number_of_segment; ++seg) {
for (int p = 0; p < np; ++p)
@ -1162,7 +1162,7 @@ WellState::reportSegmentResults(const PhaseUsage& pu,
{
using Value = data::SegmentPressures::Value;
auto& segpress = seg_res.pressures;
segpress[Value::Pressure] = this->segPress()[seg_dof];
segpress[Value::Pressure] = this->segPress(well_id)[seg_ix];
segpress[Value::PDrop] = this->segPressDrop()[seg_dof];
segpress[Value::PDropHydrostatic] = this->segPressDropHydroStatic()[seg_dof];
segpress[Value::PDropFriction] = this->segPressDropFriction()[seg_dof];

View File

@ -202,9 +202,16 @@ public:
return seg_rates_;
}
const std::vector<double>& segPress() const
double * segPress(std::size_t well_index)
{
return seg_press_;
const int top_segment_index = this->top_segment_index_[well_index];
return &seg_press_[top_segment_index];
}
const double * segPress(std::size_t well_index) const
{
const int top_segment_index = this->top_segment_index_[well_index];
return &seg_press_[top_segment_index];
}
std::vector<double>& segPressDrop()
@ -247,11 +254,6 @@ public:
return seg_pressdrop_acceleration_;
}
std::vector<double>& segPress()
{
return seg_press_;
}
int numSegment() const
{
return nseg_;

View File

@ -164,14 +164,12 @@ namespace {
{
const auto nWell = wells.size();
auto& segPress = wstate.segPress();
for (auto wellID = 0*nWell; wellID < nWell; ++wellID) {
const auto& well = wells[wellID];
const auto topSegIx = wstate.topSegmentIndex(wellID);
const auto pressTop = 100.0 * wellID;
auto* press = &segPress[topSegIx];
auto* press = wstate.segPress(wellID);
press[0] = pressTop;