Use SegmentState when copying pressure

This commit is contained in:
Joakim Hove
2021-06-01 10:24:18 +02:00
parent eb937e8ba2
commit eac69061c2
5 changed files with 22 additions and 29 deletions

View File

@@ -2021,7 +2021,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(well_index);
auto& segments = well_state.segments(well_index);
auto& segment_pressure = segments.pressure;
auto segment_rates = well_state.segRates(well_index);
for (const auto& rst_segment : rst_segments) {
const int segment_index = segment_set.segmentNumberToIndex(rst_segment.first);

View File

@@ -315,12 +315,12 @@ namespace Opm
scaleSegmentPressuresWithBhp(WellState& well_state) const
{
//scale segment pressures
auto& segments = well_state.segments(this->index_of_well_);
const double bhp = well_state.bhp(index_of_well_);
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;
}
const double unscaled_top_seg_pressure = segments.pressure[0];
const double scale_factor = bhp / unscaled_top_seg_pressure;
std::transform(segments.pressure.begin(), segments.pressure.end(), segments.pressure.begin(), [scale_factor](const double& p) { return p*scale_factor;} );
}
@@ -719,8 +719,9 @@ namespace Opm
const Well& well = Base::wellEcl();
// the index of the top segment in the WellState
const auto& segments = well_state.segments(this->index_of_well_);
const auto segment_rates = well_state.segRates(index_of_well_);
const auto segment_pressure = well_state.segPress(index_of_well_);
const auto& segment_pressure = segments.pressure;
const PhaseUsage& pu = phaseUsage();
for (int seg = 0; seg < numberOfSegments(); ++seg) {
@@ -2337,8 +2338,9 @@ namespace Opm
assert( FluidSystem::phaseIsActive(FluidSystem::oilPhaseIdx) );
const int oil_pos = pu.phase_pos[Oil];
auto& segments = well_state.segments(this->index_of_well_);
auto segment_rates = well_state.segRates(this->index_of_well_);
auto segment_pressure = well_state.segPress(this->index_of_well_);
auto& segment_pressure = segments.pressure;
for (int seg = 0; seg < numberOfSegments(); ++seg) {
std::vector<double> fractions(number_of_phases_, 0.0);
fractions[oil_pos] = 1.0;

View File

@@ -945,6 +945,7 @@ void WellState::initWellStateMSWell(const std::vector<Well>& wells_ecl,
if ( !well.isMultiSegment() )
continue;
const auto& wname = well.name();
const auto& it = prev_well_state->wellMap().find( wells_ecl[w].name() );
if (it != end) { // the well is found in the prev_well_state
// TODO: the well with same name can change a lot, like they might not have same number of segments
@@ -965,17 +966,18 @@ void WellState::initWellStateMSWell(const std::vector<Well>& wells_ecl,
number_of_segment = topSegmentIndex(new_index_well + 1) - new_top_segment_index;
}
auto segment_rates = this->segRates(w);
auto segment_pressure = this->segPress(w);
auto& segments = this->segments(wname);
const auto& prev_segments = prev_well_state->segments(wname);
segments.pressure = prev_segments.pressure;
auto segment_rates = this->segRates(w);
const auto prev_segment_rates = prev_well_state->segRates(old_index_well);
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)
segment_rates[seg*np + p] = prev_segment_rates[seg*np + p];
segment_pressure[seg] = prev_segment_pressure[seg];
}
}
}
@@ -1149,7 +1151,7 @@ WellState::reportSegmentResults(const PhaseUsage& pu,
{
using Value = data::SegmentPressures::Value;
auto& segpress = seg_res.pressures;
segpress[Value::Pressure] = this->segPress(well_id)[seg_ix];
segpress[Value::Pressure] = segments.pressure[seg_ix];
segpress[Value::PDrop] = segments.pressure_drop(seg_ix);
segpress[Value::PDropHydrostatic] = segments.pressure_drop_hydrostatic[seg_ix];
segpress[Value::PDropFriction] = segments.pressure_drop_friction[seg_ix];

View File

@@ -208,18 +208,6 @@ public:
return &this->seg_rates_[top_segment_index * this->phase_usage_.num_phases];
}
double * segPress(std::size_t well_index)
{
auto& segment = this->segments(well_index);
return segment.pressure.data();
}
const double * segPress(std::size_t well_index) const
{
const auto& segment = this->segments(well_index);
return segment.pressure.data();
}
int numSegment() const
{