diff --git a/opm/simulators/wells/PerfData.cpp b/opm/simulators/wells/PerfData.cpp index 121886c29..5d822d9e3 100644 --- a/opm/simulators/wells/PerfData.cpp +++ b/opm/simulators/wells/PerfData.cpp @@ -24,20 +24,22 @@ namespace Opm { -PerfData::PerfData(std::size_t num_perf, const PhaseUsage& pu_arg): +PerfData::PerfData(std::size_t num_perf, bool injector_, const PhaseUsage& pu_arg): pu(pu_arg), + injector(injector_), pressure(num_perf), rates(num_perf), phase_rates(num_perf * pu.num_phases), solvent_rates(num_perf), polymer_rates(num_perf), brine_rates(num_perf), - prod_index(num_perf * pu.num_phases), - water_throughput(num_perf), - skin_pressure(num_perf), - water_velocity(num_perf) + prod_index(num_perf * pu.num_phases) { - + if (injector) { + this->water_throughput.resize(num_perf); + this->skin_pressure.resize(num_perf); + this->water_velocity.resize(num_perf); + } } std::size_t PerfData::size() const { @@ -48,6 +50,9 @@ bool PerfData::try_assign(const PerfData& other) { if (this->size() != other.size()) return false; + if (this->injector != other.injector) + return false; + this->pressure = other.pressure; this->rates = other.rates; this->phase_rates = other.phase_rates; @@ -58,7 +63,6 @@ bool PerfData::try_assign(const PerfData& other) { this->skin_pressure = other.skin_pressure; this->water_velocity = other.water_velocity; this->prod_index = other.prod_index; - return true; } diff --git a/opm/simulators/wells/PerfData.hpp b/opm/simulators/wells/PerfData.hpp index 4187e7475..b663bfe72 100644 --- a/opm/simulators/wells/PerfData.hpp +++ b/opm/simulators/wells/PerfData.hpp @@ -32,9 +32,10 @@ class PerfData { private: PhaseUsage pu; + bool injector; public: - PerfData(std::size_t num_perf, const PhaseUsage& pu); + PerfData(std::size_t num_perf, bool injector_, const PhaseUsage& pu); std::size_t size() const; bool try_assign(const PerfData& other); diff --git a/opm/simulators/wells/WellState.cpp b/opm/simulators/wells/WellState.cpp index efcd2ce70..c52216b6e 100644 --- a/opm/simulators/wells/WellState.cpp +++ b/opm/simulators/wells/WellState.cpp @@ -100,7 +100,7 @@ void WellState::initSingleWell(const std::vector& cellPressures, this->well_potentials_.add(well.name(), std::vector(np, 0)); 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{static_cast(num_perf_this_well), this->phase_usage_}); + this->perfdata.add(well.name(), PerfData{static_cast(num_perf_this_well), well.isInjector(), this->phase_usage_}); this->bhp_.add(well.name(), 0.0); this->thp_.add(well.name(), 0.0); this->productivity_index_.add(well.name(), std::vector(np, 0)); diff --git a/tests/test_wellstate.cpp b/tests/test_wellstate.cpp index 437590fa8..eb8e921d1 100644 --- a/tests/test_wellstate.cpp +++ b/tests/test_wellstate.cpp @@ -545,9 +545,10 @@ GAS )"; Opm::PhaseUsage pu = Opm::phaseUsageFromDeck(Opm::Parser{}.parseString(deck_string)); - Opm::PerfData pd1(3,pu); - Opm::PerfData pd2(3,pu); - Opm::PerfData pd3(2,pu); + Opm::PerfData pd1(3, true, pu); + Opm::PerfData pd2(3, true, pu); + Opm::PerfData pd3(2, true, pu); + Opm::PerfData pd4(3, false, pu); for (std::size_t i = 0; i < 3; i++) { @@ -565,6 +566,8 @@ GAS for (std::size_t i = 0; i < 3; i++) { BOOST_CHECK(pd1.pressure[i] == 10*(i+1)); } + + BOOST_CHECK(!pd1.try_assign(pd4)); }