From 27af4b339dbc6c8369675de8cd3bb6c6a0015271 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Atgeirr=20Fl=C3=B8=20Rasmussen?= Date: Wed, 25 Apr 2012 14:03:57 +0200 Subject: [PATCH] Removed unused saturation argument from conditionsMet() methods. --- examples/wells_example.cpp | 2 +- opm/core/WellCollection.cpp | 28 +++++++++---------- opm/core/WellCollection.hpp | 23 +++++++++------- opm/core/WellsGroup.cpp | 54 ++++++++++++++++++------------------- opm/core/WellsGroup.hpp | 21 +++++++++------ opm/core/WellsManager.cpp | 2 +- 6 files changed, 68 insertions(+), 62 deletions(-) diff --git a/examples/wells_example.cpp b/examples/wells_example.cpp index bb40cc8a..ef2fb6ed 100644 --- a/examples/wells_example.cpp +++ b/examples/wells_example.cpp @@ -77,7 +77,7 @@ int main(int argc, char** argv) { computeFlowRatePerWell(*wells.c_wells(), well_rate_per_cell, well_rate); WellControlResult well_control_results; - wells.wellCollection().conditionsMet(well_bhp, well_rate, *grid.c_grid(), state.saturation(), well_control_results ); + wells.wellCollection().conditionsMet(well_bhp, well_rate, *grid.c_grid(), well_control_results ); wells.applyControl(well_control_results); #if 0 diff --git a/opm/core/WellCollection.cpp b/opm/core/WellCollection.cpp index b1be60c0..1a4b0268 100644 --- a/opm/core/WellCollection.cpp +++ b/opm/core/WellCollection.cpp @@ -23,16 +23,9 @@ along with OpenRS. If not, see . namespace Opm { - WellCollection::WellCollection() - { - } - - WellCollection::~WellCollection() - { - } - - void WellCollection::addChild(std::string child_name, std::string parent_name, - const EclipseGridParser& deck) + void WellCollection::addChild(const std::string& child_name, + const std::string& parent_name, + const EclipseGridParser& deck) { WellsGroupInterface* parent = findNode(parent_name); if (!parent) { @@ -100,11 +93,14 @@ namespace Opm return NULL; } - void WellCollection::conditionsMet(const std::vector& well_bhp, const std::vector& well_rate, - const UnstructuredGrid& grid, const std::vector& saturations, - WellControlResult& result, double epsilon) const { - for(size_t i = 0; i < leaf_nodes_.size(); i++) { - static_cast(leaf_nodes_[i].get())->conditionsMet(well_bhp, well_rate, grid, saturations, result, epsilon); + void WellCollection::conditionsMet(const std::vector& well_bhp, + const std::vector& well_rate, + const UnstructuredGrid& grid, + WellControlResult& result, + double epsilon) const + { + for (size_t i = 0; i < leaf_nodes_.size(); i++) { + static_cast(leaf_nodes_[i].get())->conditionsMet(well_bhp, well_rate, grid, result, epsilon); } } @@ -114,4 +110,4 @@ namespace Opm roots_[i]->calculateGuideRates(); } } -} \ No newline at end of file +} diff --git a/opm/core/WellCollection.hpp b/opm/core/WellCollection.hpp index fca18cca..12d964dd 100644 --- a/opm/core/WellCollection.hpp +++ b/opm/core/WellCollection.hpp @@ -33,17 +33,22 @@ namespace Opm class WellCollection { public: - WellCollection(); - virtual ~WellCollection(); + /// Adds and creates if necessary the child to the collection + /// and appends it to parent's children. Also adds and creates the parent + /// if necessary. + /// \param[in] child name of child node + /// \param[in] parent name of parent node + /// \param[in] deck deck from which we will extract group control data + void addChild(const std::string& child, + const std::string& parent, + const EclipseGridParser& deck); - void addChild(std::string child, std::string parent, - const EclipseGridParser& deck); - - - void conditionsMet(const std::vector& well_bhp, const std::vector& well_rate, - const UnstructuredGrid& grid, const std::vector& saturations, + /// Builds the WellControlResult object for the current well group hierachy. + void conditionsMet(const std::vector& well_bhp, + const std::vector& well_rate, + const UnstructuredGrid& grid, WellControlResult& result, - double epsilon=1e-8) const; + const double epsilon=1e-8) const; const std::vector >& getLeafNodes() const; diff --git a/opm/core/WellsGroup.cpp b/opm/core/WellsGroup.cpp index 2c2003e3..6e8a4d9a 100644 --- a/opm/core/WellsGroup.cpp +++ b/opm/core/WellsGroup.cpp @@ -116,14 +116,17 @@ namespace Opm } - void WellsGroup::conditionsMet(const std::vector& well_bhp, const std::vector& well_rate, - const UnstructuredGrid& grid, const std::vector& saturations, - const struct Wells* wells, int index_of_well, WellControlResult& result, - double epsilon) + void WellsGroup::conditionsMet(const std::vector& well_bhp, + const std::vector& well_rate, + const UnstructuredGrid& grid, + const struct Wells* wells, + int index_of_well, + WellControlResult& result, + const double epsilon) { if (parent_ != NULL) { (static_cast (parent_))->conditionsMet(well_bhp, - well_rate,grid, saturations, wells, index_of_well, result, epsilon); + well_rate,grid, wells, index_of_well, result, epsilon); } int number_of_leaf_nodes = numberOfLeafNodes(); @@ -197,20 +200,17 @@ namespace Opm { } - void WellNode::conditionsMet(const std::vector& well_bhp, const std::vector& well_rate, - const UnstructuredGrid& grid, const std::vector& saturations, - WellControlResult& result, double epsilon) + void WellNode::conditionsMet(const std::vector& well_bhp, + const std::vector& well_rate, + const UnstructuredGrid& grid, + WellControlResult& result, + const double epsilon) { if (parent_ != NULL) { - (static_cast (parent_))->conditionsMet(well_bhp, - well_rate, - grid, - saturations, - wells_, - self_index_, - result, - epsilon); + (static_cast (parent_)) + ->conditionsMet(well_bhp, well_rate, grid, wells_, + self_index_, result, epsilon); } // Check for self: @@ -218,7 +218,7 @@ namespace Opm double bhp_diff = well_bhp[self_index_] - prodSpec().BHP_limit_; double rate_diff = well_rate[self_index_] - prodSpec().fluid_volume_max_rate_; - if(bhp_diff > epsilon) { + if (bhp_diff > epsilon) { std::cout << "BHP exceeded, bhp_diff = " << bhp_diff << std::endl; std::cout << "BHP_limit = " << prodSpec().BHP_limit_ << std::endl; @@ -231,7 +231,7 @@ namespace Opm result.bhp_.push_back(info); } - if(rate_diff > epsilon) { + if (rate_diff > epsilon) { ExceedInformation info; info.group_name_ = name(); info.surplus_ = rate_diff; @@ -244,7 +244,7 @@ namespace Opm double rate_diff = well_rate[self_index_] - injSpec().fluid_volume_max_rate_; - if(bhp_diff > epsilon) { + if (bhp_diff > epsilon) { std::cout << "BHP exceeded, bhp_diff = " << bhp_diff< epsilon) { - std::cout << "Flow diff exceeded, flow_diff = " << rate_diff << std::endl; - ExceedInformation info; - info.group_name_ = name(); - info.surplus_ = rate_diff; - info.well_index_ = self_index_; - result.fluid_rate_.push_back(info); - } + if (rate_diff > epsilon) { + std::cout << "Flow diff exceeded, flow_diff = " << rate_diff << std::endl; + ExceedInformation info; + info.group_name_ = name(); + info.surplus_ = rate_diff; + info.well_index_ = self_index_; + result.fluid_rate_.push_back(info); + } } } diff --git a/opm/core/WellsGroup.hpp b/opm/core/WellsGroup.hpp index 9bf57a25..e6154d1f 100644 --- a/opm/core/WellsGroup.hpp +++ b/opm/core/WellsGroup.hpp @@ -21,8 +21,8 @@ namespace Opm std::vector oil_rate_; std::vector fluid_rate_; std::vector bhp_; - }; + class WellsGroupInterface { public: @@ -86,12 +86,15 @@ namespace Opm void addChild(std::tr1::shared_ptr child); - void conditionsMet(const std::vector& well_bhp, const std::vector& well_rate, - const UnstructuredGrid& grid, const std::vector& saturations, const struct Wells* wells, - int index_of_well, WellControlResult& result, double epsilon = 1e-8); + void conditionsMet(const std::vector& well_bhp, + const std::vector& well_rate, + const UnstructuredGrid& grid, + const struct Wells* wells, + int index_of_well, + WellControlResult& result, + double epsilon = 1e-8); virtual void calculateGuideRates(); - virtual int numberOfLeafNodes(); private: @@ -108,9 +111,11 @@ namespace Opm InjectionSpecification inj_spec); virtual WellsGroupInterface* findGroup(std::string name_of_node); - virtual void conditionsMet(const std::vector& well_bhp, const std::vector& well_rate, - const UnstructuredGrid& grid, const std::vector& saturations, - WellControlResult& result, double epsilon=1e-8); + virtual void conditionsMet(const std::vector& well_bhp, + const std::vector& well_rate, + const UnstructuredGrid& grid, + WellControlResult& result, + double epsilon=1e-8); virtual bool isLeafNode() const; void setWellsPointer(const struct Wells* wells, int self_index); diff --git a/opm/core/WellsManager.cpp b/opm/core/WellsManager.cpp index b978e4e6..00903645 100644 --- a/opm/core/WellsManager.cpp +++ b/opm/core/WellsManager.cpp @@ -586,7 +586,7 @@ namespace Opm } const double* zfrac = (well_data[w].type == INJECTOR) ? fracs[well_data[w].injected_phase] : 0; - // DIRTY DIRTY HACK + // DIRTY DIRTY HACK to temporarily make things work in spite of bugs in the deck reader. if(well_data[w].type == INJECTOR && (well_data[w].injected_phase < 0 || well_data[w].injected_phase > 2)){ zfrac = fracs[WATER]; }