diff --git a/opm/autodiff/BlackoilModelBase.hpp b/opm/autodiff/BlackoilModelBase.hpp index 301b637ed..f5341eae5 100644 --- a/opm/autodiff/BlackoilModelBase.hpp +++ b/opm/autodiff/BlackoilModelBase.hpp @@ -356,9 +356,6 @@ namespace Opm { void variableReservoirStateInitials(const ReservoirState& x, std::vector& vars0) const; - void - variableWellStateInitials(const WellState& xw, - std::vector& vars0) const; std::vector variableStateIndices() const; diff --git a/opm/autodiff/BlackoilModelBase_impl.hpp b/opm/autodiff/BlackoilModelBase_impl.hpp index 97a495c06..6ecfa2576 100644 --- a/opm/autodiff/BlackoilModelBase_impl.hpp +++ b/opm/autodiff/BlackoilModelBase_impl.hpp @@ -507,7 +507,7 @@ namespace detail { // and bhp and Q for the wells vars0.reserve(np + 1); variableReservoirStateInitials(x, vars0); - asImpl().variableWellStateInitials(xw, vars0); + asImpl().stdWells().variableWellStateInitials(xw, vars0); return vars0; } @@ -554,41 +554,6 @@ namespace detail { - template - void - BlackoilModelBase:: - variableWellStateInitials(const WellState& xw, std::vector& vars0) const - { - // Initial well rates. - if ( stdWells().localWellsActive() ) - { - // Need to reshuffle well rates, from phase running fastest - // to wells running fastest. - const int nw = wells().number_of_wells; - const int np = wells().number_of_phases; - - // The transpose() below switches the ordering. - const DataBlock wrates = Eigen::Map(& xw.wellRates()[0], nw, np).transpose(); - const V qs = Eigen::Map(wrates.data(), nw*np); - vars0.push_back(qs); - - // Initial well bottom-hole pressure. - assert (not xw.bhp().empty()); - const V bhp = Eigen::Map(& xw.bhp()[0], xw.bhp().size()); - vars0.push_back(bhp); - } - else - { - // push null states for qs and bhp - vars0.push_back(V()); - vars0.push_back(V()); - } - } - - - - - template std::vector BlackoilModelBase:: @@ -1100,7 +1065,7 @@ namespace detail { // bhp and Q for the wells std::vector vars0; vars0.reserve(2); - asImpl().variableWellStateInitials(well_state, vars0); + asImpl().stdWells().variableWellStateInitials(well_state, vars0); std::vector vars = ADB::variables(vars0); SolutionState wellSolutionState = state0; diff --git a/opm/autodiff/BlackoilMultiSegmentModel.hpp b/opm/autodiff/BlackoilMultiSegmentModel.hpp index 76dd8befd..4d659c920 100644 --- a/opm/autodiff/BlackoilMultiSegmentModel.hpp +++ b/opm/autodiff/BlackoilMultiSegmentModel.hpp @@ -225,6 +225,7 @@ namespace Opm { using Base::variableState; // using Base::variableWellStateIndices; using Base::asImpl; + using Base::variableReservoirStateInitials; const std::vector& wellsMultiSegment() const { return wells_multisegment_; } @@ -234,6 +235,10 @@ namespace Opm { void updateWellState(const V& dwells, WellState& well_state); + std::vector + variableStateInitials(const ReservoirState& x, + const WellState& xw) const; + void variableWellStateInitials(const WellState& xw, std::vector& vars0) const; diff --git a/opm/autodiff/BlackoilMultiSegmentModel_impl.hpp b/opm/autodiff/BlackoilMultiSegmentModel_impl.hpp index 3741d4a15..3026df908 100644 --- a/opm/autodiff/BlackoilMultiSegmentModel_impl.hpp +++ b/opm/autodiff/BlackoilMultiSegmentModel_impl.hpp @@ -1653,6 +1653,28 @@ namespace Opm { } + + + + template + std::vector + BlackoilMultiSegmentModel:: + variableStateInitials(const ReservoirState& x, + const WellState& xw) const + { + assert(active_[ Oil ]); + + const int np = x.numPhases(); + + std::vector vars0; + // p, Sw and Rs, Rv or Sg is used as primary depending on solution conditions + // and bhp and Q for the wells + vars0.reserve(np + 1); + variableReservoirStateInitials(x, vars0); + variableWellStateInitials(xw, vars0); + return vars0; + } + } // namespace Opm #endif // OPM_BLACKOILMODELBASE_IMPL_HEADER_INCLUDED diff --git a/opm/autodiff/StandardWells.hpp b/opm/autodiff/StandardWells.hpp index 0e41ef5fa..9f12a9596 100644 --- a/opm/autodiff/StandardWells.hpp +++ b/opm/autodiff/StandardWells.hpp @@ -188,6 +188,11 @@ namespace Opm { std::vector variableWellStateIndices() const; + template + void + variableWellStateInitials(const WellState& xw, + std::vector& vars0) const; + protected: bool wells_active_; const Wells* wells_; diff --git a/opm/autodiff/StandardWells_impl.hpp b/opm/autodiff/StandardWells_impl.hpp index 24fc8f8a6..be11a96a6 100644 --- a/opm/autodiff/StandardWells_impl.hpp +++ b/opm/autodiff/StandardWells_impl.hpp @@ -1148,4 +1148,39 @@ namespace Opm return indices; } + + + + + template + void + StandardWells::variableWellStateInitials(const WellState& xw, + std::vector& vars0) const + { + // Initial well rates. + if ( localWellsActive() ) + { + // Need to reshuffle well rates, from phase running fastest + // to wells running fastest. + const int nw = wells().number_of_wells; + const int np = wells().number_of_phases; + + // The transpose() below switches the ordering. + const DataBlock wrates = Eigen::Map(& xw.wellRates()[0], nw, np).transpose(); + const V qs = Eigen::Map(wrates.data(), nw*np); + vars0.push_back(qs); + + // Initial well bottom-hole pressure. + assert (not xw.bhp().empty()); + const V bhp = Eigen::Map(& xw.bhp()[0], xw.bhp().size()); + vars0.push_back(bhp); + } + else + { + // push null states for qs and bhp + vars0.push_back(V()); + vars0.push_back(V()); + } + } + }