refactoring the init() of WellStateMultiSegment

to handle better when nw = 0
This commit is contained in:
Kai Bao 2015-11-23 17:14:33 +01:00
parent 0022bb8465
commit 4c73f3c01c

View File

@ -68,18 +68,21 @@ namespace Opm
void init(const std::vector<WellMultiSegmentConstPtr>& wells, const ReservoirState& state, const PrevWellState& prevState) void init(const std::vector<WellMultiSegmentConstPtr>& wells, const ReservoirState& state, const PrevWellState& prevState)
{ {
const int nw = wells.size(); const int nw = wells.size();
nseg_ = 0;
nperf_ = 0;
if (nw == 0) { if (nw == 0) {
perfPhaseRates().clear();
perfPress().clear();
segphaserates_.clear();
segpress_.clear();
return; return;
} }
const int np = wells[0]->numberOfPhases(); // number of the phases const int np = wells[0]->numberOfPhases(); // number of the phases
int nperf = 0; // the number of the perforations
int nseg = 0; // the nubmer of the segments
for (int iw = 0; iw < nw; ++iw) { for (int iw = 0; iw < nw; ++iw) {
nperf += wells[iw]->numberOfPerforations(); nperf_ += wells[iw]->numberOfPerforations();
nseg += wells[iw]->numberOfSegments(); nseg_ += wells[iw]->numberOfSegments();
} }
bhp().resize(nw); bhp().resize(nw);
@ -87,11 +90,6 @@ namespace Opm
top_segment_loc_.resize(nw); top_segment_loc_.resize(nw);
temperature().resize(nw, 273.15 + 20); // standard temperature for now temperature().resize(nw, 273.15 + 20); // standard temperature for now
// deciding to add the following variables temporarily
// TODO: making it better later
nseg_ = nseg;
nperf_ = nperf;
wellRates().resize(nw * np, 0.0); wellRates().resize(nw * np, 0.0);
currentControls().resize(nw); currentControls().resize(nw);
@ -106,17 +104,10 @@ namespace Opm
int start_segment = 0; int start_segment = 0;
int start_perforation = 0; int start_perforation = 0;
perfPhaseRates().clear(); perfPhaseRates().resize(nperf_ * np, 0.0);
perfPhaseRates().resize(nperf * np, 0.0); perfPress().resize(nperf_, -1.0e100);
segphaserates_.resize(nseg_ * np, 0.0);
perfPress().clear(); segpress_.resize(nseg_, -1.0e100);
perfPress().resize(nperf, -1.0e100);
segphaserates_.clear();
segphaserates_.resize(nseg * np, 0.0);
segpress_.clear();
segpress_.resize(nseg, -1.0e100);
for (int w = 0; w < nw; ++w) { for (int w = 0; w < nw; ++w) {