From c9a866fce0ab77a89f88a71a5e2e961463d2dad9 Mon Sep 17 00:00:00 2001 From: Kjetil Olsen Lye Date: Fri, 13 Apr 2012 14:22:44 +0200 Subject: [PATCH] Added computations for total flow for each well --- examples/wells_example.cpp | 7 +++++-- opm/core/utility/miscUtilities.cpp | 14 ++++++++++++++ opm/core/utility/miscUtilities.hpp | 3 +++ 3 files changed, 22 insertions(+), 2 deletions(-) diff --git a/examples/wells_example.cpp b/examples/wells_example.cpp index 09329be4..44201ff5 100644 --- a/examples/wells_example.cpp +++ b/examples/wells_example.cpp @@ -73,9 +73,12 @@ int main(int argc, char** argv) { std::vector face_flux; std::vector well_bhp; - std::vector well_rate; - pressure_solver.solve(totmob, omega, src, wdp, bcs.c_bcs(), pressure, face_flux, well_bhp, well_rate); + std::vector well_rate_per_cell; + pressure_solver.solve(totmob, omega, src, wdp, bcs.c_bcs(), pressure, face_flux, well_bhp, well_rate_per_cell); std::cout << "Solved" << std::endl; + + std::vector well_rate; + computeFlowRatePerWell(*wells.c_wells(), well_rate_per_cell, well_rate); if(wells.wellCollection().conditionsMet(well_bhp, well_rate, *grid.c_grid(), state.saturation() )) { std::cout << "Conditions met for wells!" << std::endl; } diff --git a/opm/core/utility/miscUtilities.cpp b/opm/core/utility/miscUtilities.cpp index 52a1457c..5dfbbdad 100644 --- a/opm/core/utility/miscUtilities.cpp +++ b/opm/core/utility/miscUtilities.cpp @@ -437,6 +437,20 @@ namespace Opm } } } + + void computeFlowRatePerWell(const Wells& wells, const std::vector& flow_rates_per_cell, + std::vector& flow_rates_per_well) + { + int index_in_flow_rates = 0; + for(int w = 0; w < wells.number_of_wells; w++) { + int number_of_cells = wells.well_connpos[w+1]-wells.well_connpos[w]; + double flow_sum = 0.0; + for(int i = 0; i < number_of_cells; i++) { + flow_sum += flow_rates_per_cell[index_in_flow_rates++]; + } + flow_rates_per_well.push_back(flow_sum); + } + } } // namespace Opm diff --git a/opm/core/utility/miscUtilities.hpp b/opm/core/utility/miscUtilities.hpp index 72edea5a..6ef992f6 100644 --- a/opm/core/utility/miscUtilities.hpp +++ b/opm/core/utility/miscUtilities.hpp @@ -180,6 +180,9 @@ namespace Opm void computeWDP(const Wells& wells, const UnstructuredGrid& grid, const std::vector& saturations, const std::vector& densities, std::vector& wdp); + void computeFlowRatePerWell(const Wells& wells, const std::vector& flow_rates_per_cell, + std::vector& flow_rates_per_well); + /// Encapsulates the watercut curves. class Watercut {