Skip to content

Commit

Permalink
Write MULTPV to INIT-file
Browse files Browse the repository at this point in the history
This output was missing from the init file previously. Now MULTPV will
be output if it is specified in the GRID or EDIT section.  Support for

MULTPV in the SCHEDULE section will be added in an upcoming PR. I need
to sort out the parallel handling of that.

This is is #4015 again
  • Loading branch information
blattms committed Apr 18, 2024
1 parent 2d01972 commit 8dcae7f
Show file tree
Hide file tree
Showing 2 changed files with 209 additions and 2 deletions.
9 changes: 7 additions & 2 deletions opm/output/eclipse/WriteInit.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -667,10 +667,15 @@ void Opm::InitIO::write(const ::Opm::EclipseState& es,
{
const auto writeAll = es.cfg().io().writeAllTransMultipliers();

const auto tranMult = es.getTransMult()
auto multipliers = es.getTransMult()
.convertToSimProps(grid.getNumActive(), writeAll);
if (es.fieldProps().has_double("MULTPV")) {
multipliers.insert("MULTPV", UnitSystem::measure::identity,
es.fieldProps().get_double("MULTPV"),
data::TargetType::INIT);
}

writeSimulatorProperties(grid, tranMult, initFile);
writeSimulatorProperties(grid, multipliers, initFile);
}

writeTableData(es, units, initFile);
Expand Down
202 changes: 202 additions & 0 deletions tests/test_EclipseIO.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -739,3 +739,205 @@ BOOST_AUTO_TEST_CASE(MULTXYZInit)
testMultxyz({ '3', '3' , '2'}, true);
testMultxyz({ '3', '3' , '3'});
}


std::pair<std::string,std::vector<float>>
createMULTPVDECK(bool edit)
{
auto deckString = std::string { R"(RUNSPEC
TITLE
1D OIL WATER
DIMENS
100 1 1 /
EQLDIMS
/
TABDIMS
2 1 100 /
OIL
WATER
ENDSCALE
/
METRIC
START
1 'JAN' 2024 /
WELLDIMS
3 3 2 2 /
UNIFIN
UNIFOUT
GRID
INIT
DX
100*1 /
DY
100*10 /
DZ
100*1 /
TOPS
100*2000 /
PORO
100*0.3 /
MULTPV
100*5 / -- overwritten by the next MULTPV keyword
MULTPV
100*10 / -- partly overwritten by the next BOX statements
BOX
69 75 1 1 1 1 /
MULTPV
2*1 5*1.5 /
ENDBOX
BOX
76 85 1 1 1 1 /
MULTPV
5*1.5 5*1 /
ENDBOX
EDIT
)"};
std::vector<float> multpv(68, 10.);
multpv.insert(multpv.end(), 2, 1);
multpv.insert(multpv.end(), 10, 1.5);
multpv.insert(multpv.end(), 5, 1.);
multpv.insert(multpv.end(), 15, 10.);

if (edit) {
deckString += std::string { R"(MULTPV
75*10 25*10 / -- overwritten by the next
MULTPV
75*0.8 25*1 /
)"};
std::transform(multpv.begin(), multpv.begin() + 75, multpv.begin(),
[](float f) { return f*.8; });
}
deckString += std::string { R"(PROPS
SOLUTION
SCHEDULE
)"};
return { deckString, multpv };
}

void checkMULTPV(const std::pair<std::string, std::vector<float>>& deckAndValues)
{
const auto [deckString, expectedMultPV] = deckAndValues;
const auto deck = Parser().parseString(deckString);
auto es = EclipseState( deck );
const auto& eclGrid = es.getInputGrid();
const Schedule schedule(deck, es, std::make_shared<Python>());
const SummaryConfig summary_config( deck, schedule, es.fieldProps(), es.aquifer());
const SummaryState st(TimeService::now());
es.getIOConfig().setBaseName( "MULTPVFOO" );
EclipseIO eclWriter( es, eclGrid , schedule, summary_config);
eclWriter.writeInitial( );

EclIO::EclFile initFile { "MULTPVFOO.INIT" };
BOOST_CHECK_MESSAGE( initFile.hasKey("MULTPV"),
R"(INIT file must have MULTPV array)" );
const auto& multPVValues = initFile.get<float>("MULTPV");
auto expect = expectedMultPV.begin();
BOOST_CHECK(multPVValues.size() == expectedMultPV.size());

for (auto multVal = multPVValues.begin(); multVal != multPVValues.end();
++multVal, ++expect) {
BOOST_CHECK_CLOSE(*multVal, *expect, 1e-8);
}
}

BOOST_AUTO_TEST_CASE(MULTPVInit)
{
checkMULTPV(createMULTPVDECK(false));
checkMULTPV(createMULTPVDECK(true));

}

std::pair<std::string,std::vector<float>>
createMULTPVBOXDECK()
{
auto deckString = std::string { R"(RUNSPEC
TITLE
1D OIL WATER
DIMENS
100 1 1 /
EQLDIMS
/
TABDIMS
2 1 100 /
OIL
WATER
ENDSCALE
/
METRIC
START
1 'JAN' 2024 /
WELLDIMS
3 3 2 2 /
UNIFIN
UNIFOUT
GRID
INIT
DX
100*1 /
DY
100*10 /
DZ
100*1 /
TOPS
100*2000 /
PORO
100*0.3 /
BOX
11 100 1 1 1 1 /
MULTPV
90*1.5 /
ENDBOX
EDIT
PROPS
SOLUTION
SCHEDULE
)"};
std::vector<float> expected(10, 1.);
expected.insert(expected.end(), 90, 1.5);
return { deckString, expected };
}

BOOST_AUTO_TEST_CASE(MULTPVBOXInit)
{
checkMULTPV(createMULTPVBOXDECK());
}

0 comments on commit 8dcae7f

Please sign in to comment.