cosmetics

This commit is contained in:
Arne Morten Kvarving 2023-02-15 08:46:32 +01:00
parent b7a531b93a
commit d9c801033a

View File

@ -74,7 +74,9 @@ PackUnpackXConn::PackUnpackXConn(const bool isOwner,
: local_ (local) : local_ (local)
, global_(global) , global_(global)
{ {
if (! isOwner) { return; } if (! isOwner) {
return;
}
this->global_.insert(this->global_.end(), this->global_.insert(this->global_.end(),
this->local_.begin(), this->local_.begin(),
@ -170,7 +172,14 @@ void WellState::initSingleProducer(const Well& well,
const auto& pu = this->phase_usage_; const auto& pu = this->phase_usage_;
const double temp = 273.15 + 15.56; const double temp = 273.15 + 15.56;
auto& ws = this->wells_.add(well.name(), SingleWellState{well.name(), well_info, true, pressure_first_connection, well_perf_data, pu, temp}); auto& ws = this->wells_.add(well.name(),
SingleWellState{well.name(),
well_info,
true,
pressure_first_connection,
well_perf_data,
pu,
temp});
// the rest of the code needs to executed even if ws.perf_data is empty // the rest of the code needs to executed even if ws.perf_data is empty
// as this does not say anything for the whole well if it is distributed. // as this does not say anything for the whole well if it is distributed.
@ -182,7 +191,6 @@ void WellState::initSingleProducer(const Well& well,
ws.update_producer_targets(well, summary_state); ws.update_producer_targets(well, summary_state);
} }
void WellState::initSingleInjector(const Well& well, void WellState::initSingleInjector(const Well& well,
const ParallelWellInfo& well_info, const ParallelWellInfo& well_info,
double pressure_first_connection, double pressure_first_connection,
@ -192,7 +200,13 @@ void WellState::initSingleInjector(const Well& well,
const auto& pu = this->phase_usage_; const auto& pu = this->phase_usage_;
const double temp = well.temperature(); const double temp = well.temperature();
auto& ws = this->wells_.add(well.name(), SingleWellState{well.name(), well_info, false, pressure_first_connection, well_perf_data, pu, temp}); auto& ws = this->wells_.add(well.name(), SingleWellState{well.name(),
well_info,
false,
pressure_first_connection,
well_perf_data,
pu,
temp});
// the rest of the code needs to executed even if ws.perf_data is empty // the rest of the code needs to executed even if ws.perf_data is empty
// as this does not say anything for the whole well if it is distributed. // as this does not say anything for the whole well if it is distributed.
@ -204,8 +218,6 @@ void WellState::initSingleInjector(const Well& well,
ws.update_injector_targets(well, summary_state); ws.update_injector_targets(well, summary_state);
} }
void WellState::initSingleWell(const std::vector<double>& cellPressures, void WellState::initSingleWell(const std::vector<double>& cellPressures,
const Well& well, const Well& well,
const std::vector<PerforationData>& well_perf_data, const std::vector<PerforationData>& well_perf_data,
@ -217,13 +229,15 @@ void WellState::initSingleWell(const std::vector<double>& cellPressures,
pressure_first_connection = cellPressures[well_perf_data[0].cell_index]; pressure_first_connection = cellPressures[well_perf_data[0].cell_index];
pressure_first_connection = well_info.broadcastFirstPerforationValue(pressure_first_connection); pressure_first_connection = well_info.broadcastFirstPerforationValue(pressure_first_connection);
if (well.isInjector()) if (well.isInjector()) {
this->initSingleInjector(well, well_info, pressure_first_connection, well_perf_data, summary_state); this->initSingleInjector(well, well_info, pressure_first_connection,
else well_perf_data, summary_state);
this->initSingleProducer(well, well_info, pressure_first_connection, well_perf_data, summary_state); } else {
this->initSingleProducer(well, well_info, pressure_first_connection,
well_perf_data, summary_state);
}
} }
void WellState::init(const std::vector<double>& cellPressures, void WellState::init(const std::vector<double>& cellPressures,
const Schedule& schedule, const Schedule& schedule,
const std::vector<Well>& wells_ecl, const std::vector<Well>& wells_ecl,
@ -234,8 +248,11 @@ void WellState::init(const std::vector<double>& cellPressures,
const SummaryState& summary_state) const SummaryState& summary_state)
{ {
// call init on base class // call init on base class
this->base_init(cellPressures, wells_ecl, parallel_well_info, well_perf_data, summary_state); this->base_init(cellPressures, wells_ecl, parallel_well_info,
this->global_well_info = std::make_optional<GlobalWellInfo>( schedule, report_step, wells_ecl ); well_perf_data, summary_state);
this->global_well_info = std::make_optional<GlobalWellInfo>(schedule,
report_step,
wells_ecl);
for (const auto& wname : schedule.wellNames(report_step)) for (const auto& wname : schedule.wellNames(report_step))
{ {
well_rates.insert({wname, std::make_pair(false, std::vector<double>(this->numPhases()))}); well_rates.insert({wname, std::make_pair(false, std::vector<double>(this->numPhases()))});
@ -475,14 +492,14 @@ WellState::report(const int* globalCellIdxMap,
well.thp = ws.thp; well.thp = ws.thp;
well.temperature = ws.temperature; well.temperature = ws.temperature;
if( pu.phase_used[BlackoilPhases::Aqua] ) { if (pu.phase_used[BlackoilPhases::Aqua]) {
well.rates.set(rt::wat, wv[ pu.phase_pos[BlackoilPhases::Aqua] ] ); well.rates.set(rt::wat, wv[ pu.phase_pos[BlackoilPhases::Aqua] ] );
well.rates.set(rt::reservoir_water, reservoir_rates[pu.phase_pos[BlackoilPhases::Aqua]]); well.rates.set(rt::reservoir_water, reservoir_rates[pu.phase_pos[BlackoilPhases::Aqua]]);
well.rates.set(rt::productivity_index_water, wpi[pu.phase_pos[BlackoilPhases::Aqua]]); well.rates.set(rt::productivity_index_water, wpi[pu.phase_pos[BlackoilPhases::Aqua]]);
well.rates.set(rt::well_potential_water, well_potentials[pu.phase_pos[BlackoilPhases::Aqua]]); well.rates.set(rt::well_potential_water, well_potentials[pu.phase_pos[BlackoilPhases::Aqua]]);
} }
if( pu.phase_used[BlackoilPhases::Liquid] ) { if (pu.phase_used[BlackoilPhases::Liquid]) {
well.rates.set(rt::oil, wv[ pu.phase_pos[BlackoilPhases::Liquid] ] ); well.rates.set(rt::oil, wv[ pu.phase_pos[BlackoilPhases::Liquid] ] );
well.rates.set(rt::reservoir_oil, reservoir_rates[pu.phase_pos[BlackoilPhases::Liquid]]); well.rates.set(rt::reservoir_oil, reservoir_rates[pu.phase_pos[BlackoilPhases::Liquid]]);
well.rates.set(rt::productivity_index_oil, wpi[pu.phase_pos[BlackoilPhases::Liquid]]); well.rates.set(rt::productivity_index_oil, wpi[pu.phase_pos[BlackoilPhases::Liquid]]);
@ -548,7 +565,6 @@ WellState::report(const int* globalCellIdxMap,
return res; return res;
} }
void WellState::reportConnections(std::vector<data::Connection>& connections, void WellState::reportConnections(std::vector<data::Connection>& connections,
const PhaseUsage &pu, const PhaseUsage &pu,
std::size_t well_index, std::size_t well_index,
@ -560,7 +576,7 @@ void WellState::reportConnections(std::vector<data::Connection>& connections,
connections.resize(num_perf_well); 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 = perf_data.cell_index[i]; 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];
@ -572,40 +588,40 @@ void WellState::reportConnections(std::vector<data::Connection>& connections,
const int np = pu.num_phases; const int np = pu.num_phases;
std::vector< rt > phs( np ); std::vector< rt > phs( np );
std::vector<rt> pi(np); std::vector<rt> pi(np);
if( pu.phase_used[Water] ) { if (pu.phase_used[Water]) {
phs.at( pu.phase_pos[Water] ) = rt::wat; phs.at( pu.phase_pos[Water] ) = rt::wat;
pi .at( pu.phase_pos[Water] ) = rt::productivity_index_water; pi .at( pu.phase_pos[Water] ) = rt::productivity_index_water;
} }
if( pu.phase_used[Oil] ) { if (pu.phase_used[Oil]) {
phs.at( pu.phase_pos[Oil] ) = rt::oil; phs.at( pu.phase_pos[Oil] ) = rt::oil;
pi .at( pu.phase_pos[Oil] ) = rt::productivity_index_oil; pi .at( pu.phase_pos[Oil] ) = rt::productivity_index_oil;
} }
if( pu.phase_used[Gas] ) { if (pu.phase_used[Gas]) {
phs.at( pu.phase_pos[Gas] ) = rt::gas; phs.at( pu.phase_pos[Gas] ) = rt::gas;
pi .at( pu.phase_pos[Gas] ) = rt::productivity_index_gas; pi .at( pu.phase_pos[Gas] ) = rt::productivity_index_gas;
} }
size_t local_conn_index = 0; size_t local_conn_index = 0;
for( auto& comp : connections) { for (auto& comp : connections) {
const auto * rates = &perf_data.phase_rates[np * local_conn_index]; const auto * rates = &perf_data.phase_rates[np * local_conn_index];
const auto * connPI = &perf_data.prod_index[np * local_conn_index]; const auto * connPI = &perf_data.prod_index[np * local_conn_index];
for( int i = 0; i < np; ++i ) { for (int i = 0; i < np; ++i) {
comp.rates.set( phs[ i ], rates[i] ); comp.rates.set( phs[ i ], rates[i] );
comp.rates.set( pi [ i ], connPI[i] ); comp.rates.set( pi [ i ], connPI[i] );
} }
if ( pu.has_polymer ) { if (pu.has_polymer) {
const auto& perf_polymer_rate = perf_data.polymer_rates; const auto& perf_polymer_rate = perf_data.polymer_rates;
comp.rates.set( rt::polymer, perf_polymer_rate[local_conn_index]); comp.rates.set( rt::polymer, perf_polymer_rate[local_conn_index]);
} }
if ( pu.has_brine ) { if (pu.has_brine) {
const auto& perf_brine_rate = perf_data.brine_rates; const auto& perf_brine_rate = perf_data.brine_rates;
comp.rates.set( rt::brine, perf_brine_rate[local_conn_index]); comp.rates.set( rt::brine, perf_brine_rate[local_conn_index]);
} }
if ( pu.has_solvent ) { if (pu.has_solvent) {
const auto& perf_solvent_rate = perf_data.solvent_rates; const auto& perf_solvent_rate = perf_data.solvent_rates;
comp.rates.set( rt::solvent, perf_solvent_rate[local_conn_index] ); comp.rates.set( rt::solvent, perf_solvent_rate[local_conn_index] );
} }
@ -631,7 +647,7 @@ void WellState::initWellStateMSWell(const std::vector<Well>& wells_ecl,
const auto& well_ecl = wells_ecl[w]; const auto& well_ecl = wells_ecl[w];
auto& ws = this->well(w); auto& ws = this->well(w);
if ( well_ecl.isMultiSegment() ) { if (well_ecl.isMultiSegment()) {
const WellSegments& segment_set = well_ecl.getSegments(); const WellSegments& segment_set = well_ecl.getSegments();
// assuming the order of the perforations in well_ecl is the same with Wells // assuming the order of the perforations in well_ecl is the same with Wells
const WellConnections& completion_set = well_ecl.getConnections(); const WellConnections& completion_set = well_ecl.getConnections();
@ -647,7 +663,7 @@ void WellState::initWellStateMSWell(const std::vector<Well>& wells_ecl,
const Connection& connection = completion_set.get(perf); const Connection& connection = completion_set.get(perf);
if (connection.state() == Connection::State::OPEN) { if (connection.state() == Connection::State::OPEN) {
const int segment_index = segment_set.segmentNumberToIndex(connection.segment()); const int segment_index = segment_set.segmentNumberToIndex(connection.segment());
if ( segment_index == -1) { if (segment_index == -1) {
OPM_THROW(std::logic_error, OPM_THROW(std::logic_error,
fmt::format("COMPSEGS: Well {} has connection in cell {}, {}, {} " fmt::format("COMPSEGS: Well {} has connection in cell {}, {}, {} "
"without associated segment.", well_ecl.name(), "without associated segment.", well_ecl.name(),
@ -672,7 +688,6 @@ void WellState::initWellStateMSWell(const std::vector<Well>& wells_ecl,
} }
} }
auto& perf_data = ws.perf_data; auto& perf_data = ws.perf_data;
// for the seg_rates_, now it becomes a recursive solution procedure. // for the seg_rates_, now it becomes a recursive solution procedure.
if (pu.phase_used[Gas]) { if (pu.phase_used[Gas]) {
@ -702,7 +717,7 @@ void WellState::initWellStateMSWell(const std::vector<Well>& wells_ecl,
segment_pressure[0] = ws.bhp; segment_pressure[0] = ws.bhp;
const auto& perf_press = perf_data.pressure; const auto& perf_press = perf_data.pressure;
for (int seg = 1; seg < well_nseg; ++seg) { for (int seg = 1; seg < well_nseg; ++seg) {
if ( !segment_perforations[seg].empty() ) { if (!segment_perforations[seg].empty()) {
const int first_perf = segment_perforations[seg][0]; const int first_perf = segment_perforations[seg][0];
segment_pressure[seg] = perf_press[first_perf]; segment_pressure[seg] = perf_press[first_perf];
} else { } else {
@ -723,7 +738,7 @@ void WellState::initWellStateMSWell(const std::vector<Well>& wells_ecl,
if (well.getStatus() == Well::Status::SHUT) if (well.getStatus() == Well::Status::SHUT)
continue; continue;
if ( !well.isMultiSegment() ) if (!well.isMultiSegment())
continue; continue;
const auto& wname = well.name(); const auto& wname = well.name();
@ -746,7 +761,7 @@ void WellState::initWellStateMSWell(const std::vector<Well>& wells_ecl,
void void
WellState::calculateSegmentRates(const std::vector<std::vector<int>>& segment_inlets, WellState::calculateSegmentRates(const std::vector<std::vector<int>>& segment_inlets,
const std::vector<std::vector<int>>&segment_perforations, const std::vector<std::vector<int>>& segment_perforations,
const std::vector<double>& perforation_rates, const std::vector<double>& perforation_rates,
const int np, const int segment, const int np, const int segment,
std::vector<double>& segment_rates) std::vector<double>& segment_rates)
@ -796,8 +811,6 @@ void WellState::updateStatus(int well_index, WellStatus status)
ws.updateStatus(status); ws.updateStatus(status);
} }
template<class Comm> template<class Comm>
void WellState::communicateGroupRates(const Comm& comm) void WellState::communicateGroupRates(const Comm& comm)
{ {
@ -843,7 +856,6 @@ void WellState::communicateGroupRates(const Comm& comm)
assert(pos == sz); assert(pos == sz);
} }
template<class Comm> template<class Comm>
void WellState::updateGlobalIsGrup(const Comm& comm) void WellState::updateGlobalIsGrup(const Comm& comm)
{ {
@ -946,9 +958,7 @@ bool WellState::wellIsOwned(const std::string& wellName) const
return wellIsOwned(well_index.value(), wellName); return wellIsOwned(well_index.value(), wellName);
} }
void WellState::updateWellsDefaultALQ(const std::vector<Well>& wells_ecl)
void WellState::updateWellsDefaultALQ( const std::vector<Well>& wells_ecl )
{ {
const int nw = wells_ecl.size(); const int nw = wells_ecl.size();
for (int i = 0; i<nw; i++) { for (int i = 0; i<nw; i++) {
@ -968,7 +978,6 @@ bool WellState::operator==(const WellState& rhs) const
this->wells_ == rhs.wells_; this->wells_ == rhs.wells_;
} }
const ParallelWellInfo& const ParallelWellInfo&
WellState::parallelWellInfo(std::size_t well_index) const WellState::parallelWellInfo(std::size_t well_index) const
{ {