Corrected merge conflicts with upstream master

Write cumulative production / injection only in eclipse compatible mode
This commit is contained in:
Jostein Alvestad 2018-09-13 15:54:31 +02:00
parent a3b37eee4f
commit ef6e0b084d
14 changed files with 84 additions and 53 deletions

View File

@ -61,6 +61,7 @@ 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,6 +52,7 @@ 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

@ -150,11 +150,11 @@ namespace {
iConn[Ix::CellJ] = conn.getJ() + 1;
iConn[Ix::CellK] = conn.getK() + 1;
iConn[Ix::ConnStat] = (conn.state == ConnState::OPEN)
iConn[Ix::ConnStat] = (conn.state() == ConnState::OPEN)
? 1 : -1000;
iConn[Ix::Drainage] = conn.getDefaultSatTabId()
? 0 : conn.sat_tableId;
? 0 : conn.satTableId();
// Don't support differing sat-func tables for
// draining and imbibition curves at connections.
@ -163,9 +163,9 @@ namespace {
//iConn[Ix::ComplNum] = std::abs(conn.complnum);
iConn[Ix::ComplNum] = iConn[Ix::SeqIndex];
iConn[Ix::ConnDir] = conn.dir;
iConn[Ix::ConnDir] = conn.dir();
iConn[Ix::Segment] = conn.attachedToSegment()
? conn.segment_number : 0;
? conn.segment() : 0;
}
} // IConn
@ -200,28 +200,14 @@ namespace {
return static_cast<float>(units.from_si(u, x));
};
{
const auto& ctf = conn
.getConnectionTransmissibilityFactorAsValueObject();
sConn[Ix::ConnTrans] =
scprop(M::transmissibility, conn.CF());
if (ctf.hasValue()) {
sConn[Ix::ConnTrans] =
scprop(M::transmissibility, ctf.getValue());
}
}
sConn[Ix::Depth] = scprop(M::length, conn.depth());
sConn[Ix::Diameter] = scprop(M::length, 2*conn.rw());
sConn[Ix::Depth] = scprop(M::length, conn.center_depth);
sConn[Ix::Diameter] = scprop(M::length, conn.getDiameter());
{
const auto& ckh = conn
.getEffectiveKhAsValueObject();
if (ckh.hasValue()) {
sConn[Ix::EffectiveKH] =
scprop(M::effective_Kh, ckh.getValue());
}
}
sConn[Ix::EffectiveKH] =
scprop(M::effective_Kh, conn.Kh());
sConn[Ix::item12] = sConn[Ix::ConnTrans];

View File

@ -430,6 +430,30 @@ 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
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,
@ -438,6 +462,7 @@ 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();
@ -446,7 +471,7 @@ namespace {
const std::map<std::string, size_t>& keyToIndex = (groupName == "FIELD")
? fieldKeyToIndex : groupKeyToIndex;
for (const auto key : keys) {
for (const auto key : filter_cumulative(ecl_compatible_rst,keys)) {
std::string compKey = (groupName == "FIELD")
? key : key + ":" + groupName;
@ -548,6 +573,7 @@ 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)
@ -586,11 +612,11 @@ captureDeclaredGroupData(const Opm::Schedule& sched,
// Define DynamicContributions to XGrp Array.
groupLoop(curGroups,
[restart_group_keys, restart_field_keys, groupKeyToIndex, fieldKeyToIndex, sumState, this]
[restart_group_keys, restart_field_keys, groupKeyToIndex, fieldKeyToIndex, ecl_compatible_rst, 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, xg);
XGrp::dynamicContrib( restart_group_keys, restart_field_keys, groupKeyToIndex, fieldKeyToIndex, group, sumState, ecl_compatible_rst, xg);
});
}

View File

@ -139,7 +139,7 @@ namespace {
auto segNumber = segSet[segIndex].segmentNumber();
int noConnections = 0;
for (auto it : compSet) {
auto cSegment = it.segment_number;
auto cSegment = it.segment();
if (segNumber == cSegment) {
noConnections+=1;
}

View File

@ -614,6 +614,7 @@ 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;
@ -636,11 +637,12 @@ namespace {
xWell[Ix::WatCut] = get("WWCT");
xWell[Ix::GORatio] = get("WGOR");
xWell[Ix::OilPrTotal] = get("WOPT");
xWell[Ix::WatPrTotal] = get("WWPT");
xWell[Ix::GasPrTotal] = get("WGPT");
xWell[Ix::VoidPrTotal] = get("WVPT");
if (ecl_compatible_rst) {
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];
@ -649,6 +651,7 @@ namespace {
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;
@ -664,8 +667,10 @@ namespace {
xWell[Ix::LiqPrRate] = xWell[Ix::WatPrRate];
xWell[Ix::FlowBHP] = get("WBHP");
xWell[Ix::WatInjTotal] = get("WWIT");
if (ecl_compatible_rst) {
xWell[Ix::WatInjTotal] = get("WWIT");
}
xWell[Ix::item37] = xWell[Ix::WatPrRate];
xWell[Ix::item82] = xWell[Ix::WatInjTotal];
@ -676,6 +681,7 @@ 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;
@ -692,8 +698,10 @@ namespace {
xWell[Ix::FlowBHP] = get("WBHP");
xWell[Ix::GasInjTotal] = get("WGIT");
if (ecl_compatible_rst) {
xWell[Ix::GasInjTotal] = get("WGIT");
}
xWell[Ix::GasFVF] = xWell[Ix::VoidPrRate]
/ xWell[Ix::GasPrRate];
@ -708,10 +716,11 @@ 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, xWell);
assignProducer(well.name(), smry, ecl_compatible_rst, xWell);
}
else if (well.isInjector(sim_step)) {
using IType = ::Opm::WellInjector::TypeEnum;
@ -725,16 +734,16 @@ namespace {
break;
case IType::WATER:
assignWaterInjector(well.name(), smry, xWell);
assignWaterInjector(well.name(), smry, ecl_compatible_rst, xWell);
break;
case IType::GAS:
assignGasInjector(well.name(), smry, xWell);
assignGasInjector(well.name(), smry, ecl_compatible_rst, xWell);
break;
case IType::MULTI:
assignWaterInjector(well.name(), smry, xWell);
assignGasInjector (well.name(), smry, xWell);
assignWaterInjector(well.name(), smry, ecl_compatible_rst, xWell);
assignGasInjector (well.name(), smry, ecl_compatible_rst, xWell);
break;
}
}
@ -849,6 +858,7 @@ 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)
{
@ -870,11 +880,11 @@ captureDynamicWellData(const Schedule& sched,
});
// Dynamic contributions to XWEL array.
wellLoop(wells, [this, sim_step, &smry]
wellLoop(wells, [this, sim_step, ecl_compatible_rst, &smry]
(const Well& well, const std::size_t wellID) -> void
{
auto xw = this->xWell_[wellID];
XWell::dynamicContrib(well, smry, sim_step, xw);
XWell::dynamicContrib(well, smry, sim_step, ecl_compatible_rst, xw);
});
}

View File

@ -327,7 +327,7 @@ namespace {
for (const auto& sc : sched_well->getConnections(rst_view.simStep())) {
const auto i = sc.getI(), j = sc.getJ(), k = sc.getK();
if (!grid.cellActive(i, j, k) || sc.state == Opm::WellCompletion::SHUT) {
if (!grid.cellActive(i, j, k) || sc.state() == Opm::WellCompletion::SHUT) {
opm_xwel_data += Opm::data::Connection::restart_size + phases.size();
continue;
}

View File

@ -289,6 +289,7 @@ 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)
@ -306,6 +307,7 @@ 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());
@ -344,7 +346,7 @@ namespace {
{
auto wellData = Helpers::AggregateWellData(ih);
wellData.captureDeclaredWellData(schedule, units, sim_step, sumState, ih);
wellData.captureDynamicWellData(schedule, sim_step, wells, sumState);
wellData.captureDynamicWellData(schedule, sim_step, ecl_compatible_rst, wells, sumState);
write_kw(rst_file, "IWEL", wellData.getIWell());
write_kw(rst_file, "SWEL", wellData.getSWell());
@ -370,7 +372,7 @@ namespace {
write_kw(rst_file, "ICON", connectionData.getIConn());
write_kw(rst_file, "SCON", connectionData.getSConn());
write_kw(rst_file, "XCON", connectionData.getXConn());
//write_kw(rst_file, "XCON", connectionData.getXConn());
}
void writeSolution(ecl_rst_file_type* rst_file,
@ -466,7 +468,7 @@ void save(const std::string& filename,
const auto inteHD = writeHeader(rst_file.get(), sim_step, report_step,
seconds_elapsed, schedule, grid, es);
writeGroup(rst_file.get(), sim_step, schedule, sumState, inteHD);
writeGroup(rst_file.get(), sim_step, ecl_compatible_rst, schedule, sumState, inteHD);
writeMSWData(rst_file.get(), sim_step, units, schedule, grid, inteHD);

View File

@ -180,7 +180,7 @@ namespace Opm {
void Connection::updateSegment(int segment_number, double center_depth, std::size_t seqIndex) {
this->segment_number = segment_number;
this->center_depth = center_depth;
this->seqIndex = seqIndex;
this->m_seqIndex = seqIndex;
}
int Connection::segment() const {

View File

@ -304,7 +304,7 @@ namespace {
std::size_t noConn = prev->getSeqIndex();
// The complnum value carries over; the rest of the state is fully specified by
// the current COMPDAT keyword.
int complnum = prev->complnum;
int complnum = prev->complnum();
*prev = Connection(I,J,k,
complnum,
grid.getCellDepth(I,J,k),

View File

@ -151,8 +151,9 @@ Opm::WellConnections loadCOMPDAT(const std::string& compdat_keyword) {
Opm::Eclipse3DProperties props(deck, tables, grid );
const auto& keyword = deck.getKeyword("COMPDAT", 0);
Opm::WellConnections connections;
std::size_t totnc = 0;
for (const auto& rec : keyword)
connections.loadCOMPDAT(rec, grid, props);
connections.loadCOMPDAT(rec, grid, props, totnc);
return connections;
}

View File

@ -44,6 +44,7 @@
BOOST_AUTO_TEST_CASE(MultisegmentWellTest) {
Opm::WellCompletion::DirectionEnum dir = Opm::WellCompletion::DirectionEnum::Z;
Opm::WellConnections connection_set;
Opm::EclipseGrid grid(20,20,20);
connection_set.add(Opm::Connection( 19, 0, 0, 1, 0.0, Opm::WellCompletion::OPEN , 200, 17.29, 0.25, 0, dir,0, 0., 0., true) );
connection_set.add(Opm::Connection( 19, 0, 1, 1, 0.0, Opm::WellCompletion::OPEN , 200, 17.29, 0.25, 0, dir,0, 0., 0., true) );
connection_set.add(Opm::Connection( 19, 0, 2, 1, 0.0, Opm::WellCompletion::OPEN , 200, 17.29, 0.25, 0, dir,0, 0., 0., true) );

View File

@ -523,7 +523,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, xw, smry);
awd.captureDynamicWellData(simCase.sched, rptStep, true, xw, smry);
// IWEL (OP_1)
{
@ -619,7 +619,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, xw, smry);
awd.captureDynamicWellData(simCase.sched, rptStep, true, xw, smry);
// IWEL (OP_1) -- closed producer
{

View File

@ -503,6 +503,7 @@ BOOST_AUTO_TEST_CASE(ECL_FORMATTED) {
auto num_cells = setup.grid.getNumActive( );
auto cells = mkSolution( num_cells );
auto wells = mkWells();
auto sumState = sim_state();
{
RestartValue restart_value(cells, wells);
@ -514,6 +515,7 @@ BOOST_AUTO_TEST_CASE(ECL_FORMATTED) {
setup.es,
setup.grid,
setup.schedule,
sumState,
true);
{
@ -532,6 +534,7 @@ BOOST_AUTO_TEST_CASE(ECL_FORMATTED) {
setup.es,
setup.grid,
setup.schedule,
sumState,
true);
{
ecl_file_type * rst_file = ecl_file_open( "ECL_FILE.UNRST" , 0 );