/* Copyright 2018 Equinor ASA. This file is part of the Open Porous Media project (OPM). OPM is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. OPM is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with OPM. If not, see . */ #define BOOST_TEST_MODULE MSIM_BASIC #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include using namespace Opm; namespace { double prod_opr(const EclipseState& es, const Schedule& /* sched */, const SummaryState&, const data::Solution& /* sol */, size_t /* report_step */, double seconds_elapsed) { const auto& units = es.getUnits(); return -units.to_si(UnitSystem::measure::rate, seconds_elapsed); } void pressure(const EclipseState& es, const Schedule& /* sched */, data::Solution& sol, size_t /* report_step */, double seconds_elapsed) { const auto& grid = es.getInputGrid(); const auto& units = es.getUnits(); if (!sol.has("PRESSURE")) sol.insert("PRESSURE", UnitSystem::measure::pressure, std::vector(grid.getNumActive()), data::TargetType::RESTART_SOLUTION); auto& data = sol.data("PRESSURE"); std::fill(data.begin(), data.end(), units.to_si(UnitSystem::measure::pressure, seconds_elapsed)); } bool is_file(const Opm::filesystem::path& name) { return Opm::filesystem::exists(name) && Opm::filesystem::is_regular_file(name); } } BOOST_AUTO_TEST_CASE(RUN) { Parser parser; Deck deck = parser.parseFile("SPE1CASE1.DATA"); EclipseState state(deck); Schedule schedule(deck, state); SummaryConfig summary_config(deck, schedule, state.getTableManager()); msim msim(state); msim.well_rate("PROD", data::Rates::opt::oil, prod_opr); msim.solution("PRESSURE", pressure); { const WorkArea work_area("test_msim"); EclipseIO io(state, state.getInputGrid(), schedule, summary_config); msim.run(schedule, io, false); for (const auto& fname : {"SPE1CASE1.INIT", "SPE1CASE1.UNRST", "SPE1CASE1.EGRID", "SPE1CASE1.SMSPEC", "SPE1CASE1.UNSMRY"}) BOOST_CHECK( is_file( fname )); { const auto smry = EclIO::ESmry("SPE1CASE1"); const auto& time = smry.get("TIME"); const auto& press = smry.get("WOPR:PROD"); for (auto nstep = time.size(), time_index=0*nstep; time_index < nstep; time_index++) { double seconds_elapsed = time[time_index] * 86400; BOOST_CHECK_CLOSE(seconds_elapsed, press[time_index], 1e-3); } } { auto rst = EclIO::ERst("SPE1CASE1.UNRST"); for (const auto& step : rst.listOfReportStepNumbers()) { const auto& dh = rst.getRst("DOUBHEAD", step, 0); const auto& press = rst.getRst("PRESSURE", step, 0); // DOUBHEAD[0] is elapsed time in days since start of simulation. BOOST_CHECK_CLOSE( press[0], dh[0] * 86400, 1e-3 ); } } } }