From d078a96eae8dfbbeedbe137fa271f71a5779b533 Mon Sep 17 00:00:00 2001 From: Joakim Hove Date: Sat, 28 Apr 2018 12:52:28 +0200 Subject: [PATCH] Use RestartValue container for Eclipse output --- opm/output/eclipse/EclipseIO.hpp | 4 +--- opm/output/eclipse/RestartIO.hpp | 6 ++---- src/opm/output/eclipse/EclipseIO.cpp | 10 ++++------ src/opm/output/eclipse/RestartIO.cpp | 20 +++++++++---------- tests/test_EclipseIO.cpp | 17 ++++++++-------- tests/test_RFT.cpp | 17 +++++++++------- tests/test_Restart.cpp | 30 ++++++++++------------------ tests/test_writenumwells.cpp | 3 +-- 8 files changed, 46 insertions(+), 61 deletions(-) diff --git a/opm/output/eclipse/EclipseIO.hpp b/opm/output/eclipse/EclipseIO.hpp index 119996655..4a2c2131b 100644 --- a/opm/output/eclipse/EclipseIO.hpp +++ b/opm/output/eclipse/EclipseIO.hpp @@ -173,12 +173,10 @@ public: void writeTimeStep( int report_step, bool isSubstep, double seconds_elapsed, - data::Solution, - data::Wells, + RestartValue value, const std::map& single_summary_values, const std::map>& region_summary_values, const std::map, double>& block_summary_values, - const std::map>& extra_restart = {}, bool write_double = false); diff --git a/opm/output/eclipse/RestartIO.hpp b/opm/output/eclipse/RestartIO.hpp index c8688db37..d713b133c 100644 --- a/opm/output/eclipse/RestartIO.hpp +++ b/opm/output/eclipse/RestartIO.hpp @@ -75,13 +75,11 @@ namespace RestartIO { void save(const std::string& filename, int report_step, double seconds_elapsed, - data::Solution cells, - data::Wells wells, + RestartValue value, const EclipseState& es, const EclipseGrid& grid, const Schedule& schedule, - std::map> extra_data = {}, - bool write_double = false); + bool write_double = false); RestartValue load( const std::string& filename, diff --git a/src/opm/output/eclipse/EclipseIO.cpp b/src/opm/output/eclipse/EclipseIO.cpp index 9a4a1d7d9..08003d3e0 100644 --- a/src/opm/output/eclipse/EclipseIO.cpp +++ b/src/opm/output/eclipse/EclipseIO.cpp @@ -418,12 +418,10 @@ void EclipseIO::writeInitial( data::Solution simProps, std::map& single_summary_values, const std::map >& region_summary_values, const std::map, double>& block_summary_values, - const std::map>& extra_restart, bool write_double) { @@ -448,7 +446,7 @@ void EclipseIO::writeTimeStep(int report_step, secs_elapsed, es, schedule, - wells , + value.wells , single_summary_values , region_summary_values, block_summary_values); @@ -469,7 +467,7 @@ void EclipseIO::writeTimeStep(int report_step, report_step, ioConfig.getFMTOUT() ); - RestartIO::save( filename , report_step, secs_elapsed, cells, wells, es , grid , schedule, extra_restart , write_double); + RestartIO::save( filename , report_step, secs_elapsed, value, es , grid , schedule, write_double); } @@ -489,7 +487,7 @@ void EclipseIO::writeTimeStep(int report_step, secs_elapsed + this->impl->schedule.posixStartTime(), units.from_si( UnitSystem::measure::time, secs_elapsed ), units, - wells ); + value.wells ); } } diff --git a/src/opm/output/eclipse/RestartIO.cpp b/src/opm/output/eclipse/RestartIO.cpp index 378cdc896..1f1e3877b 100644 --- a/src/opm/output/eclipse/RestartIO.cpp +++ b/src/opm/output/eclipse/RestartIO.cpp @@ -565,16 +565,14 @@ void checkSaveArguments(const data::Solution& cells, void save(const std::string& filename, int report_step, double seconds_elapsed, - data::Solution cells, - data::Wells wells, + RestartValue value, const EclipseState& es, const EclipseGrid& grid, const Schedule& schedule, - std::map> extra_data, - bool write_double) + bool write_double) { - checkSaveArguments( cells, grid, extra_data ); - { + checkSaveArguments( value.solution, grid, value.extra); + { int sim_step = std::max(report_step - 1, 0); int ert_phase_mask = es.runspec().eclPhaseMask( ); const auto& units = es.getUnits(); @@ -588,11 +586,11 @@ void save(const std::string& filename, rst_file.reset( ecl_rst_file_open_write( filename.c_str() ) ); - cells.convertFromSI( units ); - writeHeader( rst_file.get() , sim_step, report_step, posix_time , sim_time, ert_phase_mask, units, schedule , grid ); - writeWell( rst_file.get() , sim_step, es , grid, schedule, wells); - writeSolution( rst_file.get() , cells , write_double ); - writeExtraData( rst_file.get() , extra_data ); + value.solution.convertFromSI( units ); + writeHeader( rst_file.get(), sim_step, report_step, posix_time , sim_time, ert_phase_mask, units, schedule , grid ); + writeWell( rst_file.get(), sim_step, es , grid, schedule, value.wells); + writeSolution( rst_file.get(), value.solution, write_double ); + writeExtraData( rst_file.get(), value.extra ); } } } diff --git a/tests/test_EclipseIO.cpp b/tests/test_EclipseIO.cpp index f6a9f7622..ab0575505 100644 --- a/tests/test_EclipseIO.cpp +++ b/tests/test_EclipseIO.cpp @@ -331,17 +331,16 @@ BOOST_AUTO_TEST_CASE(EclipseIOIntegration) { sol.insert("KRO", measure::identity , std::vector(3*3*3 , i), TargetType::RESTART_AUXILIARY); sol.insert("KRG", measure::identity , std::vector(3*3*3 , i*10), TargetType::RESTART_AUXILIARY); - + RestartValue restart_value(sol, wells); auto first_step = ecl_util_make_date( 10 + i, 11, 2008 ); eclWriter.writeTimeStep( i, - false, - first_step - start_time, - sol, - wells, - {}, - {}, - {}); - + false, + first_step - start_time, + restart_value, + {}, + {}, + {}); + checkRestartFile( i ); diff --git a/tests/test_RFT.cpp b/tests/test_RFT.cpp index 41c4f918f..c9425c284 100644 --- a/tests/test_RFT.cpp +++ b/tests/test_RFT.cpp @@ -144,19 +144,21 @@ BOOST_AUTO_TEST_CASE(test_RFT) { well2_comps[i] = well_comp; } + Opm::data::Solution solution = createBlackoilState(2, numCells); Opm::data::Wells wells; wells["OP_1"] = { r1, 1.0, 1.1, 3.1, 1, well1_comps }; wells["OP_2"] = { r2, 1.0, 1.1, 3.2, 1, well2_comps }; + RestartValue restart_value(solution, wells); + eclipseWriter.writeTimeStep( 2, false, step_time - start_time, - createBlackoilState( 2, numCells ), - wells, - {}, - {}, - {}); + restart_value, + {}, + {}, + {}); } verifyRFTFile("TESTRFT.RFT"); @@ -235,14 +237,15 @@ BOOST_AUTO_TEST_CASE(test_RFT2) { } Opm::data::Wells wells; + Opm::data::Solution solution = createBlackoilState(2, numCells); wells["OP_1"] = { r1, 1.0, 1.1, 3.1, 1, well1_comps }; wells["OP_2"] = { r2, 1.0, 1.1, 3.2, 1, well2_comps }; + RestartValue restart_value(solution, wells); eclipseWriter.writeTimeStep( step, false, step_time - start_time, - createBlackoilState( 2, numCells ), - wells, + restart_value, {}, {}, {}); diff --git a/tests/test_Restart.cpp b/tests/test_Restart.cpp index f92bc3b6b..e2e1b6361 100644 --- a/tests/test_Restart.cpp +++ b/tests/test_Restart.cpp @@ -359,7 +359,8 @@ RestartValue first_sim(const EclipseState& es, EclipseIO& eclWriter, bool write_ eclWriter.writeTimeStep( 1, false, first_step - start_time, - sol, wells , {}, {}, {}, {}, write_double); + RestartValue(sol,wells), + {}, {}, {}, write_double); return { sol, wells , {}}; } @@ -483,8 +484,7 @@ BOOST_AUTO_TEST_CASE(WriteWrongSOlutionSize) { BOOST_CHECK_THROW( RestartIO::save("FILE.UNRST", 1 , 100, - cells , - wells , + RestartValue(cells, wells), setup.es, setup.grid , setup.schedule), @@ -507,12 +507,10 @@ BOOST_AUTO_TEST_CASE(ExtraData_KEYS) { extra["TOO_LONG_KEY"] = {0,1,2,3}; BOOST_CHECK_THROW( RestartIO::save("FILE.UNRST", 1 , 100, - cells , - wells , + RestartValue(cells, wells, extra), setup.es, setup.grid, - setup.schedule, - extra), + setup.schedule), std::runtime_error); } @@ -522,12 +520,10 @@ BOOST_AUTO_TEST_CASE(ExtraData_KEYS) { extra["PRESSURE"] = {0,1,2,3}; BOOST_CHECK_THROW( RestartIO::save("FILE.UNRST", 1 , 100, - cells , - wells , + RestartValue(cells, wells, extra), setup.es, setup.grid, - setup.schedule, - extra), + setup.schedule), std::runtime_error); } @@ -537,12 +533,10 @@ BOOST_AUTO_TEST_CASE(ExtraData_KEYS) { extra["LOGIHEAD"] = {0,1,2,3}; BOOST_CHECK_THROW( RestartIO::save("FILE.UNRST", 1 , 100, - cells , - wells , + RestartValue(cells, wells, extra), setup.es, setup.grid, - setup.schedule, - extra), + setup.schedule), std::runtime_error); } } @@ -560,12 +554,10 @@ BOOST_AUTO_TEST_CASE(ExtraData_content) { extra["EXTRA"] = {0,1,2,3}; RestartIO::save("FILE.UNRST", 1 , 100, - cells , - wells , + RestartValue(cells, wells, extra), setup.es, setup.grid, - setup.schedule, - extra); + setup.schedule); { ecl_file_type * f = ecl_file_open( "FILE.UNRST" , 0 ); diff --git a/tests/test_writenumwells.cpp b/tests/test_writenumwells.cpp index 4e7efd790..980d3644d 100644 --- a/tests/test_writenumwells.cpp +++ b/tests/test_writenumwells.cpp @@ -155,8 +155,7 @@ BOOST_AUTO_TEST_CASE(EclipseWriteRestartWellInfo) { eclipseWriter.writeTimeStep( timestep, false, timestep, - solution, - wells , + RestartValue(solution, wells), {}, {}, {} );