mirror of
https://github.com/OPM/opm-simulators.git
synced 2025-02-25 18:55:30 -06:00
Merge two perforation data members in WellState
This commit is contained in:
parent
1cbc096d20
commit
f01cf74591
@ -24,16 +24,20 @@ namespace Opm
|
|||||||
{
|
{
|
||||||
|
|
||||||
|
|
||||||
PerfData::PerfData(std::size_t num_perf, bool injector_, const PhaseUsage& pu_arg):
|
PerfData::PerfData(std::size_t num_perf, bool injector_, const PhaseUsage& pu_arg)
|
||||||
pu(pu_arg),
|
: pu(pu_arg)
|
||||||
injector(injector_),
|
, injector(injector_)
|
||||||
pressure(num_perf),
|
, pressure(num_perf)
|
||||||
rates(num_perf),
|
, rates(num_perf)
|
||||||
phase_rates(num_perf * pu.num_phases),
|
, phase_rates(num_perf * pu.num_phases)
|
||||||
solvent_rates(num_perf),
|
, solvent_rates(num_perf)
|
||||||
polymer_rates(num_perf),
|
, polymer_rates(num_perf)
|
||||||
brine_rates(num_perf),
|
, brine_rates(num_perf)
|
||||||
prod_index(num_perf * pu.num_phases)
|
, prod_index(num_perf * pu.num_phases)
|
||||||
|
, cell_index(num_perf)
|
||||||
|
, connection_transmissibility_factor(num_perf)
|
||||||
|
, satnum_id(num_perf)
|
||||||
|
, ecl_index(num_perf)
|
||||||
{
|
{
|
||||||
if (injector) {
|
if (injector) {
|
||||||
this->water_throughput.resize(num_perf);
|
this->water_throughput.resize(num_perf);
|
||||||
|
@ -48,6 +48,12 @@ public:
|
|||||||
std::vector<double> brine_rates;
|
std::vector<double> brine_rates;
|
||||||
std::vector<double> prod_index;
|
std::vector<double> prod_index;
|
||||||
|
|
||||||
|
std::vector<std::size_t> cell_index;
|
||||||
|
std::vector<double> connection_transmissibility_factor;
|
||||||
|
std::vector<int> satnum_id;
|
||||||
|
std::vector<std::size_t> ecl_index;
|
||||||
|
|
||||||
|
|
||||||
// The water_throughput, skin_pressure and water_velocity variables are only
|
// The water_throughput, skin_pressure and water_velocity variables are only
|
||||||
// used for injectors to check the injectivity.
|
// used for injectors to check the injectivity.
|
||||||
std::vector<double> water_throughput;
|
std::vector<double> water_throughput;
|
||||||
|
@ -42,7 +42,6 @@ void WellState::base_init(const std::vector<double>& cellPressures,
|
|||||||
this->wellMap_.clear();
|
this->wellMap_.clear();
|
||||||
this->perfdata.clear();
|
this->perfdata.clear();
|
||||||
this->status_.clear();
|
this->status_.clear();
|
||||||
this->well_perf_data_.clear();
|
|
||||||
this->parallel_well_info_.clear();
|
this->parallel_well_info_.clear();
|
||||||
this->wellrates_.clear();
|
this->wellrates_.clear();
|
||||||
this->bhp_.clear();
|
this->bhp_.clear();
|
||||||
@ -94,11 +93,10 @@ void WellState::initSingleWell(const std::vector<double>& cellPressures,
|
|||||||
const int np = pu.num_phases;
|
const int np = pu.num_phases;
|
||||||
|
|
||||||
this->status_.add(well.name(), Well::Status::OPEN);
|
this->status_.add(well.name(), Well::Status::OPEN);
|
||||||
this->well_perf_data_.add(well.name(), well_perf_data);
|
|
||||||
this->parallel_well_info_.add(well.name(), well_info);
|
this->parallel_well_info_.add(well.name(), well_info);
|
||||||
this->wellrates_.add(well.name(), std::vector<double>(np, 0));
|
this->wellrates_.add(well.name(), std::vector<double>(np, 0));
|
||||||
this->well_potentials_.add(well.name(), std::vector<double>(np, 0));
|
this->well_potentials_.add(well.name(), std::vector<double>(np, 0));
|
||||||
const int num_perf_this_well = well_info->communication().sum(well_perf_data_[w].size());
|
const int num_perf_this_well = well_info->communication().sum(well_perf_data.size());
|
||||||
this->segment_state.add(well.name(), SegmentState{});
|
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_});
|
this->perfdata.add(well.name(), PerfData{static_cast<std::size_t>(num_perf_this_well), well.isInjector(), this->phase_usage_});
|
||||||
this->bhp_.add(well.name(), 0.0);
|
this->bhp_.add(well.name(), 0.0);
|
||||||
@ -123,8 +121,8 @@ void WellState::initSingleWell(const std::vector<double>& cellPressures,
|
|||||||
|
|
||||||
const double inj_surf_rate = well.isInjector() ? inj_controls.surface_rate : 0.0; // To avoid a "maybe-uninitialized" warning.
|
const double inj_surf_rate = well.isInjector() ? inj_controls.surface_rate : 0.0; // To avoid a "maybe-uninitialized" warning.
|
||||||
|
|
||||||
const double local_pressure = well_perf_data_[w].empty() ?
|
const double local_pressure = well_perf_data.empty() ?
|
||||||
0 : cellPressures[well_perf_data_[w][0].cell_index];
|
0 : cellPressures[well_perf_data[0].cell_index];
|
||||||
const double global_pressure = well_info->broadcastFirstPerforationValue(local_pressure);
|
const double global_pressure = well_info->broadcastFirstPerforationValue(local_pressure);
|
||||||
|
|
||||||
if (well.getStatus() == Well::Status::OPEN) {
|
if (well.getStatus() == Well::Status::OPEN) {
|
||||||
@ -288,8 +286,14 @@ void WellState::init(const std::vector<double>& cellPressures,
|
|||||||
const int num_perf_this_well = well_info[2];
|
const int num_perf_this_well = well_info[2];
|
||||||
const int global_num_perf_this_well = ecl_well.getConnections().num_open();
|
const int global_num_perf_this_well = ecl_well.getConnections().num_open();
|
||||||
auto& perf_data = this->perfData(w);
|
auto& perf_data = this->perfData(w);
|
||||||
|
const auto& perf_input = well_perf_data[w];
|
||||||
|
|
||||||
for (int perf = 0; perf < num_perf_this_well; ++perf) {
|
for (int perf = 0; perf < num_perf_this_well; ++perf) {
|
||||||
|
perf_data.cell_index[perf] = perf_input[perf].cell_index;
|
||||||
|
perf_data.connection_transmissibility_factor[perf] = perf_input[perf].connection_transmissibility_factor;
|
||||||
|
perf_data.satnum_id[perf] = perf_input[perf].satnum_id;
|
||||||
|
perf_data.ecl_index[perf] = perf_input[perf].ecl_index;
|
||||||
|
|
||||||
if (wells_ecl[w].getStatus() == Well::Status::OPEN) {
|
if (wells_ecl[w].getStatus() == Well::Status::OPEN) {
|
||||||
for (int p = 0; p < this->numPhases(); ++p) {
|
for (int p = 0; p < this->numPhases(); ++p) {
|
||||||
perf_data.phase_rates[this->numPhases()*perf + p] = wellRates(w)[p] / double(global_num_perf_this_well);
|
perf_data.phase_rates[this->numPhases()*perf + p] = wellRates(w)[p] / double(global_num_perf_this_well);
|
||||||
@ -601,19 +605,18 @@ void WellState::reportConnections(std::vector<data::Connection>& connections,
|
|||||||
const int* globalCellIdxMap) const
|
const int* globalCellIdxMap) const
|
||||||
{
|
{
|
||||||
using rt = data::Rates::opt;
|
using rt = data::Rates::opt;
|
||||||
const auto& pd = this->well_perf_data_[well_index];
|
|
||||||
const int num_perf_well = pd.size();
|
|
||||||
connections.resize(num_perf_well);
|
|
||||||
const auto& perf_data = this->perfData(well_index);
|
const auto& perf_data = this->perfData(well_index);
|
||||||
|
const int num_perf_well = perf_data.size();
|
||||||
|
connections.resize(num_perf_well);
|
||||||
const auto& perf_rates = perf_data.rates;
|
const auto& perf_rates = perf_data.rates;
|
||||||
const auto& perf_pressure = perf_data.pressure;
|
const auto& perf_pressure = perf_data.pressure;
|
||||||
for( int i = 0; i < num_perf_well; ++i ) {
|
for( int i = 0; i < num_perf_well; ++i ) {
|
||||||
const auto active_index = this->well_perf_data_[well_index][i].cell_index;
|
const auto active_index = perf_data.cell_index[i];
|
||||||
auto& connection = connections[ i ];
|
auto& connection = connections[ i ];
|
||||||
connection.index = globalCellIdxMap[active_index];
|
connection.index = globalCellIdxMap[active_index];
|
||||||
connection.pressure = perf_pressure[i];
|
connection.pressure = perf_pressure[i];
|
||||||
connection.reservoir_rate = perf_rates[i];
|
connection.reservoir_rate = perf_rates[i];
|
||||||
connection.trans_factor = pd[i].connection_transmissibility_factor;
|
connection.trans_factor = perf_data.connection_transmissibility_factor[i];
|
||||||
}
|
}
|
||||||
assert(num_perf_well == int(connections.size()));
|
assert(num_perf_well == int(connections.size()));
|
||||||
|
|
||||||
@ -659,7 +662,7 @@ void WellState::reportConnections(std::vector<data::Connection>& connections,
|
|||||||
|
|
||||||
++local_comp_index;
|
++local_comp_index;
|
||||||
}
|
}
|
||||||
assert(local_comp_index == this->well_perf_data_[well_index].size());
|
assert(local_comp_index == this->perfdata[well_index].size());
|
||||||
}
|
}
|
||||||
|
|
||||||
void WellState::initWellStateMSWell(const std::vector<Well>& wells_ecl,
|
void WellState::initWellStateMSWell(const std::vector<Well>& wells_ecl,
|
||||||
@ -1032,41 +1035,37 @@ void WellState::updateWellsDefaultALQ( const std::vector<Well>& wells_ecl )
|
|||||||
}
|
}
|
||||||
|
|
||||||
void WellState::resetConnectionTransFactors(const int well_index,
|
void WellState::resetConnectionTransFactors(const int well_index,
|
||||||
const std::vector<PerforationData>& well_perf_data)
|
const std::vector<PerforationData>& new_perf_data)
|
||||||
{
|
{
|
||||||
if (this->well_perf_data_[well_index].size() != well_perf_data.size()) {
|
if (this->perfdata[well_index].size() != new_perf_data.size()) {
|
||||||
throw std::invalid_argument {
|
throw std::invalid_argument {
|
||||||
"Size mismatch for perforation data in well "
|
"Size mismatch for perforation data in well "
|
||||||
+ std::to_string(well_index)
|
+ std::to_string(well_index)
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
auto connID = std::size_t{0};
|
auto& perf_data = this->perfData(well_index);
|
||||||
auto dst = this->well_perf_data_[well_index].begin();
|
for (std::size_t conn_index = 0; conn_index < new_perf_data.size(); conn_index++) {
|
||||||
for (const auto& src : well_perf_data) {
|
|
||||||
if (dst->cell_index != src.cell_index) {
|
if (perf_data.cell_index[conn_index] != static_cast<std::size_t>(new_perf_data[conn_index].cell_index)) {
|
||||||
throw std::invalid_argument {
|
throw std::invalid_argument {
|
||||||
"Cell index mismatch in connection "
|
"Cell index mismatch in connection "
|
||||||
+ std::to_string(connID)
|
+ std::to_string(conn_index)
|
||||||
+ " of well "
|
+ " of well "
|
||||||
+ std::to_string(well_index)
|
+ std::to_string(well_index)
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
if (dst->satnum_id != src.satnum_id) {
|
if (perf_data.satnum_id[conn_index] != new_perf_data[conn_index].satnum_id) {
|
||||||
throw std::invalid_argument {
|
throw std::invalid_argument {
|
||||||
"Saturation function table mismatch in connection "
|
"Saturation function table mismatch in connection "
|
||||||
+ std::to_string(connID)
|
+ std::to_string(conn_index)
|
||||||
+ " of well "
|
+ " of well "
|
||||||
+ std::to_string(well_index)
|
+ std::to_string(well_index)
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
dst->connection_transmissibility_factor =
|
perf_data.connection_transmissibility_factor[conn_index] = new_perf_data[conn_index].connection_transmissibility_factor;
|
||||||
src.connection_transmissibility_factor;
|
|
||||||
|
|
||||||
++dst;
|
|
||||||
++connID;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -363,7 +363,6 @@ private:
|
|||||||
bool do_glift_optimization_;
|
bool do_glift_optimization_;
|
||||||
|
|
||||||
WellContainer<Well::Status> status_;
|
WellContainer<Well::Status> status_;
|
||||||
WellContainer<std::vector<PerforationData>> well_perf_data_;
|
|
||||||
WellContainer<const ParallelWellInfo*> parallel_well_info_;
|
WellContainer<const ParallelWellInfo*> parallel_well_info_;
|
||||||
WellContainer<double> bhp_;
|
WellContainer<double> bhp_;
|
||||||
WellContainer<double> thp_;
|
WellContainer<double> thp_;
|
||||||
|
Loading…
Reference in New Issue
Block a user