20 #ifndef OPM_WELLSTATEFULLYIMPLICITBLACKOIL_HEADER_INCLUDED
21 #define OPM_WELLSTATEFULLYIMPLICITBLACKOIL_HEADER_INCLUDED
24 #include <opm/core/wells.h>
25 #include <opm/core/well_controls.h>
26 #include <opm/core/simulator/WellState.hpp>
27 #include <opm/common/ErrorMacros.hpp>
44 typedef WellState BaseType;
48 using BaseType :: wellRates;
50 using BaseType :: perfPress;
51 using BaseType :: wellMap;
52 using BaseType :: numWells;
53 using BaseType :: numPhases;
58 template <
class State,
class PrevState>
59 void init(
const Wells* wells,
const State& state,
const PrevState& prevState)
62 BaseType :: init(wells, state);
69 const int nw = wells->number_of_wells;
70 if( nw == 0 ) return ;
73 const int np = wells->number_of_phases;
74 const int nperf = wells->well_connpos[nw];
76 perfphaserates_.clear();
77 perfphaserates_.resize(nperf * np, 0.0);
78 for (
int w = 0; w < nw; ++w) {
79 assert((wells->type[w] == INJECTOR) || (wells->type[w] == PRODUCER));
80 const WellControls* ctrl = wells->ctrls[w];
82 if (well_controls_well_is_stopped(ctrl)) {
85 const int num_perf_this_well = wells->well_connpos[w + 1] - wells->well_connpos[w];
88 for (
int perf = wells->well_connpos[w]; perf < wells->well_connpos[w + 1]; ++perf) {
89 for (
int p = 0; p < np; ++p) {
90 perfphaserates_[np*perf + p] = wellRates()[np*w + p] / double(num_perf_this_well);
92 perfPress()[perf] = state.pressure()[wells->well_cells[perf]];
100 current_controls_.resize(nw);
101 for (
int w = 0; w < nw; ++w) {
102 current_controls_[w] = well_controls_get_current(wells->ctrls[w]);
107 if( ! prevState.wellMap().empty() )
109 typedef typename WellMapType :: const_iterator const_iterator;
110 const_iterator end = prevState.wellMap().end();
111 for (
int w = 0; w < nw; ++w) {
112 std::string name( wells->name[ w ] );
113 const_iterator it = prevState.wellMap().find( name );
116 const int oldIndex = (*it).second[ 0 ];
117 const int newIndex = w;
120 bhp()[ newIndex ] = prevState.bhp()[ oldIndex ];
123 for(
int i=0, idx=newIndex*np, oldidx=oldIndex*np; i<np; ++i, ++idx, ++oldidx )
125 wellRates()[ idx ] = prevState.wellRates()[ oldidx ];
129 int oldPerf_idx = (*it).second[ 1 ];
130 const int num_perf_old_well = (*it).second[ 2 ];
131 const int num_perf_this_well = wells->well_connpos[newIndex + 1] - wells->well_connpos[newIndex];
134 if( num_perf_old_well == num_perf_this_well )
136 int oldPerf = oldPerf_idx *np;
137 for (
int perf = wells->well_connpos[ newIndex ]*np;
138 perf < wells->well_connpos[ newIndex + 1]*np; ++perf, ++oldPerf )
143 for (
int perf = wells->well_connpos[newIndex]; perf < wells->well_connpos[newIndex + 1]; ++perf) {
144 for (
int p = 0; p < np; ++p) {
145 perfPhaseRates()[np*perf + p] = wellRates()[np*newIndex + p] / double(num_perf_this_well);
150 if( num_perf_old_well == num_perf_this_well )
152 for (
int perf = wells->well_connpos[ newIndex ];
153 perf < wells->well_connpos[ newIndex + 1]; ++perf, ++oldPerf_idx )
155 perfPress()[ perf ] = prevState.perfPress()[ oldPerf_idx ];
160 const int old_control_index = prevState.currentControls()[ oldIndex ];
161 if (old_control_index < well_controls_get_num(wells->ctrls[w])) {
181 std::vector<double> perfphaserates_;
182 std::vector<int> current_controls_;
188 #endif // OPM_WELLSTATEFULLYIMPLICITBLACKOIL_HEADER_INCLUDED
VFPEvaluation bhp(const VFPProdTable *table, const double &aqua, const double &liquid, const double &vapour, const double &thp, const double &alq)
Definition: VFPHelpers.hpp:517
const std::vector< int > & currentControls() const
Definition: WellStateFullyImplicitBlackoil.hpp:178
Definition: AdditionalObjectDeleter.hpp:22
Definition: WellStateFullyImplicitBlackoil.hpp:41
BaseType::WellMapType WellMapType
Definition: WellStateFullyImplicitBlackoil.hpp:46
std::vector< double > & perfPhaseRates()
One rate per phase and well connection.
Definition: WellStateFullyImplicitBlackoil.hpp:173
void init(const Wells *wells, const State &state, const PrevState &prevState)
Definition: WellStateFullyImplicitBlackoil.hpp:59
std::vector< int > & currentControls()
One current control per well.
Definition: WellStateFullyImplicitBlackoil.hpp:177
const std::vector< double > & perfPhaseRates() const
Definition: WellStateFullyImplicitBlackoil.hpp:174