Initialize static perforation data in SingleWellState constructor

This commit is contained in:
Joakim Hove 2021-10-31 10:03:21 +01:00
parent 6c16b5dbb8
commit d213bc9d78
4 changed files with 20 additions and 15 deletions

View File

@ -18,10 +18,11 @@
*/
#include <opm/simulators/wells/SingleWellState.hpp>
#include <opm/simulators/wells/PerforationData.hpp>
namespace Opm {
SingleWellState::SingleWellState(const std::string& name_, const ParallelWellInfo& pinfo, bool is_producer, std::size_t num_perf, std::size_t num_phases, double temp)
SingleWellState::SingleWellState(const std::string& name_, const ParallelWellInfo& pinfo, bool is_producer, const std::vector<PerforationData>& perf_input, std::size_t num_phases, double temp)
: name(name_)
, parallel_info(pinfo)
, producer(is_producer)
@ -30,8 +31,15 @@ SingleWellState::SingleWellState(const std::string& name_, const ParallelWellInf
, productivity_index(num_phases)
, surface_rates(num_phases)
, reservoir_rates(num_phases)
, perf_data(num_perf, !is_producer, num_phases)
{}
, perf_data(perf_input.size(), !is_producer, num_phases)
{
for (std::size_t perf = 0; perf < perf_input.size(); perf++) {
this->perf_data.cell_index[perf] = perf_input[perf].cell_index;
this->perf_data.connection_transmissibility_factor[perf] = perf_input[perf].connection_transmissibility_factor;
this->perf_data.satnum_id[perf] = perf_input[perf].satnum_id;
this->perf_data.ecl_index[perf] = perf_input[perf].ecl_index;
}
}
void SingleWellState::init_timestep(const SingleWellState& other) {

View File

@ -31,9 +31,11 @@
namespace Opm {
struct PerforationData;
class SingleWellState {
public:
SingleWellState(const std::string& name, const ParallelWellInfo& pinfo, bool is_producer, std::size_t num_perf, std::size_t num_phases, double temp);
SingleWellState(const std::string& name, const ParallelWellInfo& pinfo, bool is_producer, const std::vector<PerforationData>& perf_input, std::size_t num_phases, double temp);
std::string name;
std::reference_wrapper<const ParallelWellInfo> parallel_info;

View File

@ -72,7 +72,7 @@ void WellState::initSingleWell(const std::vector<double>& cellPressures,
const auto inj_controls = well.isInjector() ? well.injectionControls(summary_state) : Well::InjectionControls(0);
double temp = well.isInjector() ? inj_controls.temperature : 273.15 + 15.56;
auto& ws = this->wells_.add(well.name(), SingleWellState{well.name(), well_info, well.isProducer(), well_perf_data.size(), static_cast<std::size_t>(np), temp});
auto& ws = this->wells_.add(well.name(), SingleWellState{well.name(), well_info, well.isProducer(), well_perf_data, static_cast<std::size_t>(np), temp});
if ( ws.perf_data.empty())
return;
@ -83,7 +83,7 @@ void WellState::initSingleWell(const std::vector<double>& cellPressures,
const double bhp_limit = well.isInjector() ? inj_controls.bhp_limit : prod_controls.bhp_limit;
const double inj_surf_rate = well.isInjector() ? inj_controls.surface_rate : 0.0; // To avoid a "maybe-uninitialized" warning.
const double global_pressure = well_info.broadcastFirstPerforationValue(cellPressures[well_perf_data[0].cell_index]);
const double global_pressure = well_info.broadcastFirstPerforationValue(cellPressures[ws.perf_data.cell_index[0]]);
if (well.getStatus() == Well::Status::OPEN) {
ws.status = Well::Status::OPEN;
@ -240,14 +240,8 @@ void WellState::init(const std::vector<double>& cellPressures,
auto& perf_data = ws.perf_data;
const int num_perf_this_well = perf_data.size();
const int global_num_perf_this_well = ecl_well.getConnections().num_open();
const auto& perf_input = well_perf_data[w];
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) {
for (int p = 0; p < this->numPhases(); ++p) {
perf_data.phase_rates[this->numPhases()*perf + p] = ws.surface_rates[p] / double(global_num_perf_this_well);

View File

@ -574,9 +574,10 @@ BOOST_AUTO_TEST_CASE(TESTPerfData) {
BOOST_AUTO_TEST_CASE(TestSingleWellState) {
Opm::ParallelWellInfo pinfo;
Opm::SingleWellState ws1("W1", pinfo, true, 10, 3, 1);
Opm::SingleWellState ws2("W2", pinfo, true, 10, 3, 2);
Opm::SingleWellState ws3("W3", pinfo, false, 10, 3, 3);
std::vector<Opm::PerforationData> connections = {{0,1,1,0},{1,1,1,1},{2,1,1,2}};
Opm::SingleWellState ws1("W1", pinfo, true, connections, 3, 1);
Opm::SingleWellState ws2("W2", pinfo, true, connections, 3, 2);
Opm::SingleWellState ws3("W3", pinfo, false, connections, 3, 3);
ws1.bhp = 100;
ws1.thp = 200;