From 3947ff5b1d57adfca8652b793c527080e10afcee Mon Sep 17 00:00:00 2001 From: Kai Bao Date: Fri, 1 Apr 2016 14:55:58 +0200 Subject: [PATCH] moving localWellsActive and wellsActive to StandardWells maybe later it can be something general for different types of wells. --- opm/autodiff/BlackoilModelBase.hpp | 8 +-- opm/autodiff/BlackoilModelBase_impl.hpp | 52 ++++++++++++++----- opm/autodiff/BlackoilMultiSegmentModel.hpp | 1 - .../BlackoilMultiSegmentModel_impl.hpp | 6 +-- opm/autodiff/BlackoilSolventModel.hpp | 1 - opm/autodiff/BlackoilSolventModel_impl.hpp | 1 + .../fullyimplicit/BlackoilPolymerModel.hpp | 1 - .../BlackoilPolymerModel_impl.hpp | 4 +- 8 files changed, 48 insertions(+), 26 deletions(-) diff --git a/opm/autodiff/BlackoilModelBase.hpp b/opm/autodiff/BlackoilModelBase.hpp index fe881374d..c6a7107c1 100644 --- a/opm/autodiff/BlackoilModelBase.hpp +++ b/opm/autodiff/BlackoilModelBase.hpp @@ -280,6 +280,10 @@ namespace Opm { // keeping the underline, later they will be private members StandardWells(const Wells* wells); const Wells& wells() const; + // return true if wells are available in the reservoir + bool wellsActive() const; + // return true if wells are available on this process + bool localWellsActive() const; bool wells_active_; const Wells* wells_; const WellOps wops_; @@ -345,10 +349,6 @@ namespace Opm { return static_cast(*this); } - // return true if wells are available in the reservoir - bool wellsActive() const { return std_wells_.wells_active_; } - // return true if wells are available on this process - bool localWellsActive() const { return std_wells_.wells_ ? (std_wells_.wells_->number_of_wells > 0 ) : false; } // return the StandardWells object StandardWells& stdWells() { return std_wells_; } diff --git a/opm/autodiff/BlackoilModelBase_impl.hpp b/opm/autodiff/BlackoilModelBase_impl.hpp index e94d26a5b..4bae2594c 100644 --- a/opm/autodiff/BlackoilModelBase_impl.hpp +++ b/opm/autodiff/BlackoilModelBase_impl.hpp @@ -481,12 +481,36 @@ namespace detail { + template + bool + BlackoilModelBase:: + StandardWells::wellsActive() const + { + return wells_active_; + } + + + + + + template + bool + BlackoilModelBase:: + StandardWells::localWellsActive() const + { + return wells_ ? (wells_->number_of_wells > 0 ) : false; + } + + + + + template int BlackoilModelBase::numWellVars() const { // For each well, we have a bhp variable, and one flux per phase. - const int nw = localWellsActive() ? stdWells().wells().number_of_wells : 0; + const int nw = stdWells().localWellsActive() ? stdWells().wells().number_of_wells : 0; return (numPhases() + 1) * nw; } @@ -602,7 +626,7 @@ namespace detail { BlackoilModelBase::variableWellStateInitials(const WellState& xw, std::vector& vars0) const { // Initial well rates. - if ( localWellsActive() ) + if ( stdWells().localWellsActive() ) { // Need to reshuffle well rates, from phase running fastest // to wells running fastest. @@ -993,7 +1017,7 @@ namespace detail { // -------- Well equations ---------- - if ( ! wellsActive() ) { + if ( ! stdWells().wellsActive() ) { return; } @@ -1124,7 +1148,7 @@ namespace detail { const SolutionState&, const WellState&) { - if ( !asImpl().localWellsActive() ) + if ( !asImpl().stdWells().localWellsActive() ) { // If there are no wells in the subdomain of the proces then // cq_s has zero size and will cause a segmentation fault below. @@ -1152,7 +1176,7 @@ namespace detail { { // If we have wells, extract the mobilities and b-factors for // the well-perforated cells. - if (!asImpl().localWellsActive()) { + if (!asImpl().stdWells().localWellsActive()) { mob_perfcells.clear(); b_perfcells.clear(); return; @@ -1181,7 +1205,7 @@ namespace detail { V& aliveWells, std::vector& cq_s) const { - if( ! localWellsActive() ) return ; + if( ! stdWells().localWellsActive() ) return ; const int np = stdWells().wells().number_of_phases; const int nw = stdWells().wells().number_of_wells; @@ -1329,7 +1353,7 @@ namespace detail { const SolutionState& state, WellState& xw) const { - if ( !asImpl().localWellsActive() ) + if ( !asImpl().stdWells().localWellsActive() ) { // If there are no wells in the subdomain of the proces then // cq_s has zero size and will cause a segmentation fault below. @@ -1360,7 +1384,7 @@ namespace detail { void BlackoilModelBase::addWellFluxEq(const std::vector& cq_s, const SolutionState& state) { - if( !asImpl().localWellsActive() ) + if( !asImpl().stdWells().localWellsActive() ) { // If there are no wells in the subdomain of the proces then // cq_s has zero size and will cause a segmentation fault below. @@ -1517,7 +1541,7 @@ namespace detail { template bool BlackoilModelBase::isVFPActive() const { - if( ! localWellsActive() ) { + if( ! stdWells().localWellsActive() ) { return false; } @@ -1549,7 +1573,7 @@ namespace detail { template void BlackoilModelBase::updateWellControls(WellState& xw) const { - if( ! localWellsActive() ) return ; + if( ! stdWells().localWellsActive() ) return ; std::string modestring[4] = { "BHP", "THP", "RESERVOIR_RATE", "SURFACE_RATE" }; // Find, for each well, if any constraints are broken. If so, @@ -1715,7 +1739,7 @@ namespace detail { std::vector mob_perfcells_const(np, ADB::null()); std::vector b_perfcells_const(np, ADB::null()); - if (asImpl().localWellsActive() ){ + if (asImpl().stdWells().localWellsActive() ){ // If there are non well in the sudomain of the process // thene mob_perfcells_const and b_perfcells_const would be empty for (int phase = 0; phase < np; ++phase) { @@ -1746,7 +1770,7 @@ namespace detail { } ++it; - if( localWellsActive() ) + if( stdWells().localWellsActive() ) { std::vector eqs; eqs.reserve(2); @@ -1808,7 +1832,7 @@ namespace detail { const WellState& xw, const V& aliveWells) { - if( ! localWellsActive() ) return; + if( ! stdWells().localWellsActive() ) return; const int np = stdWells().wells().number_of_phases; const int nw = stdWells().wells().number_of_wells; @@ -2308,7 +2332,7 @@ namespace detail { WellState& well_state) { - if( localWellsActive() ) + if( stdWells().localWellsActive() ) { const int np = stdWells().wells().number_of_phases; const int nw = stdWells().wells().number_of_wells; diff --git a/opm/autodiff/BlackoilMultiSegmentModel.hpp b/opm/autodiff/BlackoilMultiSegmentModel.hpp index fde3f790c..a6d914df6 100644 --- a/opm/autodiff/BlackoilMultiSegmentModel.hpp +++ b/opm/autodiff/BlackoilMultiSegmentModel.hpp @@ -208,7 +208,6 @@ namespace Opm { using Base::stdWells; using Base::updatePrimalVariableFromState; - using Base::wellsActive; using Base::phaseCondition; using Base::fluidRvSat; using Base::fluidRsSat; diff --git a/opm/autodiff/BlackoilMultiSegmentModel_impl.hpp b/opm/autodiff/BlackoilMultiSegmentModel_impl.hpp index 8d2c82ff1..d6a4ca8cc 100644 --- a/opm/autodiff/BlackoilMultiSegmentModel_impl.hpp +++ b/opm/autodiff/BlackoilMultiSegmentModel_impl.hpp @@ -359,7 +359,7 @@ namespace Opm { void BlackoilMultiSegmentModel::computeWellConnectionPressures(const SolutionState& state, const WellState& xw) { - if( ! wellsActive() ) return ; + if( ! stdWells().wellsActive() ) return ; using namespace Opm::AutoDiffGrid; // 1. Compute properties required by computeConnectionPressureDelta(). @@ -621,7 +621,7 @@ namespace Opm { // -------- Well equations ---------- - if ( ! wellsActive() ) { + if ( ! stdWells().wellsActive() ) { return; } @@ -939,7 +939,7 @@ namespace Opm { template void BlackoilMultiSegmentModel::updateWellControls(WellState& xw) const { - if( ! wellsActive() ) return ; + if( ! stdWells().wellsActive() ) return ; std::string modestring[4] = { "BHP", "THP", "RESERVOIR_RATE", "SURFACE_RATE" }; // Find, for each well, if any constraints are broken. If so, diff --git a/opm/autodiff/BlackoilSolventModel.hpp b/opm/autodiff/BlackoilSolventModel.hpp index 5a03be9cb..26c9b8742 100644 --- a/opm/autodiff/BlackoilSolventModel.hpp +++ b/opm/autodiff/BlackoilSolventModel.hpp @@ -130,7 +130,6 @@ namespace Opm { // --------- Protected methods --------- // Need to declare Base members we want to use here. - using Base::wellsActive; using Base::stdWells; using Base::variableState; using Base::computeGasPressure; diff --git a/opm/autodiff/BlackoilSolventModel_impl.hpp b/opm/autodiff/BlackoilSolventModel_impl.hpp index 0065d6f0d..9bbac9618 100644 --- a/opm/autodiff/BlackoilSolventModel_impl.hpp +++ b/opm/autodiff/BlackoilSolventModel_impl.hpp @@ -389,6 +389,7 @@ namespace Opm { std::vector& rvmax_perf, std::vector& surf_dens_perf) { + if( ! stdWells().localWellsActive() ) return ; using namespace Opm::AutoDiffGrid; // 1. Compute properties required by computeConnectionPressureDelta(). diff --git a/opm/polymer/fullyimplicit/BlackoilPolymerModel.hpp b/opm/polymer/fullyimplicit/BlackoilPolymerModel.hpp index fb6560a05..8c7c2e656 100644 --- a/opm/polymer/fullyimplicit/BlackoilPolymerModel.hpp +++ b/opm/polymer/fullyimplicit/BlackoilPolymerModel.hpp @@ -179,7 +179,6 @@ namespace Opm { // Need to declare Base members we want to use here. using Base::stdWells; - using Base::wellsActive; using Base::variableState; using Base::computePressures; using Base::computeGasPressure; diff --git a/opm/polymer/fullyimplicit/BlackoilPolymerModel_impl.hpp b/opm/polymer/fullyimplicit/BlackoilPolymerModel_impl.hpp index baf7dcb79..72036351c 100644 --- a/opm/polymer/fullyimplicit/BlackoilPolymerModel_impl.hpp +++ b/opm/polymer/fullyimplicit/BlackoilPolymerModel_impl.hpp @@ -525,7 +525,7 @@ namespace Opm { assembleMassBalanceEq(state); // -------- Well equations ---------- - if ( ! wellsActive() ) { + if ( ! stdWells().wellsActive() ) { return; } @@ -710,7 +710,7 @@ namespace Opm { BlackoilPolymerModel::computeWaterShearVelocityWells(const SolutionState& state, WellState& xw, const ADB& cq_sw, std::vector& water_vel_wells, std::vector& visc_mult_wells) { - if( ! wellsActive() ) return ; + if( ! stdWells().wellsActive() ) return ; const int nw = stdWells().wells().number_of_wells; const int nperf = stdWells().wells().well_connpos[nw];