diff --git a/CMakeLists.txt b/CMakeLists.txt index 4165e7dd5..f611bca99 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -335,6 +335,13 @@ opm_add_test(test_tuning_xxxMBE ${Boost_UNIT_TEST_FRAMEWORK_LIBRARY} ONLY_COMPILE) +opm_add_test(test_tuning_tsinit_nextstep + SOURCES + tests/test_tuning_TSINIT_NEXTSTEP.cpp + LIBRARIES + ${Boost_UNIT_TEST_FRAMEWORK_LIBRARY} opmcommon + ONLY_COMPILE) + if (HAVE_OPM_TESTS) include (${CMAKE_CURRENT_SOURCE_DIR}/compareECLFiles.cmake) endif() diff --git a/compareECLFiles.cmake b/compareECLFiles.cmake index 4ff683881..572b03b47 100644 --- a/compareECLFiles.cmake +++ b/compareECLFiles.cmake @@ -312,6 +312,14 @@ add_test_runSimulator(CASENAME notuning_xxxmbe set_tests_properties(runSimulator/notuning_xxxmbe PROPERTIES WILL_FAIL TRUE) +add_test_runSimulator(CASENAME tuning_tsinit_nextstep + FILENAME 02_TUNING_TSINIT_NEXTSTEP + SIMULATOR flow + DIR tuning + TEST_ARGS --enable-tuning=true + POST_COMMAND $) + + include (${CMAKE_CURRENT_SOURCE_DIR}/regressionTests.cmake) include (${CMAKE_CURRENT_SOURCE_DIR}/restartTests.cmake) diff --git a/tests/test_tuning_TSINIT_NEXTSTEP.cpp b/tests/test_tuning_TSINIT_NEXTSTEP.cpp new file mode 100644 index 000000000..ec3c4f8db --- /dev/null +++ b/tests/test_tuning_TSINIT_NEXTSTEP.cpp @@ -0,0 +1,52 @@ +#include + +#include +#include +#include + +#define BOOST_TEST_MODULE TestTuningTSINIT +#include + +constexpr double TOLERANCE = 1.0e-10; + +inline bool is_close(double a, double b, double tol = TOLERANCE) { + return std::abs(a-b) <= tol; +} + +BOOST_AUTO_TEST_CASE(CheckTSINITAndNEXTSTEP) +{ + //std::string case_name(boost::unit_test::framework::master_test_suite().argv[1]); + std::string case_name("02_TUNING_TSINIT_NEXTSTEP"); + + BOOST_TEST_MESSAGE("---------------------------------------------------------------------------"); + BOOST_TEST_MESSAGE("Checking TSINIT and NEXTSTEP, see file " + case_name + ".DATA"); + BOOST_TEST_MESSAGE("---------------------------------------------------------------------------"); + + + Opm::EclIO::ESmry smry(case_name, false); + smry.loadData({"TIME"}); + const auto& time = smry.get("TIME"); + + // First time step 1 day + BOOST_CHECK_CLOSE(time[0], 1.0, TOLERANCE); + + for (size_t i=0; i 15.1); + // Persistent NEXTSTEP=0.5 + if (is_close(time[i], 31.0)) BOOST_CHECK_CLOSE(time[i+1], 31.5, TOLERANCE); + if (is_close(time[i], 45.0)) BOOST_CHECK_CLOSE(time[i+1], 45.5, TOLERANCE); + // Non-persistent NEXTSTEP=1.0 + if (is_close(time[i], 60.0)) BOOST_CHECK_CLOSE(time[i+1], 61.0, TOLERANCE); + if (is_close(time[i], 74.0)) BOOST_CHECK(time[i+1] > 75.1); + // TSINIT=0.5 + if (is_close(time[i], 91.0)) BOOST_CHECK_CLOSE(time[i+1], 91.5, TOLERANCE); + if (is_close(time[i], 105.0)) BOOST_CHECK(time[i+1] > 105.6); + } +} +