Restart: Provide Continuous Cumulatives in OPM Extended Files

This commit removes the restriction that cumulative totals are not
output in the case of creating OPM Extended Restart files.  There
was a reason why we did not do this when the new restart facility
was introduced, but that reason no longer applies.
This commit is contained in:
Bård Skaflestad 2019-04-28 21:33:28 +02:00
parent 9d8b08a8d8
commit d08760a922
7 changed files with 29 additions and 75 deletions

View File

@ -61,7 +61,6 @@ namespace Opm { namespace RestartIO { namespace Helpers {
const std::vector<std::string>& restart_field_keys,
const std::map<std::string, size_t>& groupKeyToIndex,
const std::map<std::string, size_t>& fieldKeyToIndex,
const bool ecl_compatible_rst,
const std::size_t simStep,
const Opm::SummaryState& sumState,
const std::vector<int>& inteHead);

View File

@ -52,7 +52,6 @@ namespace Opm { namespace RestartIO { namespace Helpers {
void captureDynamicWellData(const Opm::Schedule& sched,
const std::size_t sim_step,
const bool ecl_compatible_rst,
const Opm::data::WellRates& xw,
const Opm::SummaryState& smry);

View File

@ -369,31 +369,6 @@ namespace {
};
}
std::vector<std::string>
filter_cumulative(const bool ecl_compatible_rst,
const std::vector<std::string>& keys)
{
if (ecl_compatible_rst) {
// User wants ECLIPSE-compatible output. Write all vectors.
return keys;
}
auto ret = std::vector<std::string>{};
ret.reserve(keys.size());
for (const auto& key : keys) {
if ((key[3] == 'T') && ((key[2] == 'I') || (key[2] == 'P'))) {
// Don't write cumulative quantities in case of OPM
// extended restart files.
continue;
}
ret.push_back(key);
}
return ret;
}
// here define the dynamic group quantities to be written to the restart file
template <class XGrpArray>
void dynamicContrib(const std::vector<std::string>& restart_group_keys,
@ -402,7 +377,6 @@ namespace {
const std::map<std::string, size_t>& fieldKeyToIndex,
const Opm::Group& group,
const Opm::SummaryState& sumState,
const bool ecl_compatible_rst,
XGrpArray& xGrp)
{
std::string groupName = group.name();
@ -411,7 +385,7 @@ namespace {
const std::map<std::string, size_t>& keyToIndex = (groupName == "FIELD")
? fieldKeyToIndex : groupKeyToIndex;
for (const auto key : filter_cumulative(ecl_compatible_rst,keys)) {
for (const auto& key : keys) {
std::string compKey = (groupName == "FIELD")
? key : key + ":" + groupName;
@ -517,7 +491,6 @@ captureDeclaredGroupData(const Opm::Schedule& sched,
const std::vector<std::string>& restart_field_keys,
const std::map<std::string, size_t>& groupKeyToIndex,
const std::map<std::string, size_t>& fieldKeyToIndex,
const bool ecl_compatible_rst,
const std::size_t simStep,
const Opm::SummaryState& sumState,
const std::vector<int>& inteHead)
@ -554,14 +527,14 @@ captureDeclaredGroupData(const Opm::Schedule& sched,
// Define Dynamic Contributions to XGrp Array.
groupLoop(curGroups, [&restart_group_keys, &restart_field_keys,
&groupKeyToIndex, &fieldKeyToIndex,
ecl_compatible_rst, &sumState, this]
&sumState, this]
(const Group& group, const std::size_t groupID) -> void
{
auto xg = this->xGroup_[groupID];
XGrp::dynamicContrib(restart_group_keys, restart_field_keys,
groupKeyToIndex, fieldKeyToIndex, group,
sumState, ecl_compatible_rst, xg);
sumState, xg);
});
// Define Static Contributions to ZGrp Array.

View File

@ -613,7 +613,6 @@ namespace {
template <class XWellArray>
void assignProducer(const std::string& well,
const ::Opm::SummaryState& smry,
const bool ecl_compatible_rst,
XWellArray& xWell)
{
using Ix = ::Opm::RestartIO::Helpers::VectorItems::XWell::index;
@ -638,47 +637,39 @@ namespace {
xWell[Ix::WatCut] = get("WWCT");
xWell[Ix::GORatio] = get("WGOR");
if (ecl_compatible_rst) {
xWell[Ix::OilPrTotal] = get("WOPT");
xWell[Ix::WatPrTotal] = get("WWPT");
xWell[Ix::GasPrTotal] = get("WGPT");
xWell[Ix::VoidPrTotal] = get("WVPT");
}
xWell[Ix::OilPrTotal] = get("WOPT");
xWell[Ix::WatPrTotal] = get("WWPT");
xWell[Ix::GasPrTotal] = get("WGPT");
xWell[Ix::VoidPrTotal] = get("WVPT");
// Not fully characterised.
xWell[Ix::item37] = xWell[Ix::WatPrRate];
xWell[Ix::item38] = xWell[Ix::GasPrRate];
if (ecl_compatible_rst) {
xWell[Ix::HistOilPrTotal] = get("WOPTH");
xWell[Ix::HistWatPrTotal] = get("WWPTH");
xWell[Ix::HistGasPrTotal] = get("WGPTH");
}
xWell[Ix::HistOilPrTotal] = get("WOPTH");
xWell[Ix::HistWatPrTotal] = get("WWPTH");
xWell[Ix::HistGasPrTotal] = get("WGPTH");
}
template <class GetSummaryVector, class XWellArray>
void assignCommonInjector(GetSummaryVector& get,
const bool ecl_compatible_rst,
XWellArray& xWell)
{
using Ix = ::Opm::RestartIO::Helpers::VectorItems::XWell::index;
xWell[Ix::FlowBHP] = get("WBHP");
if (ecl_compatible_rst) {
// Note: Assign both water and gas cumulatives to support
// case of well alternating between injecting water and gas.
xWell[Ix::WatInjTotal] = get("WWIT");
xWell[Ix::GasInjTotal] = get("WGIT");
xWell[Ix::HistWatInjTotal] = get("WWITH");
xWell[Ix::HistGasInjTotal] = get("WGITH");
}
// Note: Assign both water and gas cumulatives to support
// case of well alternating between injecting water and gas.
xWell[Ix::WatInjTotal] = get("WWIT");
xWell[Ix::GasInjTotal] = get("WGIT");
xWell[Ix::HistWatInjTotal] = get("WWITH");
xWell[Ix::HistGasInjTotal] = get("WGITH");
}
template <class XWellArray>
void assignWaterInjector(const std::string& well,
const ::Opm::SummaryState& smry,
const bool ecl_compatible_rst,
XWellArray& xWell)
{
using Ix = ::Opm::RestartIO::Helpers::VectorItems::XWell::index;
@ -690,7 +681,7 @@ namespace {
return smry.has(key) ? smry.get(key) : 0.0;
};
assignCommonInjector(get, ecl_compatible_rst, xWell);
assignCommonInjector(get, xWell);
// Injection rates reported as negative.
xWell[Ix::WatPrRate] = -get("WWIR");
@ -705,7 +696,6 @@ namespace {
template <class XWellArray>
void assignGasInjector(const std::string& well,
const ::Opm::SummaryState& smry,
const bool ecl_compatible_rst,
XWellArray& xWell)
{
using Ix = ::Opm::RestartIO::Helpers::VectorItems::XWell::index;
@ -717,7 +707,7 @@ namespace {
return smry.has(key) ? smry.get(key) : 0.0;
};
assignCommonInjector(get, ecl_compatible_rst, xWell);
assignCommonInjector(get, xWell);
// Injection rates reported as negative production rates.
xWell[Ix::GasPrRate] = -get("WGIR");
@ -741,11 +731,10 @@ namespace {
void dynamicContrib(const ::Opm::Well& well,
const ::Opm::SummaryState& smry,
const std::size_t sim_step,
const bool ecl_compatible_rst,
XWellArray& xWell)
{
if (well.isProducer(sim_step)) {
assignProducer(well.name(), smry, ecl_compatible_rst, xWell);
assignProducer(well.name(), smry, xWell);
}
else if (well.isInjector(sim_step)) {
using IType = ::Opm::WellInjector::TypeEnum;
@ -759,16 +748,16 @@ namespace {
break;
case IType::WATER:
assignWaterInjector(well.name(), smry, ecl_compatible_rst, xWell);
assignWaterInjector(well.name(), smry, xWell);
break;
case IType::GAS:
assignGasInjector(well.name(), smry, ecl_compatible_rst, xWell);
assignGasInjector(well.name(), smry, xWell);
break;
case IType::MULTI:
assignWaterInjector(well.name(), smry, ecl_compatible_rst, xWell);
assignGasInjector (well.name(), smry, ecl_compatible_rst, xWell);
assignWaterInjector(well.name(), smry, xWell);
assignGasInjector (well.name(), smry, xWell);
break;
}
}
@ -883,7 +872,6 @@ void
Opm::RestartIO::Helpers::AggregateWellData::
captureDynamicWellData(const Schedule& sched,
const std::size_t sim_step,
const bool ecl_compatible_rst,
const Opm::data::WellRates& xw,
const ::Opm::SummaryState& smry)
{
@ -905,11 +893,11 @@ captureDynamicWellData(const Schedule& sched,
});
// Dynamic contributions to XWEL array.
wellLoop(wells, [this, sim_step, ecl_compatible_rst, &smry]
wellLoop(wells, [this, sim_step, &smry]
(const Well& well, const std::size_t wellID) -> void
{
auto xw = this->xWell_[wellID];
XWell::dynamicContrib(well, smry, sim_step, ecl_compatible_rst, xw);
XWell::dynamicContrib(well, smry, sim_step, xw);
});
}

View File

@ -302,7 +302,6 @@ namespace {
void writeGroup(::Opm::RestartIO::ecl_rst_file_type* rst_file,
int sim_step,
const bool ecl_compatible_rst,
const Schedule& schedule,
const Opm::SummaryState& sumState,
const std::vector<int>& ih)
@ -320,8 +319,8 @@ namespace {
groupData.captureDeclaredGroupData(schedule,
rst_g_keys, rst_f_keys,
grpKeyToInd, fldKeyToInd,
ecl_compatible_rst,
simStep, sumState, ih);
write_kw(rst_file, "IGRP", groupData.getIGroup());
write_kw(rst_file, "SGRP", groupData.getSGroup());
write_kw(rst_file, "XGRP", groupData.getXGroup());
@ -364,7 +363,6 @@ namespace {
auto wellData = Helpers::AggregateWellData(ih);
wellData.captureDeclaredWellData(schedule, units, sim_step, sumState, ih);
wellData.captureDynamicWellData(schedule, sim_step,
ecl_compatible_rst,
wells, sumState);
write_kw(rst_file, "IWEL", wellData.getIWell());
@ -555,8 +553,7 @@ void save(const std::string& filename,
nextStepSize(value), seconds_elapsed,
schedule, grid, es);
writeGroup(rst_file.get(), sim_step, ecl_compatible_rst,
schedule, sumState, inteHD);
writeGroup(rst_file.get(), sim_step, schedule, sumState, inteHD);
// Write well and MSW data only when applicable (i.e., when present)
{

View File

@ -503,11 +503,9 @@ BOOST_AUTO_TEST_CASE (Declared_Group_Data)
const auto& rst_f_keys = agrpd.restart_field_keys;
const auto& grpKeyToInd = agrpd.groupKeyToIndex;
const auto& fldKeyToInd = agrpd.fieldKeyToIndex;
const bool ecl_compatible_rst = true;
agrpd.captureDeclaredGroupData(simCase.sched,
rst_g_keys, rst_f_keys,
grpKeyToInd, fldKeyToInd,
ecl_compatible_rst,
rptStep, smry,
ih.value);

View File

@ -538,7 +538,7 @@ BOOST_AUTO_TEST_CASE (Dynamic_Well_Data_Step1)
const auto smry = sim_state();
auto awd = Opm::RestartIO::Helpers::AggregateWellData{ih.value};
awd.captureDynamicWellData(simCase.sched, rptStep, true, xw, smry);
awd.captureDynamicWellData(simCase.sched, rptStep, xw, smry);
// IWEL (OP_1)
{
@ -645,7 +645,7 @@ BOOST_AUTO_TEST_CASE (Dynamic_Well_Data_Step2)
const auto smry = sim_state();
auto awd = Opm::RestartIO::Helpers::AggregateWellData{ih.value};
awd.captureDynamicWellData(simCase.sched, rptStep, true, xw, smry);
awd.captureDynamicWellData(simCase.sched, rptStep, xw, smry);
// IWEL (OP_1) -- closed producer
{