From 7df0023038ad5350a6e0112d89c7ced04fc57e46 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Atgeirr=20Fl=C3=B8=20Rasmussen?= Date: Tue, 15 May 2012 12:50:02 +0200 Subject: [PATCH] Added WellReport::push() overload taking BlackoilPropertiesInterface. --- opm/core/utility/miscUtilities.cpp | 55 ++++++++++++++++++++++++++++++ opm/core/utility/miscUtilities.hpp | 10 ++++++ 2 files changed, 65 insertions(+) diff --git a/opm/core/utility/miscUtilities.cpp b/opm/core/utility/miscUtilities.cpp index b84f94e6c..289b68bae 100644 --- a/opm/core/utility/miscUtilities.cpp +++ b/opm/core/utility/miscUtilities.cpp @@ -22,6 +22,7 @@ #include #include #include +#include #include #include #include @@ -614,6 +615,60 @@ namespace Opm + void WellReport::push(const BlackoilPropertiesInterface& props, + const Wells& wells, + const std::vector& p, + const std::vector& z, + const std::vector& s, + const double time, + const std::vector& well_bhp, + const std::vector& well_perfrates) + { + // TODO: refactor, since this is almost identical to the other push(). + int nw = well_bhp.size(); + ASSERT(nw == wells.number_of_wells); + if (props.numPhases() != 2) { + THROW("WellReport for now assumes two phase flow."); + } + std::vector data_now; + data_now.reserve(1 + 3*nw); + data_now.push_back(time/unit::day); + for (int w = 0; w < nw; ++w) { + data_now.push_back(well_bhp[w]/(unit::barsa)); + double well_rate_total = 0.0; + double well_rate_water = 0.0; + for (int perf = wells.well_connpos[w]; perf < wells.well_connpos[w + 1]; ++perf) { + const double perf_rate = well_perfrates[perf]*(unit::day/unit::second); + well_rate_total += perf_rate; + if (perf_rate > 0.0) { + // Injection. + well_rate_water += perf_rate*wells.comp_frac[0]; + } else { + // Production. + const int cell = wells.well_cells[perf]; + double mob[2]; + props.relperm(1, &s[2*cell], &cell, mob, 0); + double visc[2]; + props.viscosity(1, &p[cell], &z[2*cell], &cell, visc, 0); + mob[0] /= visc[0]; + mob[1] /= visc[1]; + const double fracflow = mob[0]/(mob[0] + mob[1]); + well_rate_water += perf_rate*fracflow; + } + } + data_now.push_back(well_rate_total); + if (well_rate_total == 0.0) { + data_now.push_back(0.0); + } else { + data_now.push_back(well_rate_water/well_rate_total); + } + } + data_.push_back(data_now); + } + + + + void WellReport::write(std::ostream& os) const { const int sz = data_.size(); diff --git a/opm/core/utility/miscUtilities.hpp b/opm/core/utility/miscUtilities.hpp index 40fe0059b..37b252bc2 100644 --- a/opm/core/utility/miscUtilities.hpp +++ b/opm/core/utility/miscUtilities.hpp @@ -30,6 +30,7 @@ namespace Opm { class IncompPropertiesInterface; + class BlackoilPropertiesInterface; class RockCompressibility; /// @brief Computes pore volume of all cells in a grid. @@ -247,6 +248,15 @@ namespace Opm const double time, const std::vector& well_bhp, const std::vector& well_perfrates); + /// Add a report point (compressible fluids). + void push(const BlackoilPropertiesInterface& props, + const Wells& wells, + const std::vector& p, + const std::vector& z, + const std::vector& s, + const double time, + const std::vector& well_bhp, + const std::vector& well_perfrates); /// Write report to a stream. void write(std::ostream& os) const; private: