MSW: Support Connection Results for All Connections
The current code that aggregates flow rates from connection to segment levels assumes that the simulator generates connection results for the open connections only. Relax this restriction as upcoming work in the context of WELPI will require generating at least the CTFs even for shut connections.
This commit is contained in:
parent
96f9362f59
commit
14c566d99b
@ -181,29 +181,35 @@ namespace {
|
||||
}
|
||||
|
||||
Opm::RestartIO::Helpers::SegmentSetSourceSinkTerms
|
||||
getSegmentSetSSTerms(const std::string& wname, const Opm::WellSegments& segSet, const std::vector<Opm::data::Connection>& rateConns,
|
||||
const Opm::WellConnections& welConns, const Opm::UnitSystem& units)
|
||||
getSegmentSetSSTerms(const Opm::WellSegments& segSet,
|
||||
const std::vector<Opm::data::Connection>& rateConns,
|
||||
const Opm::WellConnections& welConns,
|
||||
const Opm::UnitSystem& units)
|
||||
{
|
||||
std::vector<double> qosc (segSet.size(), 0.);
|
||||
std::vector<double> qwsc (segSet.size(), 0.);
|
||||
std::vector<double> qgsc (segSet.size(), 0.);
|
||||
std::vector<const Opm::Connection* > openConnections;
|
||||
using M = ::Opm::UnitSystem::measure;
|
||||
using R = ::Opm::data::Rates::opt;
|
||||
for (auto nConn = welConns.size(), connID = 0*nConn; connID < nConn; connID++) {
|
||||
if (welConns[connID].state() == Opm::Connection::State::OPEN) openConnections.push_back(&welConns[connID]);
|
||||
}
|
||||
if (openConnections.size() != rateConns.size()) {
|
||||
throw std::invalid_argument {
|
||||
"Inconsistent number of open connections I in Opm::WellConnections (" +
|
||||
std::to_string(welConns.size()) + ") and vector<Opm::data::Connection> (" +
|
||||
std::to_string(rateConns.size()) + ") in Well " + wname
|
||||
};
|
||||
}
|
||||
for (auto nConn = openConnections.size(), connID = 0*nConn; connID < nConn; connID++) {
|
||||
const auto& segNo = openConnections[connID]->segment();
|
||||
const auto& segInd = segSet.segmentNumberToIndex(segNo);
|
||||
const auto& Q = rateConns[connID].rates;
|
||||
|
||||
using M = ::Opm::UnitSystem::measure;
|
||||
using R = ::Opm::data::Rates::opt;
|
||||
|
||||
for (const auto& conn : welConns) {
|
||||
if (conn.state() != Opm::Connection::State::OPEN) {
|
||||
continue;
|
||||
}
|
||||
|
||||
auto xcPos = std::find_if(rateConns.begin(), rateConns.end(),
|
||||
[&conn](const Opm::data::Connection& xconn) -> bool
|
||||
{
|
||||
return xconn.index == conn.global_index();
|
||||
});
|
||||
|
||||
if (xcPos == rateConns.end()) {
|
||||
continue;
|
||||
}
|
||||
|
||||
const auto segInd = segSet.segmentNumberToIndex(conn.segment());
|
||||
const auto& Q = xcPos->rates;
|
||||
|
||||
auto get = [&units, &Q](const M u, const R q) -> double
|
||||
{
|
||||
@ -225,15 +231,17 @@ namespace {
|
||||
}
|
||||
|
||||
Opm::RestartIO::Helpers::SegmentSetFlowRates
|
||||
getSegmentSetFlowRates(const std::string& wname, const Opm::WellSegments& segSet, const std::vector<Opm::data::Connection>& rateConns,
|
||||
const Opm::WellConnections& welConns, const Opm::UnitSystem& units)
|
||||
getSegmentSetFlowRates(const Opm::WellSegments& segSet,
|
||||
const std::vector<Opm::data::Connection>& rateConns,
|
||||
const Opm::WellConnections& welConns,
|
||||
const Opm::UnitSystem& units)
|
||||
{
|
||||
std::vector<double> sofr (segSet.size(), 0.);
|
||||
std::vector<double> swfr (segSet.size(), 0.);
|
||||
std::vector<double> sgfr (segSet.size(), 0.);
|
||||
//
|
||||
//call function to calculate the individual segment source/sink terms
|
||||
auto sSSST = getSegmentSetSSTerms(wname, segSet, rateConns, welConns, units);
|
||||
auto sSSST = getSegmentSetSSTerms(segSet, rateConns, welConns, units);
|
||||
|
||||
// find an ordered list of segments
|
||||
auto orderedSegmentInd = segmentOrder(segSet);
|
||||
@ -255,6 +263,7 @@ namespace {
|
||||
sgfr[segInd] += sgfr[ifSegInd];
|
||||
}
|
||||
}
|
||||
|
||||
return {
|
||||
sofr,
|
||||
swfr,
|
||||
@ -655,7 +664,7 @@ namespace {
|
||||
// find well connections and calculate segment rates based on well connection production/injection terms
|
||||
auto sSFR = Opm::RestartIO::Helpers::SegmentSetFlowRates{};
|
||||
if (haveWellRes) {
|
||||
sSFR = getSegmentSetFlowRates(well.name(), welSegSet, wRatesIt->second.connections, welConns, units);
|
||||
sSFR = getSegmentSetFlowRates(welSegSet, wRatesIt->second.connections, welConns, units);
|
||||
}
|
||||
|
||||
std::string stringSegNum = std::to_string(segment0.segmentNumber());
|
||||
|
@ -558,6 +558,8 @@ END
|
||||
c.rates.set(o::wat, qw*(float(i)+1.))
|
||||
.set(o::oil, qo*(float(i)+1.))
|
||||
.set(o::gas, qg*(float(i)+1.));
|
||||
|
||||
c.index = 90 + i; // zero-based global index
|
||||
}
|
||||
auto seg = Opm::data::Segment{};
|
||||
for (std::size_t i = 1; i < 5; i++) {
|
||||
@ -576,6 +578,7 @@ END
|
||||
c.rates.set(o::wat, qw*(float(i)+1.))
|
||||
.set(o::oil, 0.)
|
||||
.set(o::gas, 0.);
|
||||
c.index = 409 - i; // zero-based global index
|
||||
}
|
||||
}
|
||||
return xw;
|
||||
|
Loading…
Reference in New Issue
Block a user