Add member "bool producer" to SingleWellState

This commit is contained in:
Joakim Hove 2021-08-03 21:11:09 +02:00
parent a54daf75e8
commit 1dd9b91ad3
5 changed files with 25 additions and 19 deletions

View File

@ -21,8 +21,15 @@
namespace Opm {
SingleWellState::SingleWellState(bool is_producer)
: producer(is_producer)
{}
void SingleWellState::init_timestep(const SingleWellState& other) {
if (this->producer != other.producer)
return;
this->bhp = other.bhp;
this->thp = other.thp;
}

View File

@ -25,6 +25,11 @@ namespace Opm {
class SingleWellState {
public:
explicit SingleWellState(bool is_producer);
bool producer;
double bhp{0};
double thp{0};

View File

@ -91,7 +91,7 @@ void WellState::initSingleWell(const std::vector<double>& cellPressures,
const auto& pu = this->phase_usage_;
const int np = pu.num_phases;
auto& ws = this->wells_.add(well.name(), SingleWellState{});
auto& ws = this->wells_.add(well.name(), SingleWellState{well.isProducer()});
this->status_.add(well.name(), Well::Status::OPEN);
this->parallel_well_info_.add(well.name(), well_info);
this->wellrates_.add(well.name(), std::vector<double>(np, 0));
@ -305,12 +305,6 @@ void WellState::init(const std::vector<double>& cellPressures,
this->well_vaporized_oil_rates_.add(wname, 0);
}
is_producer_.clear();
for (int w = 0; w < nw; ++w) {
const auto& ecl_well = wells_ecl[w];
this->is_producer_.add( ecl_well.name(), ecl_well.isProducer());
}
current_injection_controls_.clear();
current_production_controls_.clear();
for (int w = 0; w < nw; ++w) {
@ -370,10 +364,9 @@ void WellState::init(const std::vector<double>& cellPressures,
continue;
}
if (is_producer_[newIndex] != prevState->is_producer_[oldIndex]) {
if (new_well.producer != prev_well.producer)
// Well changed to/from injector from/to producer, do not use its privious values.
continue;
}
// If new target is set using WCONPROD, WCONINJE etc. we use the new control
if (!this->events_[w].hasEvent(WellState::event_mask)) {
@ -555,7 +548,7 @@ WellState::report(const int* globalCellIdxMap,
well.rates.set(rt::brine, brineWellRate(well_index));
}
if (is_producer_[well_index]) {
if (ws.producer) {
well.rates.set(rt::alq, getALQ(wname));
}
else {
@ -568,7 +561,7 @@ WellState::report(const int* globalCellIdxMap,
{
auto& curr = well.current_control;
curr.isProducer = this->is_producer_[well_index];
curr.isProducer = ws.producer;
curr.prod = this->currentProductionControl(well_index);
curr.inj = this->currentInjectionControl(well_index);
}

View File

@ -341,10 +341,6 @@ public:
return this->status_.well_name(well_index);
}
bool producer(std::size_t well_index) const {
return this->is_producer_[well_index];
}
const SingleWellState& well(std::size_t well_index) const {
return this->wells_[well_index];
}
@ -380,8 +376,6 @@ private:
PhaseUsage phase_usage_;
WellContainer<PerfData> perfdata;
WellContainer<int> is_producer_; // Size equal to number of local wells.
// vector with size number of wells +1.
// iterate over all perforations of a given well
// for (int perf = first_perf_index_[well_index]; perf < first_perf_index_[well_index] + num_perf_[well_index]; ++perf)

View File

@ -577,8 +577,9 @@ GAS
BOOST_AUTO_TEST_CASE(TestSingleWellState) {
Opm::SingleWellState ws1;
Opm::SingleWellState ws2;
Opm::SingleWellState ws1(true);
Opm::SingleWellState ws2(true);
Opm::SingleWellState ws3(false);
ws1.bhp = 100;
ws1.thp = 200;
@ -586,6 +587,12 @@ BOOST_AUTO_TEST_CASE(TestSingleWellState) {
ws2.init_timestep(ws1);
BOOST_CHECK_EQUAL(ws2.bhp, ws1.bhp);
BOOST_CHECK_EQUAL(ws2.thp, ws1.thp);
ws3.bhp = ws1.bhp * 2;
ws3.thp = ws1.thp * 2;
ws3.init_timestep(ws1);
BOOST_CHECK(ws3.bhp != ws1.bhp);
BOOST_CHECK(ws3.thp != ws1.thp);
}