Use PerfData for perforation pressure

This commit is contained in:
Joakim Hove 2021-06-05 08:52:18 +02:00
parent 4b69d12335
commit 76838cd8a4
8 changed files with 62 additions and 31 deletions

View File

@ -188,13 +188,15 @@ loadRestartData(const data::Wells& rst_wells,
well_state.wellRates(well_index)[i] = rst_well.rates.get(phs[i]);
}
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);
const auto& perf_data = this->well_perf_data_[well_index];
for (std::size_t perf_index = 0; perf_index < perf_data.size(); perf_index++) {
const auto& pd = perf_data[perf_index];
auto& perf_data = well_state.perfData(well_index);
auto& perf_pressure = perf_data.pressure;
const auto& old_perf_data = this->well_perf_data_[well_index];
for (std::size_t perf_index = 0; perf_index < old_perf_data.size(); perf_index++) {
const auto& pd = old_perf_data[perf_index];
const auto& rst_connection = rst_well.connections[pd.ecl_index];
perf_pressure[perf_index] = rst_connection.pressure;
perf_rates[perf_index] = rst_connection.reservoir_rate;

View File

@ -1247,8 +1247,9 @@ namespace Opm
// calculating the perforation rate for each perforation that belongs to this segment
const EvalWell seg_pressure = this->getSegmentPressure(seg);
auto& perf_data = well_state.perfData(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_);
auto& perf_press_state = perf_data.pressure;
for (const int perf : this->segment_perforations_[seg]) {
const int cell_idx = well_cells_[perf];
const auto& int_quants = *(ebosSimulator.model().cachedIntensiveQuantities(cell_idx, /*timeIdx=*/ 0));

View File

@ -44,5 +44,23 @@ std::size_t PerfData::size() const {
return this->pressure.size();
}
bool PerfData::try_assign(const PerfData& other) {
if (this->size() != other.size())
return false;
this->pressure = other.pressure;
this->rates = other.rates;
this->phase_rates = other.phase_rates;
this->solvent_rates = other.solvent_rates;
this->polymer_rates = other.polymer_rates;
this->brine_rates = other.brine_rates;
this->water_throughput = other.water_throughput;
this->skin_pressure = other.skin_pressure;
this->water_velocity = other.water_velocity;
this->prod_index = other.prod_index;
return true;
}
}

View File

@ -36,6 +36,8 @@ private:
public:
PerfData(std::size_t num_perf, const PhaseUsage& pu);
std::size_t size() const;
bool try_assign(const PerfData& other);
std::vector<double> pressure;
std::vector<double> rates;

View File

@ -463,8 +463,8 @@ namespace Opm
}
// Store the perforation pressure for later usage.
auto& perf_press = well_state.perfPress(index_of_well_);
perf_press[perf] = well_state.bhp(index_of_well_) + this->perf_pressure_diffs_[perf];
auto& perf_data = well_state.perfData(this->index_of_well_);
perf_data.pressure[perf] = well_state.bhp(this->index_of_well_) + this->perf_pressure_diffs_[perf];
}
@ -922,7 +922,7 @@ namespace Opm
}
// Compute the average pressure in each well block
const auto& perf_press = well_state.perfPress(w);
const auto& perf_press = well_state.perfData(w).pressure;
auto p_above = this->parallel_well_info_.communicateAboveValues(well_state.bhp(w),
perf_press.data(),
nperf);

View File

@ -40,7 +40,6 @@ void WellState::base_init(const std::vector<double>& cellPressures,
{
// clear old name mapping
this->wellMap_.clear();
this->perfpress_.clear();
this->perfdata.clear();
this->perf_skin_pressure_.clear();
this->perf_water_throughput_.clear();
@ -110,7 +109,6 @@ void WellState::initSingleWell(const std::vector<double>& cellPressures,
const int num_perf_this_well = well_info->communication().sum(well_perf_data_[w].size());
this->segment_state.add(well.name(), SegmentState{});
this->perfdata.add(well.name(), PerfData{num_perf_this_well, this->phase_usage_});
this->perfpress_.add(well.name(), std::vector<double>(num_perf_this_well, -1e100));
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));
@ -304,7 +302,7 @@ void WellState::init(const std::vector<double>& cellPressures,
const auto& well_info = this->wellMap().at(wname);
const int num_perf_this_well = well_info[2];
const int global_num_perf_this_well = ecl_well.getConnections().num_open();
auto& perf_press = this->perfPress(w);
auto& perf_data = this->perfData(w);
auto& phase_rates = this->perfPhaseRates(w);
@ -314,7 +312,7 @@ void WellState::init(const std::vector<double>& cellPressures,
phase_rates[this->numPhases()*perf + p] = wellRates(w)[p] / double(global_num_perf_this_well);
}
}
perf_press[perf] = cellPressures[well_perf_data[w][perf].cell_index];
perf_data.pressure[perf] = cellPressures[well_perf_data[w][perf].cell_index];
}
this->well_reservoir_rates_.add(wname, std::vector<double>(np, 0));
@ -449,12 +447,9 @@ void WellState::init(const std::vector<double>& cellPressures,
// perfPressures
if (global_num_perf_same)
{
auto& target_press = perfPress(w);
const auto& src_press = prevState->perfPress(well.name());
for (int perf = 0; perf < num_perf_this_well; ++perf)
{
target_press[perf] = src_press[perf];
}
auto& perf_data = this->perfData(w);
const auto& prev_perf_data = prevState->perfData(w);
perf_data.try_assign( prev_perf_data );
}
// perfSolventRates
@ -710,7 +705,7 @@ void WellState::reportConnections(data::Well& well,
well.connections.resize(num_perf_well);
const auto& perf_data = this->perfData(well_index);
const auto& perf_rates = perf_data.rates;
const auto& perf_pressure = this->perfPress(well_index);
const auto& perf_pressure = perf_data.pressure;
for( int i = 0; i < num_perf_well; ++i ) {
const auto active_index = this->well_perf_data_[well_index][i].cell_index;
auto& connection = well.connections[ i ];
@ -816,6 +811,7 @@ void WellState::initWellStateMSWell(const std::vector<Well>& wells_ecl,
}
auto& perf_data = this->perfData(w);
// for the seg_rates_, now it becomes a recursive solution procedure.
{
// make sure the information from wells_ecl consistent with wells
@ -849,7 +845,7 @@ void WellState::initWellStateMSWell(const std::vector<Well>& wells_ecl,
// top segment is always the first one, and its pressure is the well bhp
auto& segment_pressure = this->segments(w).pressure;
segment_pressure[0] = bhp(w);
const auto& perf_press = this->perfPress(w);
const auto& perf_press = perf_data.pressure;
for (int seg = 1; seg < well_nseg; ++seg) {
if ( !segment_perforations[seg].empty() ) {
const int first_perf = segment_perforations[seg][0];

View File

@ -398,14 +398,7 @@ public:
std::vector<double>& wellRates(std::size_t well_index) { return wellrates_[well_index]; }
const std::vector<double>& wellRates(std::size_t well_index) const { return wellrates_[well_index]; }
/// One pressure per well connection.
std::vector<double>& perfPress(std::size_t well_index) { return perfpress_[well_index]; }
const std::vector<double>& perfPress(std::size_t well_index) const { return perfpress_[well_index]; }
std::vector<double>& perfPress(const std::string& wname) { return perfpress_[wname]; }
const std::vector<double>& perfPress(const std::string& wname) const { return perfpress_[wname]; }
std::size_t numPerf(std::size_t well_index) const { return this->perfpress_[well_index].size(); }
std::size_t numPerf(std::size_t well_index) const { return this->perfdata[well_index].size(); }
PerfData& perfData(const std::string& wname) {
return this->perfdata[wname];
@ -441,7 +434,6 @@ private:
WellContainer<std::vector<double>> wellrates_;
PhaseUsage phase_usage_;
WellContainer<PerfData> perfdata;
WellContainer<std::vector<double>> perfpress_;
WellContainer<std::vector<double>> perfphaserates_;
WellContainer<int> is_producer_; // Size equal to number of local wells.

View File

@ -358,7 +358,8 @@ BOOST_AUTO_TEST_CASE(STOP_well)
std::vector<Opm::ParallelWellInfo> pinfos;
auto wstate = buildWellState(setup, 0, pinfos);
for (std::size_t well_index = 0; well_index < setup.sched.numWells(0); well_index++) {
for (const auto& p : wstate.perfPress(well_index))
const auto& perf_data = wstate.perfData(well_index);
for (const auto& p : perf_data.pressure)
BOOST_CHECK(p > 0);
}
}
@ -544,7 +545,26 @@ GAS
)";
Opm::PhaseUsage pu = Opm::phaseUsageFromDeck(Opm::Parser{}.parseString(deck_string));
Opm::PerfData pd(100,pu);
Opm::PerfData pd1(3,pu);
Opm::PerfData pd2(3,pu);
Opm::PerfData pd3(2,pu);
for (std::size_t i = 0; i < 3; i++) {
pd1.pressure[i] = i+1;
pd2.pressure[i] = 10*(i+1);
}
BOOST_CHECK(pd1.try_assign(pd2));
for (std::size_t i = 0; i < 3; i++) {
BOOST_CHECK(pd2.pressure[i] == 10*(i+1));
BOOST_CHECK(pd1.pressure[i] == 10*(i+1));
}
BOOST_CHECK(!pd1.try_assign(pd3));
for (std::size_t i = 0; i < 3; i++) {
BOOST_CHECK(pd1.pressure[i] == 10*(i+1));
}
}