/* Copyright 2024 Equinor AS 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 . */ #include #define BOOST_TEST_MODULE TestOilPhaseConsistencyChecks #ifndef HAVE_MPI // Suppress GCC diagnostics of the form // // warning: "HAVE_MPI" is not defined, evaluates to 0 // // when compiling with "-Wundef". #define HAVE_MPI 0 #endif // HAVE_MPI #include #include #include #include #include #include // ########################################################################### namespace Checks = Opm::Satfunc::PhaseChecks::Oil; // =========================================================================== BOOST_AUTO_TEST_SUITE(Gas_Oil_System) // --------------------------------------------------------------------------- BOOST_AUTO_TEST_SUITE(Sogcr) BOOST_AUTO_TEST_CASE(All_Good) { auto check = Checks::SOcr_GO{}; BOOST_CHECK_EQUAL(check.numExportedCheckValues(), std::size_t{1}); { auto column = std::string{}; check.columnNames(&column); BOOST_CHECK_EQUAL(column, "SOGCR"); } { auto endPoints = Opm::EclEpsScalingPointsInfo{}; endPoints.Sogcr = 0.3f; // >= 0 && < 1 check.test(endPoints); } { auto value = -0.1f; check.exportCheckValues(&value); BOOST_CHECK_CLOSE(value, 0.3f, 1.0e-6f); } BOOST_CHECK_MESSAGE(! check.isViolated(), "Test must not be violated"); BOOST_CHECK_MESSAGE(! check.isCritical(), "Test must not be violated at critical level"); } BOOST_AUTO_TEST_CASE(Non_Finite) { // NaN if constexpr (std::numeric_limits::has_quiet_NaN) { auto endPoints = Opm::EclEpsScalingPointsInfo{}; endPoints.Sogcr = std::numeric_limits::quiet_NaN(); auto check = Checks::SOcr_GO{}; check.test(endPoints); auto value = -0.1f; check.exportCheckValues(&value); BOOST_CHECK_MESSAGE(std::isnan(value), "Sogcr value must be NaN"); BOOST_CHECK_MESSAGE(check.isViolated(), "Check must be violated"); BOOST_CHECK_MESSAGE(check.isCritical(), "Check must be violated at critical level"); } // Inf if constexpr (std::numeric_limits::has_infinity) { auto endPoints = Opm::EclEpsScalingPointsInfo{}; endPoints.Sogcr = std::numeric_limits::infinity(); auto check = Checks::SOcr_GO{}; check.test(endPoints); auto value = -0.1f; check.exportCheckValues(&value); BOOST_CHECK_MESSAGE(std::isinf(value), "Sogcr value must be Inf"); BOOST_CHECK_MESSAGE(check.isViolated(), "Check must be violated"); BOOST_CHECK_MESSAGE(check.isCritical(), "Check must be violated at critical level"); } } BOOST_AUTO_TEST_CASE(Negative) { auto check = Checks::SOcr_GO{}; auto endPoints = Opm::EclEpsScalingPointsInfo{}; endPoints.Sogcr = -0.01; // < 0 check.test(endPoints); { auto value = 1.0; check.exportCheckValues(&value); BOOST_CHECK_CLOSE(value, -0.01, 1.0e-8); } BOOST_CHECK_MESSAGE(check.isViolated(), "Test must be violated"); BOOST_CHECK_MESSAGE(check.isCritical(), "Test must be violated at critical level"); } BOOST_AUTO_TEST_CASE(Is_One) { auto check = Checks::SOcr_GO{}; auto endPoints = Opm::EclEpsScalingPointsInfo{}; endPoints.Sogcr = 1.0; // >= 1 check.test(endPoints); { auto value = 0.0; check.exportCheckValues(&value); BOOST_CHECK_CLOSE(value, 1.0, 1.0e-8); } BOOST_CHECK_MESSAGE(check.isViolated(), "Test must be violated"); BOOST_CHECK_MESSAGE(check.isCritical(), "Test must be violated at critical level"); } BOOST_AUTO_TEST_CASE(Exceeds_One) { auto check = Checks::SOcr_GO{}; auto endPoints = Opm::EclEpsScalingPointsInfo{}; endPoints.Sogcr = 1.2; // >= 1 check.test(endPoints); { auto value = 0.0; check.exportCheckValues(&value); BOOST_CHECK_CLOSE(value, 1.2, 1.0e-8); } BOOST_CHECK_MESSAGE(check.isViolated(), "Test must be violated"); BOOST_CHECK_MESSAGE(check.isCritical(), "Test must be violated at critical level"); } BOOST_AUTO_TEST_SUITE_END() // Sogcr // --------------------------------------------------------------------------- BOOST_AUTO_TEST_SUITE(So_min) BOOST_AUTO_TEST_CASE(All_Good) { auto check = Checks::SOmin_GO{}; BOOST_CHECK_EQUAL(check.numExportedCheckValues(), std::size_t{3}); { auto columns = std::vector(3); check.columnNames(columns.data()); BOOST_CHECK_EQUAL(columns[0], "SWL"); BOOST_CHECK_EQUAL(columns[1], "SGU"); BOOST_CHECK_EQUAL(columns[2], "SWL + SGU"); } { auto endPoints = Opm::EclEpsScalingPointsInfo{}; endPoints.Swl = 0.09; endPoints.Sgu = 0.9; check.test(endPoints); } { auto values = std::vector(3); check.exportCheckValues(values.data()); BOOST_CHECK_CLOSE(values[0], 0.09, 1.0e-8); BOOST_CHECK_CLOSE(values[1], 0.9 , 1.0e-8); BOOST_CHECK_CLOSE(values[2], 0.99, 1.0e-8); } BOOST_CHECK_MESSAGE(! check.isViolated(), "Test must not be violated"); BOOST_CHECK_MESSAGE(! check.isCritical(), "Test must not be violated at critical level"); } BOOST_AUTO_TEST_CASE(Non_Finite) { // NaN if constexpr (std::numeric_limits::has_quiet_NaN) { auto endPoints = Opm::EclEpsScalingPointsInfo{}; endPoints.Swl = std::numeric_limits::quiet_NaN(); endPoints.Sgu = 0.75f; auto check = Checks::SOmin_GO{}; check.test(endPoints); { auto values = std::vector(3); check.exportCheckValues(values.data()); BOOST_CHECK_MESSAGE(std::isnan(values[0]), "Swl value must be NaN"); BOOST_CHECK_CLOSE (values[1], 0.75f, 1.0e-6f); BOOST_CHECK_MESSAGE(std::isnan(values[2]), "Swl + Sgu value must be NaN"); BOOST_CHECK_MESSAGE(check.isViolated(), "Check must be violated"); BOOST_CHECK_MESSAGE(check.isCritical(), "Check must be violated at critical level"); } endPoints.Swl = 0.75f; endPoints.Sgu = std::numeric_limits::quiet_NaN(); check.test(endPoints); { auto values = std::vector(3); check.exportCheckValues(values.data()); BOOST_CHECK_CLOSE (values[0], 0.75f, 1.0e-6f); BOOST_CHECK_MESSAGE(std::isnan(values[1]), "Sgu value must be NaN"); BOOST_CHECK_MESSAGE(std::isnan(values[2]), "Swl + Sgu value must be NaN"); BOOST_CHECK_MESSAGE(check.isViolated(), "Check must be violated"); BOOST_CHECK_MESSAGE(check.isCritical(), "Check must be violated at critical level"); } endPoints.Swl = std::numeric_limits::quiet_NaN(); endPoints.Sgu = std::numeric_limits::quiet_NaN(); check.test(endPoints); { auto values = std::vector(3); check.exportCheckValues(values.data()); BOOST_CHECK_MESSAGE(std::isnan(values[0]), "Swl value must be NaN"); BOOST_CHECK_MESSAGE(std::isnan(values[1]), "Sgu value must be NaN"); BOOST_CHECK_MESSAGE(std::isnan(values[2]), "Swl + Sgu value must be NaN"); BOOST_CHECK_MESSAGE(check.isViolated(), "Check must be violated"); BOOST_CHECK_MESSAGE(check.isCritical(), "Check must be violated at critical level"); } } // Inf if constexpr (std::numeric_limits::has_infinity) { auto endPoints = Opm::EclEpsScalingPointsInfo{}; endPoints.Swl = std::numeric_limits::infinity(); endPoints.Sgu = 0.75f; auto check = Checks::SOmin_GO{}; check.test(endPoints); { auto values = std::vector(3); check.exportCheckValues(values.data()); BOOST_CHECK_MESSAGE(std::isinf(values[0]), "Swl value must be Inf"); BOOST_CHECK_CLOSE (values[1], 0.75f, 1.0e-6f); BOOST_CHECK_MESSAGE(std::isinf(values[2]), "Swl + Sgu value must be Inf"); BOOST_CHECK_MESSAGE(check.isViolated(), "Check must be violated"); BOOST_CHECK_MESSAGE(check.isCritical(), "Check must be violated at critical level"); } endPoints.Swl = 0.75f; endPoints.Sgu = std::numeric_limits::infinity(); check.test(endPoints); { auto values = std::vector(3); check.exportCheckValues(values.data()); BOOST_CHECK_CLOSE (values[0], 0.75f, 1.0e-6f); BOOST_CHECK_MESSAGE(std::isinf(values[1]), "Sgu value must be Inf"); BOOST_CHECK_MESSAGE(std::isinf(values[2]), "Swl + Sgu value must be Inf"); BOOST_CHECK_MESSAGE(check.isViolated(), "Check must be violated"); BOOST_CHECK_MESSAGE(check.isCritical(), "Check must be violated at critical level"); } endPoints.Swl = std::numeric_limits::infinity(); endPoints.Sgu = std::numeric_limits::infinity(); check.test(endPoints); { auto values = std::vector(3); check.exportCheckValues(values.data()); BOOST_CHECK_MESSAGE(std::isinf(values[0]), "Swl value must be Inf"); BOOST_CHECK_MESSAGE(std::isinf(values[1]), "Sgu value must be Inf"); BOOST_CHECK_MESSAGE(std::isinf(values[2]), "Swl + Sgu value must be Inf"); BOOST_CHECK_MESSAGE(check.isViolated(), "Check must be violated"); BOOST_CHECK_MESSAGE(check.isCritical(), "Check must be violated at critical level"); } } } BOOST_AUTO_TEST_CASE(Swl_TooLarge) { auto check = Checks::SOmin_GO{}; { auto endPoints = Opm::EclEpsScalingPointsInfo{}; endPoints.Swl = 0.15; endPoints.Sgu = 0.9; check.test(endPoints); } { auto values = std::vector(3); check.exportCheckValues(values.data()); BOOST_CHECK_CLOSE(values[0], 0.15, 1.0e-8); BOOST_CHECK_CLOSE(values[1], 0.9 , 1.0e-8); BOOST_CHECK_CLOSE(values[2], 1.05, 1.0e-8); } BOOST_CHECK_MESSAGE(check.isViolated(), "Test must be violated"); BOOST_CHECK_MESSAGE(! check.isCritical(), "Test must not be violated at critical level"); } BOOST_AUTO_TEST_CASE(Sgu_TooLarge) { auto check = Checks::SOmin_GO{}; { auto endPoints = Opm::EclEpsScalingPointsInfo{}; endPoints.Swl = 0.1; endPoints.Sgu = 0.95; check.test(endPoints); } { auto values = std::vector(3); check.exportCheckValues(values.data()); BOOST_CHECK_CLOSE(values[0], 0.1 , 1.0e-8); BOOST_CHECK_CLOSE(values[1], 0.95, 1.0e-8); BOOST_CHECK_CLOSE(values[2], 1.05, 1.0e-8); } BOOST_CHECK_MESSAGE(check.isViolated(), "Test must be violated"); BOOST_CHECK_MESSAGE(! check.isCritical(), "Test must not be violated at critical level"); } BOOST_AUTO_TEST_SUITE_END() // So_min // --------------------------------------------------------------------------- BOOST_AUTO_TEST_SUITE(Mobile_Oil_Sgmin) BOOST_AUTO_TEST_CASE(All_Good) { auto check = Checks::MobileOil_GO_SGmin{}; const auto expectNumExported = std::size_t{4}; BOOST_CHECK_EQUAL(check.numExportedCheckValues(), expectNumExported); { auto columns = std::vector(expectNumExported); check.columnNames(columns.data()); BOOST_CHECK_EQUAL(columns[0], "SWL"); BOOST_CHECK_EQUAL(columns[1], "SGL"); BOOST_CHECK_EQUAL(columns[2], "SOGCR"); BOOST_CHECK_EQUAL(columns[3], "1 - SWL - SGL"); } { auto endPoints = Opm::EclEpsScalingPointsInfo{}; endPoints.Swl = 0.15f; endPoints.Sgl = 0.01f; endPoints.Sogcr = 0.15f; check.test(endPoints); } { auto values = std::vector(expectNumExported); check.exportCheckValues(values.data()); BOOST_CHECK_CLOSE(values[0], 0.15f, 1.0e-6f); BOOST_CHECK_CLOSE(values[1], 0.01f, 1.0e-6f); BOOST_CHECK_CLOSE(values[2], 0.15f, 1.0e-6f); BOOST_CHECK_CLOSE(values[3], 1.0f - 0.15f - 0.01, 1.0e-5f); } BOOST_CHECK_MESSAGE(! check.isViolated(), "Test must not be violated"); BOOST_CHECK_MESSAGE(! check.isCritical(), "Test must not be violated at critical level"); } BOOST_AUTO_TEST_CASE(Non_Finite) { // NaN if constexpr (std::numeric_limits::has_quiet_NaN) { const auto expectNumExported = std::size_t{4}; auto endPoints = Opm::EclEpsScalingPointsInfo{}; endPoints.Swl = std::numeric_limits::quiet_NaN(); endPoints.Sgl = 0.01f; endPoints.Sogcr = 0.32f; auto check = Checks::MobileOil_GO_SGmin{}; check.test(endPoints); { auto values = std::vector(expectNumExported); check.exportCheckValues(values.data()); BOOST_CHECK_MESSAGE(std::isnan(values[0]), "Swl value must be NaN"); BOOST_CHECK_CLOSE (values[1], 0.01f, 1.0e-6f); BOOST_CHECK_CLOSE (values[2], 0.32f, 1.0e-6f); BOOST_CHECK_MESSAGE(std::isnan(values[3]), "1 - Swl - Sgl value must be NaN"); BOOST_CHECK_MESSAGE(check.isViolated(), "Check must be violated"); BOOST_CHECK_MESSAGE(check.isCritical(), "Check must be violated at critical level"); } endPoints.Swl = 0.6f; endPoints.Sgl = std::numeric_limits::quiet_NaN(); endPoints.Sogcr = 0.32f; check.test(endPoints); { auto values = std::vector(expectNumExported); check.exportCheckValues(values.data()); BOOST_CHECK_CLOSE (values[0], 0.6f, 1.0e-6f); BOOST_CHECK_MESSAGE(std::isnan(values[1]), "Sgl value must be NaN"); BOOST_CHECK_CLOSE (values[2], 0.32f, 1.0e-6f); BOOST_CHECK_MESSAGE(std::isnan(values[3]), "1 - Swl - Sgl value must be NaN"); BOOST_CHECK_MESSAGE(check.isViolated(), "Check must be violated"); BOOST_CHECK_MESSAGE(check.isCritical(), "Check must be violated at critical level"); } endPoints.Swl = 0.6f; endPoints.Sgl = 0.01f; endPoints.Sogcr = std::numeric_limits::quiet_NaN(); check.test(endPoints); { auto values = std::vector(expectNumExported); check.exportCheckValues(values.data()); BOOST_CHECK_CLOSE (values[0], 0.6f, 1.0e-6f); BOOST_CHECK_CLOSE (values[1], 0.01f, 1.0e-6f); BOOST_CHECK_MESSAGE(std::isnan(values[2]), "Sogcr value must be NaN"); BOOST_CHECK_CLOSE (values[3], 1.0f - 0.6f - 0.01f, 1.0e-6); BOOST_CHECK_MESSAGE(check.isViolated(), "Check must be violated"); BOOST_CHECK_MESSAGE(check.isCritical(), "Check must be violated at critical level"); } endPoints.Swl = std::numeric_limits::quiet_NaN(); endPoints.Sgl = std::numeric_limits::quiet_NaN(); endPoints.Sogcr = 0.32f; check.test(endPoints); { auto values = std::vector(expectNumExported); check.exportCheckValues(values.data()); BOOST_CHECK_MESSAGE(std::isnan(values[0]), "Swl value must be NaN"); BOOST_CHECK_MESSAGE(std::isnan(values[1]), "Sgl value must be NaN"); BOOST_CHECK_CLOSE (values[2], 0.32f, 1.0e-6f); BOOST_CHECK_MESSAGE(std::isnan(values[3]), "1 - Swl - Sgl value must be NaN"); BOOST_CHECK_MESSAGE(check.isViolated(), "Check must be violated"); BOOST_CHECK_MESSAGE(check.isCritical(), "Check must be violated at critical level"); } endPoints.Swl = std::numeric_limits::quiet_NaN(); endPoints.Sgl = 0.01f; endPoints.Sogcr = std::numeric_limits::quiet_NaN(); check.test(endPoints); { auto values = std::vector(expectNumExported); check.exportCheckValues(values.data()); BOOST_CHECK_MESSAGE(std::isnan(values[0]), "Swl value must be NaN"); BOOST_CHECK_CLOSE (values[1], 0.01f, 1.0e-6f); BOOST_CHECK_MESSAGE(std::isnan(values[2]), "Sogcr value must be NaN"); BOOST_CHECK_MESSAGE(std::isnan(values[3]), "1 - Swl - Sgl value must be NaN"); BOOST_CHECK_MESSAGE(check.isViolated(), "Check must be violated"); BOOST_CHECK_MESSAGE(check.isCritical(), "Check must be violated at critical level"); } endPoints.Swl = std::numeric_limits::quiet_NaN(); endPoints.Sgl = std::numeric_limits::quiet_NaN(); endPoints.Sogcr = std::numeric_limits::quiet_NaN(); check.test(endPoints); { auto values = std::vector(expectNumExported); check.exportCheckValues(values.data()); BOOST_CHECK_MESSAGE(std::isnan(values[0]), "Swl value must be NaN"); BOOST_CHECK_MESSAGE(std::isnan(values[1]), "Sgl value must be NaN"); BOOST_CHECK_MESSAGE(std::isnan(values[2]), "Sogcr value must be NaN"); BOOST_CHECK_MESSAGE(std::isnan(values[3]), "1 - Swl - Sgl value must be NaN"); BOOST_CHECK_MESSAGE(check.isViolated(), "Check must be violated"); BOOST_CHECK_MESSAGE(check.isCritical(), "Check must be violated at critical level"); } } // Inf if constexpr (std::numeric_limits::has_infinity) { const auto expectNumExported = std::size_t{4}; auto endPoints = Opm::EclEpsScalingPointsInfo{}; endPoints.Swl = std::numeric_limits::infinity(); endPoints.Sgl = 0.01f; endPoints.Sogcr = 0.32f; auto check = Checks::MobileOil_GO_SGmin{}; check.test(endPoints); { auto values = std::vector(expectNumExported); check.exportCheckValues(values.data()); BOOST_CHECK_MESSAGE(std::isinf(values[0]), "Swl value must be Inf"); BOOST_CHECK_CLOSE (values[1], 0.01f, 1.0e-6f); BOOST_CHECK_CLOSE (values[2], 0.32f, 1.0e-6f); BOOST_CHECK_MESSAGE(std::isinf(values[3]), "1 - Swl - Sgl value must be Inf"); BOOST_CHECK_MESSAGE(check.isViolated(), "Check must be violated"); BOOST_CHECK_MESSAGE(check.isCritical(), "Check must be violated at critical level"); } endPoints.Swl = 0.6f; endPoints.Sgl = std::numeric_limits::infinity(); endPoints.Sogcr = 0.32f; check.test(endPoints); { auto values = std::vector(expectNumExported); check.exportCheckValues(values.data()); BOOST_CHECK_CLOSE (values[0], 0.6f, 1.0e-6f); BOOST_CHECK_MESSAGE(std::isinf(values[1]), "Sgl value must be Inf"); BOOST_CHECK_CLOSE (values[2], 0.32f, 1.0e-6f); BOOST_CHECK_MESSAGE(std::isinf(values[3]), "1 - Swl - Sgl value must be Inf"); BOOST_CHECK_MESSAGE(check.isViolated(), "Check must be violated"); BOOST_CHECK_MESSAGE(check.isCritical(), "Check must be violated at critical level"); } endPoints.Swl = 0.6f; endPoints.Sgl = 0.01f; endPoints.Sogcr = std::numeric_limits::infinity(); check.test(endPoints); { auto values = std::vector(expectNumExported); check.exportCheckValues(values.data()); BOOST_CHECK_CLOSE (values[0], 0.6f, 1.0e-6f); BOOST_CHECK_CLOSE (values[1], 0.01f, 1.0e-6f); BOOST_CHECK_MESSAGE(std::isinf(values[2]), "Sogcr value must be Inf"); BOOST_CHECK_CLOSE (values[3], 1.0f - 0.6f - 0.01f, 1.0e-6); BOOST_CHECK_MESSAGE(check.isViolated(), "Check must be violated"); BOOST_CHECK_MESSAGE(check.isCritical(), "Check must be violated at critical level"); } endPoints.Swl = std::numeric_limits::infinity(); endPoints.Sgl = std::numeric_limits::infinity(); endPoints.Sogcr = 0.32f; check.test(endPoints); { auto values = std::vector(expectNumExported); check.exportCheckValues(values.data()); BOOST_CHECK_MESSAGE(std::isinf(values[0]), "Swl value must be Inf"); BOOST_CHECK_MESSAGE(std::isinf(values[1]), "Sgl value must be Inf"); BOOST_CHECK_CLOSE (values[2], 0.32f, 1.0e-6f); BOOST_CHECK_MESSAGE(std::isinf(values[3]), "1 - Swl - Sgl value must be Inf"); BOOST_CHECK_MESSAGE(check.isViolated(), "Check must be violated"); BOOST_CHECK_MESSAGE(check.isCritical(), "Check must be violated at critical level"); } endPoints.Swl = std::numeric_limits::infinity(); endPoints.Sgl = 0.01f; endPoints.Sogcr = std::numeric_limits::infinity(); check.test(endPoints); { auto values = std::vector(expectNumExported); check.exportCheckValues(values.data()); BOOST_CHECK_MESSAGE(std::isinf(values[0]), "Swl value must be Inf"); BOOST_CHECK_CLOSE (values[1], 0.01f, 1.0e-6f); BOOST_CHECK_MESSAGE(std::isinf(values[2]), "Sogcr value must be Inf"); BOOST_CHECK_MESSAGE(std::isinf(values[3]), "1 - Swl - Sgl value must be Inf"); BOOST_CHECK_MESSAGE(check.isViolated(), "Check must be violated"); BOOST_CHECK_MESSAGE(check.isCritical(), "Check must be violated at critical level"); } endPoints.Swl = std::numeric_limits::infinity(); endPoints.Sgl = std::numeric_limits::infinity(); endPoints.Sogcr = std::numeric_limits::infinity(); check.test(endPoints); { auto values = std::vector(expectNumExported); check.exportCheckValues(values.data()); BOOST_CHECK_MESSAGE(std::isinf(values[0]), "Swl value must be Inf"); BOOST_CHECK_MESSAGE(std::isinf(values[1]), "Sgl value must be Inf"); BOOST_CHECK_MESSAGE(std::isinf(values[2]), "Sogcr value must be Inf"); BOOST_CHECK_MESSAGE(std::isinf(values[3]), "1 - Swl - Sgl value must be Inf"); BOOST_CHECK_MESSAGE(check.isViolated(), "Check must be violated"); BOOST_CHECK_MESSAGE(check.isCritical(), "Check must be violated at critical level"); } } } BOOST_AUTO_TEST_CASE(Swl_TooLarge) { auto check = Checks::MobileOil_GO_SGmin{}; const auto expectNumExported = std::size_t{4}; { auto endPoints = Opm::EclEpsScalingPointsInfo{}; endPoints.Swl = 0.70; endPoints.Sgl = 0.01; endPoints.Sogcr = 0.32; check.test(endPoints); } { auto values = std::vector(expectNumExported); check.exportCheckValues(values.data()); BOOST_CHECK_CLOSE(values[0], 0.70, 1.0e-8); BOOST_CHECK_CLOSE(values[1], 0.01, 1.0e-8); BOOST_CHECK_CLOSE(values[2], 0.32, 1.0e-8); BOOST_CHECK_CLOSE(values[3], 1.0 - 0.70 - 0.01, 1.0e-8); } BOOST_CHECK_MESSAGE(check.isViolated(), "Test must not be violated"); BOOST_CHECK_MESSAGE(! check.isCritical(), "Test must not be violated at critical level"); } BOOST_AUTO_TEST_CASE(Sgl_TooLarge) { auto check = Checks::MobileOil_GO_SGmin{}; const auto expectNumExported = std::size_t{4}; { auto endPoints = Opm::EclEpsScalingPointsInfo{}; endPoints.Swl = 0.65; endPoints.Sgl = 0.05; endPoints.Sogcr = 0.32; check.test(endPoints); } { auto values = std::vector(expectNumExported); check.exportCheckValues(values.data()); BOOST_CHECK_CLOSE(values[0], 0.65, 1.0e-8); BOOST_CHECK_CLOSE(values[1], 0.05, 1.0e-8); BOOST_CHECK_CLOSE(values[2], 0.32, 1.0e-8); BOOST_CHECK_CLOSE(values[3], 1.0 - 0.65 - 0.05, 1.0e-8); } BOOST_CHECK_MESSAGE(check.isViolated(), "Test must not be violated"); BOOST_CHECK_MESSAGE(! check.isCritical(), "Test must not be violated at critical level"); } BOOST_AUTO_TEST_CASE(Sogcr_TooLarge) { auto check = Checks::MobileOil_GO_SGmin{}; const auto expectNumExported = std::size_t{4}; { auto endPoints = Opm::EclEpsScalingPointsInfo{}; endPoints.Swl = 0.65; endPoints.Sgl = 0.04; endPoints.Sogcr = 0.32; check.test(endPoints); } { auto values = std::vector(expectNumExported); check.exportCheckValues(values.data()); BOOST_CHECK_CLOSE(values[0], 0.65, 1.0e-8); BOOST_CHECK_CLOSE(values[1], 0.04, 1.0e-8); BOOST_CHECK_CLOSE(values[2], 0.32, 1.0e-8); BOOST_CHECK_CLOSE(values[3], 1.0 - 0.65 - 0.04, 1.0e-8); } BOOST_CHECK_MESSAGE(check.isViolated(), "Test must not be violated"); BOOST_CHECK_MESSAGE(! check.isCritical(), "Test must not be violated at critical level"); } BOOST_AUTO_TEST_SUITE_END() // Mobile_Oil_Sgmin // --------------------------------------------------------------------------- BOOST_AUTO_TEST_SUITE(Mobile_Oil_Sgcr) BOOST_AUTO_TEST_CASE(All_Good) { auto check = Checks::MobileOil_GO_SGcr{}; const auto expectNumExported = std::size_t{4}; BOOST_CHECK_EQUAL(check.numExportedCheckValues(), expectNumExported); { auto columns = std::vector(expectNumExported); check.columnNames(columns.data()); BOOST_CHECK_EQUAL(columns[0], "SWL"); BOOST_CHECK_EQUAL(columns[1], "SGCR"); BOOST_CHECK_EQUAL(columns[2], "SOGCR"); BOOST_CHECK_EQUAL(columns[3], "1 - SWL - SGCR"); } { auto endPoints = Opm::EclEpsScalingPointsInfo{}; endPoints.Swl = 0.15f; endPoints.Sgcr = 0.01f; endPoints.Sogcr = 0.15f; check.test(endPoints); } { auto values = std::vector(expectNumExported); check.exportCheckValues(values.data()); BOOST_CHECK_CLOSE(values[0], 0.15f, 1.0e-6f); BOOST_CHECK_CLOSE(values[1], 0.01f, 1.0e-6f); BOOST_CHECK_CLOSE(values[2], 0.15f, 1.0e-6f); BOOST_CHECK_CLOSE(values[3], 1.0f - 0.15f - 0.01, 1.0e-5f); } BOOST_CHECK_MESSAGE(! check.isViolated(), "Test must not be violated"); BOOST_CHECK_MESSAGE(! check.isCritical(), "Test must not be violated at critical level"); } BOOST_AUTO_TEST_CASE(Non_Finite) { // NaN if constexpr (std::numeric_limits::has_quiet_NaN) { const auto expectNumExported = std::size_t{4}; auto endPoints = Opm::EclEpsScalingPointsInfo{}; endPoints.Swl = std::numeric_limits::quiet_NaN(); endPoints.Sgcr = 0.01f; endPoints.Sogcr = 0.32f; auto check = Checks::MobileOil_GO_SGcr{}; check.test(endPoints); { auto values = std::vector(expectNumExported); check.exportCheckValues(values.data()); BOOST_CHECK_MESSAGE(std::isnan(values[0]), "Swl value must be NaN"); BOOST_CHECK_CLOSE (values[1], 0.01f, 1.0e-6f); BOOST_CHECK_CLOSE (values[2], 0.32f, 1.0e-6f); BOOST_CHECK_MESSAGE(std::isnan(values[3]), "1 - Swl - Sgcr value must be NaN"); BOOST_CHECK_MESSAGE(check.isViolated(), "Check must be violated"); BOOST_CHECK_MESSAGE(check.isCritical(), "Check must be violated at critical level"); } endPoints.Swl = 0.6f; endPoints.Sgcr = std::numeric_limits::quiet_NaN(); endPoints.Sogcr = 0.32f; check.test(endPoints); { auto values = std::vector(expectNumExported); check.exportCheckValues(values.data()); BOOST_CHECK_CLOSE (values[0], 0.6f, 1.0e-6f); BOOST_CHECK_MESSAGE(std::isnan(values[1]), "Sgcr value must be NaN"); BOOST_CHECK_CLOSE (values[2], 0.32f, 1.0e-6f); BOOST_CHECK_MESSAGE(std::isnan(values[3]), "1 - Swl - Sgcr value must be NaN"); BOOST_CHECK_MESSAGE(check.isViolated(), "Check must be violated"); BOOST_CHECK_MESSAGE(check.isCritical(), "Check must be violated at critical level"); } endPoints.Swl = 0.6f; endPoints.Sgcr = 0.01f; endPoints.Sogcr = std::numeric_limits::quiet_NaN(); check.test(endPoints); { auto values = std::vector(expectNumExported); check.exportCheckValues(values.data()); BOOST_CHECK_CLOSE (values[0], 0.6f, 1.0e-6f); BOOST_CHECK_CLOSE (values[1], 0.01f, 1.0e-6f); BOOST_CHECK_MESSAGE(std::isnan(values[2]), "Sogcr value must be NaN"); BOOST_CHECK_CLOSE (values[3], 1.0f - 0.6f - 0.01f, 1.0e-6); BOOST_CHECK_MESSAGE(check.isViolated(), "Check must be violated"); BOOST_CHECK_MESSAGE(check.isCritical(), "Check must be violated at critical level"); } endPoints.Swl = std::numeric_limits::quiet_NaN(); endPoints.Sgcr = std::numeric_limits::quiet_NaN(); endPoints.Sogcr = 0.32f; check.test(endPoints); { auto values = std::vector(expectNumExported); check.exportCheckValues(values.data()); BOOST_CHECK_MESSAGE(std::isnan(values[0]), "Swl value must be NaN"); BOOST_CHECK_MESSAGE(std::isnan(values[1]), "Sgcr value must be NaN"); BOOST_CHECK_CLOSE (values[2], 0.32f, 1.0e-6f); BOOST_CHECK_MESSAGE(std::isnan(values[3]), "1 - Swl - Sgcr value must be NaN"); BOOST_CHECK_MESSAGE(check.isViolated(), "Check must be violated"); BOOST_CHECK_MESSAGE(check.isCritical(), "Check must be violated at critical level"); } endPoints.Swl = std::numeric_limits::quiet_NaN(); endPoints.Sgcr = 0.01f; endPoints.Sogcr = std::numeric_limits::quiet_NaN(); check.test(endPoints); { auto values = std::vector(expectNumExported); check.exportCheckValues(values.data()); BOOST_CHECK_MESSAGE(std::isnan(values[0]), "Swl value must be NaN"); BOOST_CHECK_CLOSE (values[1], 0.01f, 1.0e-6f); BOOST_CHECK_MESSAGE(std::isnan(values[2]), "Sogcr value must be NaN"); BOOST_CHECK_MESSAGE(std::isnan(values[3]), "1 - Swl - Sgcr value must be NaN"); BOOST_CHECK_MESSAGE(check.isViolated(), "Check must be violated"); BOOST_CHECK_MESSAGE(check.isCritical(), "Check must be violated at critical level"); } endPoints.Swl = std::numeric_limits::quiet_NaN(); endPoints.Sgcr = std::numeric_limits::quiet_NaN(); endPoints.Sogcr = std::numeric_limits::quiet_NaN(); check.test(endPoints); { auto values = std::vector(expectNumExported); check.exportCheckValues(values.data()); BOOST_CHECK_MESSAGE(std::isnan(values[0]), "Swl value must be NaN"); BOOST_CHECK_MESSAGE(std::isnan(values[1]), "Sgu value must be NaN"); BOOST_CHECK_MESSAGE(std::isnan(values[2]), "Sogcr value must be NaN"); BOOST_CHECK_MESSAGE(std::isnan(values[3]), "1 - Swl - Sgcr value must be NaN"); BOOST_CHECK_MESSAGE(check.isViolated(), "Check must be violated"); BOOST_CHECK_MESSAGE(check.isCritical(), "Check must be violated at critical level"); } } // Inf if constexpr (std::numeric_limits::has_infinity) { const auto expectNumExported = std::size_t{4}; auto endPoints = Opm::EclEpsScalingPointsInfo{}; endPoints.Swl = std::numeric_limits::infinity(); endPoints.Sgcr = 0.01f; endPoints.Sogcr = 0.32f; auto check = Checks::MobileOil_GO_SGcr{}; check.test(endPoints); { auto values = std::vector(expectNumExported); check.exportCheckValues(values.data()); BOOST_CHECK_MESSAGE(std::isinf(values[0]), "Swl value must be Inf"); BOOST_CHECK_CLOSE (values[1], 0.01f, 1.0e-6f); BOOST_CHECK_CLOSE (values[2], 0.32f, 1.0e-6f); BOOST_CHECK_MESSAGE(std::isinf(values[3]), "1 - Swl - Sgcr value must be Inf"); BOOST_CHECK_MESSAGE(check.isViolated(), "Check must be violated"); BOOST_CHECK_MESSAGE(check.isCritical(), "Check must be violated at critical level"); } endPoints.Swl = 0.6f; endPoints.Sgcr = std::numeric_limits::infinity(); endPoints.Sogcr = 0.32f; check.test(endPoints); { auto values = std::vector(expectNumExported); check.exportCheckValues(values.data()); BOOST_CHECK_CLOSE (values[0], 0.6f, 1.0e-6f); BOOST_CHECK_MESSAGE(std::isinf(values[1]), "Sgcr value must be Inf"); BOOST_CHECK_CLOSE (values[2], 0.32f, 1.0e-6f); BOOST_CHECK_MESSAGE(std::isinf(values[3]), "1 - Swl - Sgcr value must be Inf"); BOOST_CHECK_MESSAGE(check.isViolated(), "Check must be violated"); BOOST_CHECK_MESSAGE(check.isCritical(), "Check must be violated at critical level"); } endPoints.Swl = 0.6f; endPoints.Sgcr = 0.01f; endPoints.Sogcr = std::numeric_limits::infinity(); check.test(endPoints); { auto values = std::vector(expectNumExported); check.exportCheckValues(values.data()); BOOST_CHECK_CLOSE (values[0], 0.6f, 1.0e-6f); BOOST_CHECK_CLOSE (values[1], 0.01f, 1.0e-6f); BOOST_CHECK_MESSAGE(std::isinf(values[2]), "Sogcr value must be Inf"); BOOST_CHECK_CLOSE (values[3], 1.0f - 0.6f - 0.01f, 1.0e-6); BOOST_CHECK_MESSAGE(check.isViolated(), "Check must be violated"); BOOST_CHECK_MESSAGE(check.isCritical(), "Check must be violated at critical level"); } endPoints.Swl = std::numeric_limits::infinity(); endPoints.Sgcr = std::numeric_limits::infinity(); endPoints.Sogcr = 0.32f; check.test(endPoints); { auto values = std::vector(expectNumExported); check.exportCheckValues(values.data()); BOOST_CHECK_MESSAGE(std::isinf(values[0]), "Swl value must be Inf"); BOOST_CHECK_MESSAGE(std::isinf(values[1]), "Sgcr value must be Inf"); BOOST_CHECK_CLOSE (values[2], 0.32f, 1.0e-6f); BOOST_CHECK_MESSAGE(std::isinf(values[3]), "1 - Swl - Sgcr value must be Inf"); BOOST_CHECK_MESSAGE(check.isViolated(), "Check must be violated"); BOOST_CHECK_MESSAGE(check.isCritical(), "Check must be violated at critical level"); } endPoints.Swl = std::numeric_limits::infinity(); endPoints.Sgcr = 0.01f; endPoints.Sogcr = std::numeric_limits::infinity(); check.test(endPoints); { auto values = std::vector(expectNumExported); check.exportCheckValues(values.data()); BOOST_CHECK_MESSAGE(std::isinf(values[0]), "Swl value must be Inf"); BOOST_CHECK_CLOSE (values[1], 0.01f, 1.0e-6f); BOOST_CHECK_MESSAGE(std::isinf(values[2]), "Sogcr value must be Inf"); BOOST_CHECK_MESSAGE(std::isinf(values[3]), "1 - Swl - Sgcr value must be Inf"); BOOST_CHECK_MESSAGE(check.isViolated(), "Check must be violated"); BOOST_CHECK_MESSAGE(check.isCritical(), "Check must be violated at critical level"); } endPoints.Swl = std::numeric_limits::infinity(); endPoints.Sgcr = std::numeric_limits::infinity(); endPoints.Sogcr = std::numeric_limits::infinity(); check.test(endPoints); { auto values = std::vector(expectNumExported); check.exportCheckValues(values.data()); BOOST_CHECK_MESSAGE(std::isinf(values[0]), "Swl value must be Inf"); BOOST_CHECK_MESSAGE(std::isinf(values[1]), "Sgcr value must be Inf"); BOOST_CHECK_MESSAGE(std::isinf(values[2]), "Sogcr value must be Inf"); BOOST_CHECK_MESSAGE(std::isinf(values[3]), "1 - Swl - Sgcr value must be Inf"); BOOST_CHECK_MESSAGE(check.isViolated(), "Check must be violated"); BOOST_CHECK_MESSAGE(check.isCritical(), "Check must be violated at critical level"); } } } BOOST_AUTO_TEST_CASE(Swl_TooLarge) { auto check = Checks::MobileOil_GO_SGcr{}; const auto expectNumExported = std::size_t{4}; { auto endPoints = Opm::EclEpsScalingPointsInfo{}; endPoints.Swl = 0.70; endPoints.Sgcr = 0.01; endPoints.Sogcr = 0.32; check.test(endPoints); } { auto values = std::vector(expectNumExported); check.exportCheckValues(values.data()); BOOST_CHECK_CLOSE(values[0], 0.70, 1.0e-8); BOOST_CHECK_CLOSE(values[1], 0.01, 1.0e-8); BOOST_CHECK_CLOSE(values[2], 0.32, 1.0e-8); BOOST_CHECK_CLOSE(values[3], 1.0 - 0.70 - 0.01, 1.0e-8); } BOOST_CHECK_MESSAGE(check.isViolated(), "Test must not be violated"); BOOST_CHECK_MESSAGE(! check.isCritical(), "Test must not be violated at critical level"); } BOOST_AUTO_TEST_CASE(Sgcr_TooLarge) { auto check = Checks::MobileOil_GO_SGcr{}; const auto expectNumExported = std::size_t{4}; { auto endPoints = Opm::EclEpsScalingPointsInfo{}; endPoints.Swl = 0.65; endPoints.Sgcr = 0.05; endPoints.Sogcr = 0.32; check.test(endPoints); } { auto values = std::vector(expectNumExported); check.exportCheckValues(values.data()); BOOST_CHECK_CLOSE(values[0], 0.65, 1.0e-8); BOOST_CHECK_CLOSE(values[1], 0.05, 1.0e-8); BOOST_CHECK_CLOSE(values[2], 0.32, 1.0e-8); BOOST_CHECK_CLOSE(values[3], 1.0 - 0.65 - 0.05, 1.0e-8); } BOOST_CHECK_MESSAGE(check.isViolated(), "Test must not be violated"); BOOST_CHECK_MESSAGE(! check.isCritical(), "Test must not be violated at critical level"); } BOOST_AUTO_TEST_CASE(Sogcr_TooLarge) { auto check = Checks::MobileOil_GO_SGcr{}; const auto expectNumExported = std::size_t{4}; { auto endPoints = Opm::EclEpsScalingPointsInfo{}; endPoints.Swl = 0.65; endPoints.Sgcr = 0.04; endPoints.Sogcr = 0.32; check.test(endPoints); } { auto values = std::vector(expectNumExported); check.exportCheckValues(values.data()); BOOST_CHECK_CLOSE(values[0], 0.65, 1.0e-8); BOOST_CHECK_CLOSE(values[1], 0.04, 1.0e-8); BOOST_CHECK_CLOSE(values[2], 0.32, 1.0e-8); BOOST_CHECK_CLOSE(values[3], 1.0 - 0.65 - 0.04, 1.0e-8); } BOOST_CHECK_MESSAGE(check.isViolated(), "Test must not be violated"); BOOST_CHECK_MESSAGE(! check.isCritical(), "Test must not be violated at critical level"); } BOOST_AUTO_TEST_SUITE_END() // Mobile_Oil_Sgcr // --------------------------------------------------------------------------- BOOST_AUTO_TEST_SUITE_END() // Gas_Oil_System // =========================================================================== BOOST_AUTO_TEST_SUITE(Oil_Water_System) // --------------------------------------------------------------------------- BOOST_AUTO_TEST_SUITE(Sowcr) BOOST_AUTO_TEST_CASE(All_Good) { auto check = Checks::SOcr_OW{}; BOOST_CHECK_EQUAL(check.numExportedCheckValues(), std::size_t{1}); { auto column = std::string{}; check.columnNames(&column); BOOST_CHECK_EQUAL(column, "SOWCR"); } { auto endPoints = Opm::EclEpsScalingPointsInfo{}; endPoints.Sowcr = 0.3f; // >= 0 && < 1 check.test(endPoints); } { auto value = -0.1f; check.exportCheckValues(&value); BOOST_CHECK_CLOSE(value, 0.3f, 1.0e-6f); } BOOST_CHECK_MESSAGE(! check.isViolated(), "Test must not be violated"); BOOST_CHECK_MESSAGE(! check.isCritical(), "Test must not be violated at critical level"); } BOOST_AUTO_TEST_CASE(Non_Finite) { // NaN if constexpr (std::numeric_limits::has_quiet_NaN) { auto endPoints = Opm::EclEpsScalingPointsInfo{}; endPoints.Sowcr = std::numeric_limits::quiet_NaN(); auto check = Checks::SOcr_OW{}; check.test(endPoints); auto value = -0.1f; check.exportCheckValues(&value); BOOST_CHECK_MESSAGE(std::isnan(value), "Sowcr value must be NaN"); BOOST_CHECK_MESSAGE(check.isViolated(), "Check must be violated"); BOOST_CHECK_MESSAGE(check.isCritical(), "Check must be violated at critical level"); } // Inf if constexpr (std::numeric_limits::has_infinity) { auto endPoints = Opm::EclEpsScalingPointsInfo{}; endPoints.Sowcr = std::numeric_limits::infinity(); auto check = Checks::SOcr_OW{}; check.test(endPoints); auto value = -0.1f; check.exportCheckValues(&value); BOOST_CHECK_MESSAGE(std::isinf(value), "Sowcr value must be Inf"); BOOST_CHECK_MESSAGE(check.isViolated(), "Check must be violated"); BOOST_CHECK_MESSAGE(check.isCritical(), "Check must be violated at critical level"); } } BOOST_AUTO_TEST_CASE(Negative) { auto check = Checks::SOcr_OW{}; auto endPoints = Opm::EclEpsScalingPointsInfo{}; endPoints.Sowcr = -0.01; // < 0 check.test(endPoints); { auto value = 1.0; check.exportCheckValues(&value); BOOST_CHECK_CLOSE(value, -0.01, 1.0e-8); } BOOST_CHECK_MESSAGE(check.isViolated(), "Test must be violated"); BOOST_CHECK_MESSAGE(check.isCritical(), "Test must be violated at critical level"); } BOOST_AUTO_TEST_CASE(Is_One) { auto check = Checks::SOcr_OW{}; auto endPoints = Opm::EclEpsScalingPointsInfo{}; endPoints.Sowcr = 1.0; // >= 1 check.test(endPoints); { auto value = 0.0; check.exportCheckValues(&value); BOOST_CHECK_CLOSE(value, 1.0, 1.0e-8); } BOOST_CHECK_MESSAGE(check.isViolated(), "Test must be violated"); BOOST_CHECK_MESSAGE(check.isCritical(), "Test must be violated at critical level"); } BOOST_AUTO_TEST_CASE(Exceeds_One) { auto check = Checks::SOcr_OW{}; auto endPoints = Opm::EclEpsScalingPointsInfo{}; endPoints.Sowcr = 1.2; // >= 1 check.test(endPoints); { auto value = 0.0; check.exportCheckValues(&value); BOOST_CHECK_CLOSE(value, 1.2, 1.0e-8); } BOOST_CHECK_MESSAGE(check.isViolated(), "Test must be violated"); BOOST_CHECK_MESSAGE(check.isCritical(), "Test must be violated at critical level"); } BOOST_AUTO_TEST_SUITE_END() // Sowcr // --------------------------------------------------------------------------- BOOST_AUTO_TEST_SUITE(So_min) BOOST_AUTO_TEST_CASE(All_Good) { auto check = Checks::SOmin_OW{}; BOOST_CHECK_EQUAL(check.numExportedCheckValues(), std::size_t{3}); { auto columns = std::vector(3); check.columnNames(columns.data()); BOOST_CHECK_EQUAL(columns[0], "SGL"); BOOST_CHECK_EQUAL(columns[1], "SWU"); BOOST_CHECK_EQUAL(columns[2], "SGL + SWU"); } { auto endPoints = Opm::EclEpsScalingPointsInfo{}; endPoints.Sgl = 0.09; endPoints.Swu = 0.9; check.test(endPoints); } { auto values = std::vector(3); check.exportCheckValues(values.data()); BOOST_CHECK_CLOSE(values[0], 0.09, 1.0e-8); BOOST_CHECK_CLOSE(values[1], 0.9 , 1.0e-8); BOOST_CHECK_CLOSE(values[2], 0.99, 1.0e-8); } BOOST_CHECK_MESSAGE(! check.isViolated(), "Test must not be violated"); BOOST_CHECK_MESSAGE(! check.isCritical(), "Test must not be violated at critical level"); } BOOST_AUTO_TEST_CASE(Non_Finite) { // NaN if constexpr (std::numeric_limits::has_quiet_NaN) { auto endPoints = Opm::EclEpsScalingPointsInfo{}; endPoints.Sgl = std::numeric_limits::quiet_NaN(); endPoints.Swu = 0.75f; auto check = Checks::SOmin_OW{}; check.test(endPoints); { auto values = std::vector(3); check.exportCheckValues(values.data()); BOOST_CHECK_MESSAGE(std::isnan(values[0]), "Sgl value must be NaN"); BOOST_CHECK_CLOSE (values[1], 0.75f, 1.0e-6f); BOOST_CHECK_MESSAGE(std::isnan(values[2]), "Sgl + Swu value must be NaN"); BOOST_CHECK_MESSAGE(check.isViolated(), "Check must be violated"); BOOST_CHECK_MESSAGE(check.isCritical(), "Check must be violated at critical level"); } endPoints.Sgl = 0.75f; endPoints.Swu = std::numeric_limits::quiet_NaN(); check.test(endPoints); { auto values = std::vector(3); check.exportCheckValues(values.data()); BOOST_CHECK_CLOSE (values[0], 0.75f, 1.0e-6f); BOOST_CHECK_MESSAGE(std::isnan(values[1]), "Swu value must be NaN"); BOOST_CHECK_MESSAGE(std::isnan(values[2]), "Sgl + Swu value must be NaN"); BOOST_CHECK_MESSAGE(check.isViolated(), "Check must be violated"); BOOST_CHECK_MESSAGE(check.isCritical(), "Check must be violated at critical level"); } endPoints.Sgl = std::numeric_limits::quiet_NaN(); endPoints.Swu = std::numeric_limits::quiet_NaN(); check.test(endPoints); { auto values = std::vector(3); check.exportCheckValues(values.data()); BOOST_CHECK_MESSAGE(std::isnan(values[0]), "Sgl value must be NaN"); BOOST_CHECK_MESSAGE(std::isnan(values[1]), "Swu value must be NaN"); BOOST_CHECK_MESSAGE(std::isnan(values[2]), "Sgl + Swu value must be NaN"); BOOST_CHECK_MESSAGE(check.isViolated(), "Check must be violated"); BOOST_CHECK_MESSAGE(check.isCritical(), "Check must be violated at critical level"); } } // Inf if constexpr (std::numeric_limits::has_infinity) { auto endPoints = Opm::EclEpsScalingPointsInfo{}; endPoints.Sgl = std::numeric_limits::infinity(); endPoints.Swu = 0.75f; auto check = Checks::SOmin_OW{}; check.test(endPoints); { auto values = std::vector(3); check.exportCheckValues(values.data()); BOOST_CHECK_MESSAGE(std::isinf(values[0]), "Sgl value must be Inf"); BOOST_CHECK_CLOSE (values[1], 0.75f, 1.0e-6f); BOOST_CHECK_MESSAGE(std::isinf(values[2]), "Sgl + Swu value must be Inf"); BOOST_CHECK_MESSAGE(check.isViolated(), "Check must be violated"); BOOST_CHECK_MESSAGE(check.isCritical(), "Check must be violated at critical level"); } endPoints.Sgl = 0.75f; endPoints.Swu = std::numeric_limits::infinity(); check.test(endPoints); { auto values = std::vector(3); check.exportCheckValues(values.data()); BOOST_CHECK_CLOSE (values[0], 0.75f, 1.0e-6f); BOOST_CHECK_MESSAGE(std::isinf(values[1]), "Swu value must be Inf"); BOOST_CHECK_MESSAGE(std::isinf(values[2]), "Sgl + Swu value must be Inf"); BOOST_CHECK_MESSAGE(check.isViolated(), "Check must be violated"); BOOST_CHECK_MESSAGE(check.isCritical(), "Check must be violated at critical level"); } endPoints.Sgl = std::numeric_limits::infinity(); endPoints.Swu = std::numeric_limits::infinity(); check.test(endPoints); { auto values = std::vector(3); check.exportCheckValues(values.data()); BOOST_CHECK_MESSAGE(std::isinf(values[0]), "Sgl value must be Inf"); BOOST_CHECK_MESSAGE(std::isinf(values[1]), "Swu value must be Inf"); BOOST_CHECK_MESSAGE(std::isinf(values[2]), "Sgl + Swu value must be Inf"); BOOST_CHECK_MESSAGE(check.isViolated(), "Check must be violated"); BOOST_CHECK_MESSAGE(check.isCritical(), "Check must be violated at critical level"); } } } BOOST_AUTO_TEST_CASE(Sgl_TooLarge) { auto check = Checks::SOmin_OW{}; { auto endPoints = Opm::EclEpsScalingPointsInfo{}; endPoints.Sgl = 0.15; endPoints.Swu = 0.9; check.test(endPoints); } { auto values = std::vector(3); check.exportCheckValues(values.data()); BOOST_CHECK_CLOSE(values[0], 0.15, 1.0e-8); BOOST_CHECK_CLOSE(values[1], 0.9 , 1.0e-8); BOOST_CHECK_CLOSE(values[2], 1.05, 1.0e-8); } BOOST_CHECK_MESSAGE(check.isViolated(), "Test must be violated"); BOOST_CHECK_MESSAGE(! check.isCritical(), "Test must not be violated at critical level"); } BOOST_AUTO_TEST_CASE(Swu_TooLarge) { auto check = Checks::SOmin_OW{}; { auto endPoints = Opm::EclEpsScalingPointsInfo{}; endPoints.Sgl = 0.1; endPoints.Swu = 0.95; check.test(endPoints); } { auto values = std::vector(3); check.exportCheckValues(values.data()); BOOST_CHECK_CLOSE(values[0], 0.1 , 1.0e-8); BOOST_CHECK_CLOSE(values[1], 0.95, 1.0e-8); BOOST_CHECK_CLOSE(values[2], 1.05, 1.0e-8); } BOOST_CHECK_MESSAGE(check.isViolated(), "Test must be violated"); BOOST_CHECK_MESSAGE(! check.isCritical(), "Test must not be violated at critical level"); } BOOST_AUTO_TEST_SUITE_END() // --------------------------------------------------------------------------- BOOST_AUTO_TEST_SUITE(Mobile_Oil_Swmin) BOOST_AUTO_TEST_CASE(All_Good) { auto check = Checks::MobileOil_OW_SWmin{}; const auto expectNumExported = std::size_t{4}; BOOST_CHECK_EQUAL(check.numExportedCheckValues(), expectNumExported); { auto columns = std::vector(expectNumExported); check.columnNames(columns.data()); BOOST_CHECK_EQUAL(columns[0], "SWL"); BOOST_CHECK_EQUAL(columns[1], "SGL"); BOOST_CHECK_EQUAL(columns[2], "SOWCR"); BOOST_CHECK_EQUAL(columns[3], "1 - SWL - SGL"); } { auto endPoints = Opm::EclEpsScalingPointsInfo{}; endPoints.Swl = 0.15f; endPoints.Sgl = 0.01f; endPoints.Sowcr = 0.15f; check.test(endPoints); } { auto values = std::vector(expectNumExported); check.exportCheckValues(values.data()); BOOST_CHECK_CLOSE(values[0], 0.15f, 1.0e-6f); BOOST_CHECK_CLOSE(values[1], 0.01f, 1.0e-6f); BOOST_CHECK_CLOSE(values[2], 0.15f, 1.0e-6f); BOOST_CHECK_CLOSE(values[3], 1.0f - 0.15f - 0.01, 1.0e-5f); } BOOST_CHECK_MESSAGE(! check.isViolated(), "Test must not be violated"); BOOST_CHECK_MESSAGE(! check.isCritical(), "Test must not be violated at critical level"); } BOOST_AUTO_TEST_CASE(Non_Finite) { // NaN if constexpr (std::numeric_limits::has_quiet_NaN) { const auto expectNumExported = std::size_t{4}; auto endPoints = Opm::EclEpsScalingPointsInfo{}; endPoints.Swl = std::numeric_limits::quiet_NaN(); endPoints.Sgl = 0.01f; endPoints.Sowcr = 0.32f; auto check = Checks::MobileOil_OW_SWmin{}; check.test(endPoints); { auto values = std::vector(expectNumExported); check.exportCheckValues(values.data()); BOOST_CHECK_MESSAGE(std::isnan(values[0]), "Swl value must be NaN"); BOOST_CHECK_CLOSE (values[1], 0.01f, 1.0e-6f); BOOST_CHECK_CLOSE (values[2], 0.32f, 1.0e-6f); BOOST_CHECK_MESSAGE(std::isnan(values[3]), "1 - Swl - Sgl value must be NaN"); BOOST_CHECK_MESSAGE(check.isViolated(), "Check must be violated"); BOOST_CHECK_MESSAGE(check.isCritical(), "Check must be violated at critical level"); } endPoints.Swl = 0.6f; endPoints.Sgl = std::numeric_limits::quiet_NaN(); endPoints.Sowcr = 0.32f; check.test(endPoints); { auto values = std::vector(expectNumExported); check.exportCheckValues(values.data()); BOOST_CHECK_CLOSE (values[0], 0.6f, 1.0e-6f); BOOST_CHECK_MESSAGE(std::isnan(values[1]), "Sgl value must be NaN"); BOOST_CHECK_CLOSE (values[2], 0.32f, 1.0e-6f); BOOST_CHECK_MESSAGE(std::isnan(values[3]), "1 - Swl - Sgl value must be NaN"); BOOST_CHECK_MESSAGE(check.isViolated(), "Check must be violated"); BOOST_CHECK_MESSAGE(check.isCritical(), "Check must be violated at critical level"); } endPoints.Swl = 0.6f; endPoints.Sgl = 0.01f; endPoints.Sowcr = std::numeric_limits::quiet_NaN(); check.test(endPoints); { auto values = std::vector(expectNumExported); check.exportCheckValues(values.data()); BOOST_CHECK_CLOSE (values[0], 0.6f, 1.0e-6f); BOOST_CHECK_CLOSE (values[1], 0.01f, 1.0e-6f); BOOST_CHECK_MESSAGE(std::isnan(values[2]), "Sowcr value must be NaN"); BOOST_CHECK_CLOSE (values[3], 1.0f - 0.6f - 0.01f, 1.0e-6); BOOST_CHECK_MESSAGE(check.isViolated(), "Check must be violated"); BOOST_CHECK_MESSAGE(check.isCritical(), "Check must be violated at critical level"); } endPoints.Swl = std::numeric_limits::quiet_NaN(); endPoints.Sgl = std::numeric_limits::quiet_NaN(); endPoints.Sowcr = 0.32f; check.test(endPoints); { auto values = std::vector(expectNumExported); check.exportCheckValues(values.data()); BOOST_CHECK_MESSAGE(std::isnan(values[0]), "Swl value must be NaN"); BOOST_CHECK_MESSAGE(std::isnan(values[1]), "Sgl value must be NaN"); BOOST_CHECK_CLOSE (values[2], 0.32f, 1.0e-6f); BOOST_CHECK_MESSAGE(std::isnan(values[3]), "1 - Swl - Sgl value must be NaN"); BOOST_CHECK_MESSAGE(check.isViolated(), "Check must be violated"); BOOST_CHECK_MESSAGE(check.isCritical(), "Check must be violated at critical level"); } endPoints.Swl = std::numeric_limits::quiet_NaN(); endPoints.Sgl = 0.01f; endPoints.Sowcr = std::numeric_limits::quiet_NaN(); check.test(endPoints); { auto values = std::vector(expectNumExported); check.exportCheckValues(values.data()); BOOST_CHECK_MESSAGE(std::isnan(values[0]), "Swl value must be NaN"); BOOST_CHECK_CLOSE (values[1], 0.01f, 1.0e-6f); BOOST_CHECK_MESSAGE(std::isnan(values[2]), "Sowcr value must be NaN"); BOOST_CHECK_MESSAGE(std::isnan(values[3]), "1 - Swl - Sgl value must be NaN"); BOOST_CHECK_MESSAGE(check.isViolated(), "Check must be violated"); BOOST_CHECK_MESSAGE(check.isCritical(), "Check must be violated at critical level"); } endPoints.Swl = std::numeric_limits::quiet_NaN(); endPoints.Sgl = std::numeric_limits::quiet_NaN(); endPoints.Sowcr = std::numeric_limits::quiet_NaN(); check.test(endPoints); { auto values = std::vector(expectNumExported); check.exportCheckValues(values.data()); BOOST_CHECK_MESSAGE(std::isnan(values[0]), "Swl value must be NaN"); BOOST_CHECK_MESSAGE(std::isnan(values[1]), "Sgl value must be NaN"); BOOST_CHECK_MESSAGE(std::isnan(values[2]), "Sowcr value must be NaN"); BOOST_CHECK_MESSAGE(std::isnan(values[3]), "1 - Swl - Sgl value must be NaN"); BOOST_CHECK_MESSAGE(check.isViolated(), "Check must be violated"); BOOST_CHECK_MESSAGE(check.isCritical(), "Check must be violated at critical level"); } } // Inf if constexpr (std::numeric_limits::has_infinity) { const auto expectNumExported = std::size_t{4}; auto endPoints = Opm::EclEpsScalingPointsInfo{}; endPoints.Swl = std::numeric_limits::infinity(); endPoints.Sgl = 0.01f; endPoints.Sowcr = 0.32f; auto check = Checks::MobileOil_OW_SWmin{}; check.test(endPoints); { auto values = std::vector(expectNumExported); check.exportCheckValues(values.data()); BOOST_CHECK_MESSAGE(std::isinf(values[0]), "Swl value must be Inf"); BOOST_CHECK_CLOSE (values[1], 0.01f, 1.0e-6f); BOOST_CHECK_CLOSE (values[2], 0.32f, 1.0e-6f); BOOST_CHECK_MESSAGE(std::isinf(values[3]), "1 - Swl - Sgl value must be Inf"); BOOST_CHECK_MESSAGE(check.isViolated(), "Check must be violated"); BOOST_CHECK_MESSAGE(check.isCritical(), "Check must be violated at critical level"); } endPoints.Swl = 0.6f; endPoints.Sgl = std::numeric_limits::infinity(); endPoints.Sowcr = 0.32f; check.test(endPoints); { auto values = std::vector(expectNumExported); check.exportCheckValues(values.data()); BOOST_CHECK_CLOSE (values[0], 0.6f, 1.0e-6f); BOOST_CHECK_MESSAGE(std::isinf(values[1]), "Sgl value must be Inf"); BOOST_CHECK_CLOSE (values[2], 0.32f, 1.0e-6f); BOOST_CHECK_MESSAGE(std::isinf(values[3]), "1 - Swl - Sgl value must be Inf"); BOOST_CHECK_MESSAGE(check.isViolated(), "Check must be violated"); BOOST_CHECK_MESSAGE(check.isCritical(), "Check must be violated at critical level"); } endPoints.Swl = 0.6f; endPoints.Sgl = 0.01f; endPoints.Sowcr = std::numeric_limits::infinity(); check.test(endPoints); { auto values = std::vector(expectNumExported); check.exportCheckValues(values.data()); BOOST_CHECK_CLOSE (values[0], 0.6f, 1.0e-6f); BOOST_CHECK_CLOSE (values[1], 0.01f, 1.0e-6f); BOOST_CHECK_MESSAGE(std::isinf(values[2]), "Sowcr value must be Inf"); BOOST_CHECK_CLOSE (values[3], 1.0f - 0.6f - 0.01f, 1.0e-6); BOOST_CHECK_MESSAGE(check.isViolated(), "Check must be violated"); BOOST_CHECK_MESSAGE(check.isCritical(), "Check must be violated at critical level"); } endPoints.Swl = std::numeric_limits::infinity(); endPoints.Sgl = std::numeric_limits::infinity(); endPoints.Sowcr = 0.32f; check.test(endPoints); { auto values = std::vector(expectNumExported); check.exportCheckValues(values.data()); BOOST_CHECK_MESSAGE(std::isinf(values[0]), "Swl value must be Inf"); BOOST_CHECK_MESSAGE(std::isinf(values[1]), "Sgl value must be Inf"); BOOST_CHECK_CLOSE (values[2], 0.32f, 1.0e-6f); BOOST_CHECK_MESSAGE(std::isinf(values[3]), "1 - Swl - Sgl value must be Inf"); BOOST_CHECK_MESSAGE(check.isViolated(), "Check must be violated"); BOOST_CHECK_MESSAGE(check.isCritical(), "Check must be violated at critical level"); } endPoints.Swl = std::numeric_limits::infinity(); endPoints.Sgl = 0.01f; endPoints.Sowcr = std::numeric_limits::infinity(); check.test(endPoints); { auto values = std::vector(expectNumExported); check.exportCheckValues(values.data()); BOOST_CHECK_MESSAGE(std::isinf(values[0]), "Swl value must be Inf"); BOOST_CHECK_CLOSE (values[1], 0.01f, 1.0e-6f); BOOST_CHECK_MESSAGE(std::isinf(values[2]), "Sowcr value must be Inf"); BOOST_CHECK_MESSAGE(std::isinf(values[3]), "1 - Swl - Sgl value must be Inf"); BOOST_CHECK_MESSAGE(check.isViolated(), "Check must be violated"); BOOST_CHECK_MESSAGE(check.isCritical(), "Check must be violated at critical level"); } endPoints.Swl = std::numeric_limits::infinity(); endPoints.Sgl = std::numeric_limits::infinity(); endPoints.Sowcr = std::numeric_limits::infinity(); check.test(endPoints); { auto values = std::vector(expectNumExported); check.exportCheckValues(values.data()); BOOST_CHECK_MESSAGE(std::isinf(values[0]), "Swl value must be Inf"); BOOST_CHECK_MESSAGE(std::isinf(values[1]), "Sgl value must be Inf"); BOOST_CHECK_MESSAGE(std::isinf(values[2]), "Sowcr value must be Inf"); BOOST_CHECK_MESSAGE(std::isinf(values[3]), "1 - Swl - Sgl value must be Inf"); BOOST_CHECK_MESSAGE(check.isViolated(), "Check must be violated"); BOOST_CHECK_MESSAGE(check.isCritical(), "Check must be violated at critical level"); } } } BOOST_AUTO_TEST_CASE(Swl_TooLarge) { auto check = Checks::MobileOil_OW_SWmin{}; const auto expectNumExported = std::size_t{4}; { auto endPoints = Opm::EclEpsScalingPointsInfo{}; endPoints.Swl = 0.70; endPoints.Sgl = 0.01; endPoints.Sowcr = 0.32; check.test(endPoints); } { auto values = std::vector(expectNumExported); check.exportCheckValues(values.data()); BOOST_CHECK_CLOSE(values[0], 0.70, 1.0e-8); BOOST_CHECK_CLOSE(values[1], 0.01, 1.0e-8); BOOST_CHECK_CLOSE(values[2], 0.32, 1.0e-8); BOOST_CHECK_CLOSE(values[3], 1.0 - 0.70 - 0.01, 1.0e-8); } BOOST_CHECK_MESSAGE(check.isViolated(), "Test must not be violated"); BOOST_CHECK_MESSAGE(! check.isCritical(), "Test must not be violated at critical level"); } BOOST_AUTO_TEST_CASE(Sgl_TooLarge) { auto check = Checks::MobileOil_OW_SWmin{}; const auto expectNumExported = std::size_t{4}; { auto endPoints = Opm::EclEpsScalingPointsInfo{}; endPoints.Swl = 0.65; endPoints.Sgl = 0.05; endPoints.Sowcr = 0.32; check.test(endPoints); } { auto values = std::vector(expectNumExported); check.exportCheckValues(values.data()); BOOST_CHECK_CLOSE(values[0], 0.65, 1.0e-8); BOOST_CHECK_CLOSE(values[1], 0.05, 1.0e-8); BOOST_CHECK_CLOSE(values[2], 0.32, 1.0e-8); BOOST_CHECK_CLOSE(values[3], 1.0 - 0.65 - 0.05, 1.0e-8); } BOOST_CHECK_MESSAGE(check.isViolated(), "Test must not be violated"); BOOST_CHECK_MESSAGE(! check.isCritical(), "Test must not be violated at critical level"); } BOOST_AUTO_TEST_CASE(Sowcr_TooLarge) { auto check = Checks::MobileOil_OW_SWmin{}; const auto expectNumExported = std::size_t{4}; { auto endPoints = Opm::EclEpsScalingPointsInfo{}; endPoints.Swl = 0.65; endPoints.Sgl = 0.04; endPoints.Sowcr = 0.32; check.test(endPoints); } { auto values = std::vector(expectNumExported); check.exportCheckValues(values.data()); BOOST_CHECK_CLOSE(values[0], 0.65, 1.0e-8); BOOST_CHECK_CLOSE(values[1], 0.04, 1.0e-8); BOOST_CHECK_CLOSE(values[2], 0.32, 1.0e-8); BOOST_CHECK_CLOSE(values[3], 1.0 - 0.65 - 0.04, 1.0e-8); } BOOST_CHECK_MESSAGE(check.isViolated(), "Test must not be violated"); BOOST_CHECK_MESSAGE(! check.isCritical(), "Test must not be violated at critical level"); } BOOST_AUTO_TEST_SUITE_END() // Mobile_Oil_Swmin // --------------------------------------------------------------------------- BOOST_AUTO_TEST_SUITE(Mobile_Oil_Swcr) BOOST_AUTO_TEST_CASE(All_Good) { auto check = Checks::MobileOil_OW_SWcr{}; const auto expectNumExported = std::size_t{4}; BOOST_CHECK_EQUAL(check.numExportedCheckValues(), expectNumExported); { auto columns = std::vector(expectNumExported); check.columnNames(columns.data()); BOOST_CHECK_EQUAL(columns[0], "SGL"); BOOST_CHECK_EQUAL(columns[1], "SWCR"); BOOST_CHECK_EQUAL(columns[2], "SOWCR"); BOOST_CHECK_EQUAL(columns[3], "1 - SWCR - SGL"); } { auto endPoints = Opm::EclEpsScalingPointsInfo{}; endPoints.Sgl = 0.15f; endPoints.Swcr = 0.01f; endPoints.Sowcr = 0.15f; check.test(endPoints); } { auto values = std::vector(expectNumExported); check.exportCheckValues(values.data()); BOOST_CHECK_CLOSE(values[0], 0.15f, 1.0e-6f); BOOST_CHECK_CLOSE(values[1], 0.01f, 1.0e-6f); BOOST_CHECK_CLOSE(values[2], 0.15f, 1.0e-6f); BOOST_CHECK_CLOSE(values[3], 1.0f - 0.15f - 0.01, 1.0e-5f); } BOOST_CHECK_MESSAGE(! check.isViolated(), "Test must not be violated"); BOOST_CHECK_MESSAGE(! check.isCritical(), "Test must not be violated at critical level"); } BOOST_AUTO_TEST_CASE(Non_Finite) { // NaN if constexpr (std::numeric_limits::has_quiet_NaN) { const auto expectNumExported = std::size_t{4}; auto endPoints = Opm::EclEpsScalingPointsInfo{}; endPoints.Sgl = std::numeric_limits::quiet_NaN(); endPoints.Swcr = 0.01f; endPoints.Sowcr = 0.32f; auto check = Checks::MobileOil_OW_SWcr{}; check.test(endPoints); { auto values = std::vector(expectNumExported); check.exportCheckValues(values.data()); BOOST_CHECK_MESSAGE(std::isnan(values[0]), "Sgl value must be NaN"); BOOST_CHECK_CLOSE (values[1], 0.01f, 1.0e-6f); BOOST_CHECK_CLOSE (values[2], 0.32f, 1.0e-6f); BOOST_CHECK_MESSAGE(std::isnan(values[3]), "1 - Sgl - Swcr value must be NaN"); BOOST_CHECK_MESSAGE(check.isViolated(), "Check must be violated"); BOOST_CHECK_MESSAGE(check.isCritical(), "Check must be violated at critical level"); } endPoints.Sgl = 0.6f; endPoints.Swcr = std::numeric_limits::quiet_NaN(); endPoints.Sowcr = 0.32f; check.test(endPoints); { auto values = std::vector(expectNumExported); check.exportCheckValues(values.data()); BOOST_CHECK_CLOSE (values[0], 0.6f, 1.0e-6f); BOOST_CHECK_MESSAGE(std::isnan(values[1]), "Swcr value must be NaN"); BOOST_CHECK_CLOSE (values[2], 0.32f, 1.0e-6f); BOOST_CHECK_MESSAGE(std::isnan(values[3]), "1 - Sgl - Swcr value must be NaN"); BOOST_CHECK_MESSAGE(check.isViolated(), "Check must be violated"); BOOST_CHECK_MESSAGE(check.isCritical(), "Check must be violated at critical level"); } endPoints.Sgl = 0.6f; endPoints.Swcr = 0.01f; endPoints.Sowcr = std::numeric_limits::quiet_NaN(); check.test(endPoints); { auto values = std::vector(expectNumExported); check.exportCheckValues(values.data()); BOOST_CHECK_CLOSE (values[0], 0.6f, 1.0e-6f); BOOST_CHECK_CLOSE (values[1], 0.01f, 1.0e-6f); BOOST_CHECK_MESSAGE(std::isnan(values[2]), "Sowcr value must be NaN"); BOOST_CHECK_CLOSE (values[3], 1.0f - 0.6f - 0.01f, 1.0e-6); BOOST_CHECK_MESSAGE(check.isViolated(), "Check must be violated"); BOOST_CHECK_MESSAGE(check.isCritical(), "Check must be violated at critical level"); } endPoints.Sgl = std::numeric_limits::quiet_NaN(); endPoints.Swcr = std::numeric_limits::quiet_NaN(); endPoints.Sowcr = 0.32f; check.test(endPoints); { auto values = std::vector(expectNumExported); check.exportCheckValues(values.data()); BOOST_CHECK_MESSAGE(std::isnan(values[0]), "Sgl value must be NaN"); BOOST_CHECK_MESSAGE(std::isnan(values[1]), "Swcr value must be NaN"); BOOST_CHECK_CLOSE (values[2], 0.32f, 1.0e-6f); BOOST_CHECK_MESSAGE(std::isnan(values[3]), "1 - Sgl - Swcr value must be NaN"); BOOST_CHECK_MESSAGE(check.isViolated(), "Check must be violated"); BOOST_CHECK_MESSAGE(check.isCritical(), "Check must be violated at critical level"); } endPoints.Sgl = std::numeric_limits::quiet_NaN(); endPoints.Swcr = 0.01f; endPoints.Sowcr = std::numeric_limits::quiet_NaN(); check.test(endPoints); { auto values = std::vector(expectNumExported); check.exportCheckValues(values.data()); BOOST_CHECK_MESSAGE(std::isnan(values[0]), "Sgl value must be NaN"); BOOST_CHECK_CLOSE (values[1], 0.01f, 1.0e-6f); BOOST_CHECK_MESSAGE(std::isnan(values[2]), "Sowcr value must be NaN"); BOOST_CHECK_MESSAGE(std::isnan(values[3]), "1 - Sgl - Swcr value must be NaN"); BOOST_CHECK_MESSAGE(check.isViolated(), "Check must be violated"); BOOST_CHECK_MESSAGE(check.isCritical(), "Check must be violated at critical level"); } endPoints.Sgl = std::numeric_limits::quiet_NaN(); endPoints.Swcr = std::numeric_limits::quiet_NaN(); endPoints.Sowcr = std::numeric_limits::quiet_NaN(); check.test(endPoints); { auto values = std::vector(expectNumExported); check.exportCheckValues(values.data()); BOOST_CHECK_MESSAGE(std::isnan(values[0]), "Sgl value must be NaN"); BOOST_CHECK_MESSAGE(std::isnan(values[1]), "Sgu value must be NaN"); BOOST_CHECK_MESSAGE(std::isnan(values[2]), "Sowcr value must be NaN"); BOOST_CHECK_MESSAGE(std::isnan(values[3]), "1 - Sgl - Swcr value must be NaN"); BOOST_CHECK_MESSAGE(check.isViolated(), "Check must be violated"); BOOST_CHECK_MESSAGE(check.isCritical(), "Check must be violated at critical level"); } } // Inf if constexpr (std::numeric_limits::has_infinity) { const auto expectNumExported = std::size_t{4}; auto endPoints = Opm::EclEpsScalingPointsInfo{}; endPoints.Sgl = std::numeric_limits::infinity(); endPoints.Swcr = 0.01f; endPoints.Sowcr = 0.32f; auto check = Checks::MobileOil_OW_SWcr{}; check.test(endPoints); { auto values = std::vector(expectNumExported); check.exportCheckValues(values.data()); BOOST_CHECK_MESSAGE(std::isinf(values[0]), "Sgl value must be Inf"); BOOST_CHECK_CLOSE (values[1], 0.01f, 1.0e-6f); BOOST_CHECK_CLOSE (values[2], 0.32f, 1.0e-6f); BOOST_CHECK_MESSAGE(std::isinf(values[3]), "1 - Sgl - Swcr value must be Inf"); BOOST_CHECK_MESSAGE(check.isViolated(), "Check must be violated"); BOOST_CHECK_MESSAGE(check.isCritical(), "Check must be violated at critical level"); } endPoints.Sgl = 0.6f; endPoints.Swcr = std::numeric_limits::infinity(); endPoints.Sowcr = 0.32f; check.test(endPoints); { auto values = std::vector(expectNumExported); check.exportCheckValues(values.data()); BOOST_CHECK_CLOSE (values[0], 0.6f, 1.0e-6f); BOOST_CHECK_MESSAGE(std::isinf(values[1]), "Swcr value must be Inf"); BOOST_CHECK_CLOSE (values[2], 0.32f, 1.0e-6f); BOOST_CHECK_MESSAGE(std::isinf(values[3]), "1 - Sgl - Swcr value must be Inf"); BOOST_CHECK_MESSAGE(check.isViolated(), "Check must be violated"); BOOST_CHECK_MESSAGE(check.isCritical(), "Check must be violated at critical level"); } endPoints.Sgl = 0.6f; endPoints.Swcr = 0.01f; endPoints.Sowcr = std::numeric_limits::infinity(); check.test(endPoints); { auto values = std::vector(expectNumExported); check.exportCheckValues(values.data()); BOOST_CHECK_CLOSE (values[0], 0.6f, 1.0e-6f); BOOST_CHECK_CLOSE (values[1], 0.01f, 1.0e-6f); BOOST_CHECK_MESSAGE(std::isinf(values[2]), "Sowcr value must be Inf"); BOOST_CHECK_CLOSE (values[3], 1.0f - 0.6f - 0.01f, 1.0e-6); BOOST_CHECK_MESSAGE(check.isViolated(), "Check must be violated"); BOOST_CHECK_MESSAGE(check.isCritical(), "Check must be violated at critical level"); } endPoints.Sgl = std::numeric_limits::infinity(); endPoints.Swcr = std::numeric_limits::infinity(); endPoints.Sowcr = 0.32f; check.test(endPoints); { auto values = std::vector(expectNumExported); check.exportCheckValues(values.data()); BOOST_CHECK_MESSAGE(std::isinf(values[0]), "Sgl value must be Inf"); BOOST_CHECK_MESSAGE(std::isinf(values[1]), "Swcr value must be Inf"); BOOST_CHECK_CLOSE (values[2], 0.32f, 1.0e-6f); BOOST_CHECK_MESSAGE(std::isinf(values[3]), "1 - Sgl - Swcr value must be Inf"); BOOST_CHECK_MESSAGE(check.isViolated(), "Check must be violated"); BOOST_CHECK_MESSAGE(check.isCritical(), "Check must be violated at critical level"); } endPoints.Sgl = std::numeric_limits::infinity(); endPoints.Swcr = 0.01f; endPoints.Sowcr = std::numeric_limits::infinity(); check.test(endPoints); { auto values = std::vector(expectNumExported); check.exportCheckValues(values.data()); BOOST_CHECK_MESSAGE(std::isinf(values[0]), "Sgl value must be Inf"); BOOST_CHECK_CLOSE (values[1], 0.01f, 1.0e-6f); BOOST_CHECK_MESSAGE(std::isinf(values[2]), "Sowcr value must be Inf"); BOOST_CHECK_MESSAGE(std::isinf(values[3]), "1 - Sgl - Swcr value must be Inf"); BOOST_CHECK_MESSAGE(check.isViolated(), "Check must be violated"); BOOST_CHECK_MESSAGE(check.isCritical(), "Check must be violated at critical level"); } endPoints.Sgl = std::numeric_limits::infinity(); endPoints.Swcr = std::numeric_limits::infinity(); endPoints.Sowcr = std::numeric_limits::infinity(); check.test(endPoints); { auto values = std::vector(expectNumExported); check.exportCheckValues(values.data()); BOOST_CHECK_MESSAGE(std::isinf(values[0]), "Sgl value must be Inf"); BOOST_CHECK_MESSAGE(std::isinf(values[1]), "Swcr value must be Inf"); BOOST_CHECK_MESSAGE(std::isinf(values[2]), "Sowcr value must be Inf"); BOOST_CHECK_MESSAGE(std::isinf(values[3]), "1 - Sgl - Swcr value must be Inf"); BOOST_CHECK_MESSAGE(check.isViolated(), "Check must be violated"); BOOST_CHECK_MESSAGE(check.isCritical(), "Check must be violated at critical level"); } } } BOOST_AUTO_TEST_CASE(Sgl_TooLarge) { auto check = Checks::MobileOil_OW_SWcr{}; const auto expectNumExported = std::size_t{4}; { auto endPoints = Opm::EclEpsScalingPointsInfo{}; endPoints.Sgl = 0.70; endPoints.Swcr = 0.01; endPoints.Sowcr = 0.32; check.test(endPoints); } { auto values = std::vector(expectNumExported); check.exportCheckValues(values.data()); BOOST_CHECK_CLOSE(values[0], 0.70, 1.0e-8); BOOST_CHECK_CLOSE(values[1], 0.01, 1.0e-8); BOOST_CHECK_CLOSE(values[2], 0.32, 1.0e-8); BOOST_CHECK_CLOSE(values[3], 1.0 - 0.70 - 0.01, 1.0e-8); } BOOST_CHECK_MESSAGE(check.isViolated(), "Test must not be violated"); BOOST_CHECK_MESSAGE(! check.isCritical(), "Test must not be violated at critical level"); } BOOST_AUTO_TEST_CASE(Swcr_TooLarge) { auto check = Checks::MobileOil_OW_SWcr{}; const auto expectNumExported = std::size_t{4}; { auto endPoints = Opm::EclEpsScalingPointsInfo{}; endPoints.Sgl = 0.65; endPoints.Swcr = 0.05; endPoints.Sowcr = 0.32; check.test(endPoints); } { auto values = std::vector(expectNumExported); check.exportCheckValues(values.data()); BOOST_CHECK_CLOSE(values[0], 0.65, 1.0e-8); BOOST_CHECK_CLOSE(values[1], 0.05, 1.0e-8); BOOST_CHECK_CLOSE(values[2], 0.32, 1.0e-8); BOOST_CHECK_CLOSE(values[3], 1.0 - 0.65 - 0.05, 1.0e-8); } BOOST_CHECK_MESSAGE(check.isViolated(), "Test must not be violated"); BOOST_CHECK_MESSAGE(! check.isCritical(), "Test must not be violated at critical level"); } BOOST_AUTO_TEST_CASE(Sowcr_TooLarge) { auto check = Checks::MobileOil_OW_SWcr{}; const auto expectNumExported = std::size_t{4}; { auto endPoints = Opm::EclEpsScalingPointsInfo{}; endPoints.Sgl = 0.65; endPoints.Swcr = 0.04; endPoints.Sowcr = 0.32; check.test(endPoints); } { auto values = std::vector(expectNumExported); check.exportCheckValues(values.data()); BOOST_CHECK_CLOSE(values[0], 0.65, 1.0e-8); BOOST_CHECK_CLOSE(values[1], 0.04, 1.0e-8); BOOST_CHECK_CLOSE(values[2], 0.32, 1.0e-8); BOOST_CHECK_CLOSE(values[3], 1.0 - 0.65 - 0.04, 1.0e-8); } BOOST_CHECK_MESSAGE(check.isViolated(), "Test must not be violated"); BOOST_CHECK_MESSAGE(! check.isCritical(), "Test must not be violated at critical level"); } BOOST_AUTO_TEST_SUITE_END() // Mobile_Oil_Swcr // --------------------------------------------------------------------------- BOOST_AUTO_TEST_SUITE_END() // Oil_Water_System