fixing a bug related to adding ms well during simulation.

When there is not ms well involved, all the ms well related is not
initialized. It causes problem when we want to add ms well after some
time of running.

The bug fix the running with model 2.
This commit is contained in:
Kai Bao 2017-10-04 15:43:38 +02:00
parent c3a368e58e
commit 78a28abf91

View File

@ -63,7 +63,8 @@ namespace Opm
/// to give useful initial values to the bhp(), wellRates()
/// and perfPhaseRates() fields, depending on controls
template <class PrevWellState>
void init(const Wells* wells, const std::vector<double>& cellPressures, const PrevWellState& prevState, const PhaseUsage& pu)
void init(const Wells* wells, const std::vector<double>& cellPressures,
const PrevWellState& prevState, const PhaseUsage& pu)
{
// call init on base class
@ -109,6 +110,17 @@ namespace Opm
}
}
}
{
// we need to create a trival segment related values to avoid there will be some
// multi-segment wells added later.
top_segment_loc_.reserve(nw);
for (int w = 0; w < nw; ++w) {
top_segment_loc_.push_back(w);
}
segpress_ = bhp();
segrates_ = wellRates();
}
}
/// init the MS well related.
@ -122,6 +134,13 @@ namespace Opm
return;
}
top_segment_loc_.clear();
top_segment_loc_.reserve(nw);
segpress_.clear();
segpress_.reserve(nw);
segrates_.clear();
segrates_.reserve(nw * numPhases());
nseg_ = 0.;
// in the init function, the well rates and perforation rates have been initialized or copied from prevState
// what we do here, is to set the segment rates and perforation rates
@ -358,6 +377,7 @@ namespace Opm
int topSegmentLocation(const int w) const
{
assert(w < int(top_segment_loc_.size()) );
return top_segment_loc_[w];
}