diff --git a/opm/parser/eclipse/EclipseState/Schedule/Schedule.hpp b/opm/parser/eclipse/EclipseState/Schedule/Schedule.hpp index ef22bf7df..55c6653ad 100644 --- a/opm/parser/eclipse/EclipseState/Schedule/Schedule.hpp +++ b/opm/parser/eclipse/EclipseState/Schedule/Schedule.hpp @@ -193,7 +193,6 @@ namespace Opm const TimeMap& getTimeMap() const; - PAvgCalculatorCollection pavg_calculators(const EclipseGrid& grid, const std::unordered_set& wells, std::size_t report_step) const; std::size_t numWells() const; std::size_t numWells(std::size_t timestep) const; bool hasWell(const std::string& wellName) const; diff --git a/opm/parser/eclipse/EclipseState/Schedule/Well/PAvgCalculator.hpp b/opm/parser/eclipse/EclipseState/Schedule/Well/PAvgCalculator.hpp index 38c5be723..3b0678bf1 100644 --- a/opm/parser/eclipse/EclipseState/Schedule/Well/PAvgCalculator.hpp +++ b/opm/parser/eclipse/EclipseState/Schedule/Well/PAvgCalculator.hpp @@ -37,7 +37,7 @@ class Serializer; class PAvgCalculator { public: - PAvgCalculator(const std::string& well, const EclipseGrid& grid, const WellConnections& connections, const PAvg& pavg); + PAvgCalculator(const std::string& well, const EclipseGrid& grid, const std::vector& porv, const WellConnections& connections, const PAvg& pavg); enum class WBPMode { WBP, diff --git a/opm/parser/eclipse/EclipseState/Schedule/Well/Well.hpp b/opm/parser/eclipse/EclipseState/Schedule/Well/Well.hpp index 11c6a4191..7a5a9cb11 100644 --- a/opm/parser/eclipse/EclipseState/Schedule/Well/Well.hpp +++ b/opm/parser/eclipse/EclipseState/Schedule/Well/Well.hpp @@ -592,7 +592,7 @@ public: void applyWellProdIndexScaling(const double scalingFactor, std::vector& scalingApplicable); const PAvg& pavg() const; - PAvgCalculator pavg_calculator(const EclipseGrid& grid) const; + PAvgCalculator pavg_calculator(const EclipseGrid& grid, const std::vector& porv) const; template void serializeOp(Serializer& serializer) diff --git a/src/opm/output/eclipse/Summary.cpp b/src/opm/output/eclipse/Summary.cpp index 9fd7fd10e..3058b28ee 100644 --- a/src/opm/output/eclipse/Summary.cpp +++ b/src/opm/output/eclipse/Summary.cpp @@ -2931,12 +2931,16 @@ internal_store(const SummaryState& st, const int report_step) } Opm::PAvgCalculatorCollection Opm::out::Summary::SummaryImplementation::wbp_calculators(std::size_t report_step) const { + if (this->wbp_wells.empty()) + return {}; + Opm::PAvgCalculatorCollection calculators; + const auto& porv = this->es_.get().globalFieldProps().porv(true); for (const auto& wname : this->wbp_wells) { if (this->sched_.get().hasWell(wname, report_step)) { const auto& well = this->sched_.get().getWell(wname, report_step); if (well.getStatus() == Opm::Well::Status::OPEN) - calculators.add(well.pavg_calculator(this->grid_)); + calculators.add(well.pavg_calculator(this->grid_, porv)); } } return calculators; diff --git a/src/opm/parser/eclipse/EclipseState/Schedule/Schedule.cpp b/src/opm/parser/eclipse/EclipseState/Schedule/Schedule.cpp index 5aad9c427..751d2525b 100644 --- a/src/opm/parser/eclipse/EclipseState/Schedule/Schedule.cpp +++ b/src/opm/parser/eclipse/EclipseState/Schedule/Schedule.cpp @@ -2049,13 +2049,4 @@ bool Schedule::cmp(const Schedule& sched1, const Schedule& sched2, std::size_t r } -PAvgCalculatorCollection Schedule::pavg_calculators(const EclipseGrid& grid, const std::unordered_set& wells, std::size_t report_step) const -{ - PAvgCalculatorCollection calculators; - for (const auto& wname : wells) { - const auto& well = this->getWell(wname, report_step); - calculators.add(well.pavg_calculator(grid)); - } - return calculators; -} } diff --git a/src/opm/parser/eclipse/EclipseState/Schedule/Well/PAvgCalculator.cpp b/src/opm/parser/eclipse/EclipseState/Schedule/Well/PAvgCalculator.cpp index df29ffdab..efe58f7db 100644 --- a/src/opm/parser/eclipse/EclipseState/Schedule/Well/PAvgCalculator.cpp +++ b/src/opm/parser/eclipse/EclipseState/Schedule/Well/PAvgCalculator.cpp @@ -54,7 +54,7 @@ const std::string& PAvgCalculator::wname() const { } -PAvgCalculator::PAvgCalculator(const std::string& well, const EclipseGrid& grid, const WellConnections& connections, const PAvg& pavg) : +PAvgCalculator::PAvgCalculator(const std::string& well, const EclipseGrid& grid, const std::vector& porv, const WellConnections& connections, const PAvg& pavg) : well_name(well), m_pavg(pavg) { @@ -62,10 +62,12 @@ PAvgCalculator::PAvgCalculator(const std::string& well, const EclipseGrid& grid, OpmLog::warning("PORV based averaging is not yet supported in WBPx"); //throw std::logic_error("The current implementation does not yet support PORV based averaging"); + if (porv.size() != grid.getCartesianSize()) + throw std::logic_error("Should pass a GLOBAL porv vector"); + for (const auto& conn : connections) { if (conn.state() == ::Opm::Connection::State::OPEN || !this->m_pavg.open_connections()) { - double porv = -1; - Connection wp_conn(porv, conn.CF(), conn.dir(), conn.global_index()); + Connection wp_conn(porv[conn.global_index()], conn.CF(), conn.dir(), conn.global_index()); this->add_connection(wp_conn); } } diff --git a/src/opm/parser/eclipse/EclipseState/Schedule/Well/Well.cpp b/src/opm/parser/eclipse/EclipseState/Schedule/Well/Well.cpp index d7790cc55..a3c5b2cff 100644 --- a/src/opm/parser/eclipse/EclipseState/Schedule/Well/Well.cpp +++ b/src/opm/parser/eclipse/EclipseState/Schedule/Well/Well.cpp @@ -1644,8 +1644,8 @@ bool Well::operator==(const Well& data) const { } -PAvgCalculator Well::pavg_calculator(const EclipseGrid& grid) const { - return PAvgCalculator(this->name(), grid, this->getConnections(), this->m_pavg); +PAvgCalculator Well::pavg_calculator(const EclipseGrid& grid, const std::vector& porv) const { + return PAvgCalculator(this->name(), grid, porv, this->getConnections(), this->m_pavg); } diff --git a/tests/parser/PAvgTests.cpp b/tests/parser/PAvgTests.cpp index 3f1ac6e61..f2d00d827 100644 --- a/tests/parser/PAvgTests.cpp +++ b/tests/parser/PAvgTests.cpp @@ -195,7 +195,8 @@ END auto sched = Schedule{ deck, es }; auto summary_config = SummaryConfig{deck, sched, es.getTableManager(), es.aquifer()}; const auto& w1 = sched.getWell("P1", 0); - auto calc = w1.pavg_calculator(grid); + const auto& porv = es.globalFieldProps().porv(true); + auto calc = w1.pavg_calculator(grid, porv); { const auto& index_list = calc.index_list(); @@ -234,7 +235,7 @@ END //---------------------------------------------------- const auto& w5 = sched.getWell("P5", 0); - auto calc5 = w5.pavg_calculator(grid); + auto calc5 = w5.pavg_calculator(grid, porv); { const auto& index_list = calc5.index_list(); @@ -262,8 +263,8 @@ END // We emulate MPI and calc1 and calc2 are on two different processors { - auto calc1 = w5.pavg_calculator(grid); - auto calc2 = w5.pavg_calculator(grid); + auto calc1 = w5.pavg_calculator(grid, porv); + auto calc2 = w5.pavg_calculator(grid, porv); for (std::size_t k = 0; k < 3; k++) { calc1.add_pressure(grid.getGlobalIndex(0,0,k), 1); calc2.add_pressure(grid.getGlobalIndex(1,0,k), 2.0); @@ -285,9 +286,9 @@ END - auto calculators = sched.pavg_calculators(grid, summary_config.wbp_wells(), 0); - calculators.add(w1.pavg_calculator(grid)); - calculators.add(w5.pavg_calculator(grid)); + PAvgCalculatorCollection calculators; + calculators.add(w1.pavg_calculator(grid, porv)); + calculators.add(w5.pavg_calculator(grid, porv)); BOOST_CHECK( calculators.has("P1"));