From 99c3ec2824c634acaa816157caa2447f1a11a9a7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?B=C3=A5rd=20Skaflestad?= Date: Tue, 14 May 2013 14:59:31 +0200 Subject: [PATCH 1/8] Start a test suite for class BlackoilPropsAd. Relies on external data ("fluid.data") to describe the fluid model. --- fluid.data | 66 ++++++++++++++++++++++++++++++++++++++++ test_boprops_ad.cpp | 74 +++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 140 insertions(+) create mode 100644 fluid.data create mode 100644 test_boprops_ad.cpp diff --git a/fluid.data b/fluid.data new file mode 100644 index 000000000..820da5e76 --- /dev/null +++ b/fluid.data @@ -0,0 +1,66 @@ +RUNSPEC + +DIMENS +1 1 1 +/ + +OIL +WATER + +METRIC + +-- ===================================================================== +GRID + +DXV +1 +/ + +DYV +1 +/ + +DZV +0.1 +/ + +DEPTHZ +4*0 +/ + +PERMX +1.01325E15 +/ + +PERMY +1.01325E15 +/ + +PERMZ +1.01325E15 +/ + +PORO +1 +/ + +-- ===================================================================== +PROPS + +PVTW +-- Pw Bw(Pw) Cw muw Cv + 1 1 0 1000 0 +/ + +PVCDO +-- Po Bo(Po) Co muo Cv + 1 1 0 1000 0 +/ + +SWOF +0 0 1 0 +1 1 0 0 +/ + +-- ===================================================================== +END diff --git a/test_boprops_ad.cpp b/test_boprops_ad.cpp new file mode 100644 index 000000000..4de32c03a --- /dev/null +++ b/test_boprops_ad.cpp @@ -0,0 +1,74 @@ +/* + Copyright 2013 SINTEF ICT, Applied Mathematics. + Copyright 2013 Statoil 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 . +*/ + +#if HAVE_DYNAMIC_BOOST_TEST +#define BOOST_TEST_DYN_LINK +#endif + +#define BOOST_TEST_MODULE FluidPropertiesTest + +#include "BlackoilPropsAd.hpp" + +#include + +#include +#include +#include +#include + +#include + +struct SetupSimple { + SetupSimple() + : param() + , deck() + { + std::ifstream str("fluid.data"); + deck.read(str); + + param.insertParameter("init_rock" , false ); + param.insertParameter("threephase_model", "simple"); + } + + Opm::parameter::ParameterGroup param; + Opm::EclipseGridParser deck; +}; + + +template +struct TestFixture : public Setup +{ + TestFixture() + : Setup() + , grid (Setup::deck) + , props(Setup::deck, *grid.c_grid(), Setup::param, + Setup::param.getDefault("init_rock", false)) + { + } + + Opm::GridManager grid; + Opm::BlackoilPropertiesFromDeck props; +}; + + +BOOST_FIXTURE_TEST_CASE(Construction, TestFixture) +{ + Opm::BlackoilPropsAd boprops_ad(props); +} From 667cae6d84ad94392559d9c643bb8dec6a12f98d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?B=C3=A5rd=20Skaflestad?= Date: Tue, 14 May 2013 15:31:41 +0200 Subject: [PATCH 2/8] Expose 'param' and 'deck' in TestFixture. --- test_boprops_ad.cpp | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/test_boprops_ad.cpp b/test_boprops_ad.cpp index 4de32c03a..3827373df 100644 --- a/test_boprops_ad.cpp +++ b/test_boprops_ad.cpp @@ -57,12 +57,15 @@ struct TestFixture : public Setup { TestFixture() : Setup() - , grid (Setup::deck) - , props(Setup::deck, *grid.c_grid(), Setup::param, - Setup::param.getDefault("init_rock", false)) + , grid (deck) + , props(deck, *grid.c_grid(), param, + param.getDefault("init_rock", false)) { } + using Setup::param; + using Setup::deck; + Opm::GridManager grid; Opm::BlackoilPropertiesFromDeck props; }; From ac5350a598d02b904e5c0a80589868a8e8500e03 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?B=C3=A5rd=20Skaflestad?= Date: Tue, 14 May 2013 15:41:34 +0200 Subject: [PATCH 3/8] All "parameter" values must be strings. --- test_boprops_ad.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test_boprops_ad.cpp b/test_boprops_ad.cpp index 3827373df..325f3534f 100644 --- a/test_boprops_ad.cpp +++ b/test_boprops_ad.cpp @@ -43,7 +43,7 @@ struct SetupSimple { std::ifstream str("fluid.data"); deck.read(str); - param.insertParameter("init_rock" , false ); + param.insertParameter("init_rock" , "false" ); param.insertParameter("threephase_model", "simple"); } From 6583aca34c8a9c171b3149f3d83537ee0155dd18 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?B=C3=A5rd=20Skaflestad?= Date: Tue, 14 May 2013 15:41:45 +0200 Subject: [PATCH 4/8] Default to using tables as-is. --- test_boprops_ad.cpp | 2 ++ 1 file changed, 2 insertions(+) diff --git a/test_boprops_ad.cpp b/test_boprops_ad.cpp index 325f3534f..353dbe063 100644 --- a/test_boprops_ad.cpp +++ b/test_boprops_ad.cpp @@ -45,6 +45,8 @@ struct SetupSimple { param.insertParameter("init_rock" , "false" ); param.insertParameter("threephase_model", "simple"); + param.insertParameter("pvt_tab_size" , "0" ); + param.insertParameter("sat_tab_size" , "0" ); } Opm::parameter::ParameterGroup param; From eb1836c977913268143b7ee49fd1672f5f9ea2d2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?B=C3=A5rd=20Skaflestad?= Date: Tue, 14 May 2013 15:45:31 +0200 Subject: [PATCH 5/8] Disable 'param' output for all test cases. --- test_boprops_ad.cpp | 1 + 1 file changed, 1 insertion(+) diff --git a/test_boprops_ad.cpp b/test_boprops_ad.cpp index 353dbe063..43216ff82 100644 --- a/test_boprops_ad.cpp +++ b/test_boprops_ad.cpp @@ -43,6 +43,7 @@ struct SetupSimple { std::ifstream str("fluid.data"); deck.read(str); + param.disableOutput(); param.insertParameter("init_rock" , "false" ); param.insertParameter("threephase_model", "simple"); param.insertParameter("pvt_tab_size" , "0" ); From cebb6fd5fa9749f6b4ab386abee0975645704f5c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?B=C3=A5rd=20Skaflestad?= Date: Tue, 14 May 2013 15:46:00 +0200 Subject: [PATCH 6/8] Add required fluid densities --- fluid.data | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/fluid.data b/fluid.data index 820da5e76..a83345b3b 100644 --- a/fluid.data +++ b/fluid.data @@ -62,5 +62,9 @@ SWOF 1 1 0 0 / +DENSITY + 800 1000 1 +/ + -- ===================================================================== END From b85c0dce881009c5cfbb4ad62ab1a65dd7dc87df Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?B=C3=A5rd=20Skaflestad?= Date: Tue, 14 May 2013 17:29:49 +0200 Subject: [PATCH 7/8] Add test cases for density and water viscosity. Currently, ViscosityAD fails due to missing pressure derivatives in the viscosity primitives. --- test_boprops_ad.cpp | 76 +++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 76 insertions(+) diff --git a/test_boprops_ad.cpp b/test_boprops_ad.cpp index 43216ff82..428db1f05 100644 --- a/test_boprops_ad.cpp +++ b/test_boprops_ad.cpp @@ -31,6 +31,7 @@ #include #include #include +#include #include #include @@ -78,3 +79,78 @@ BOOST_FIXTURE_TEST_CASE(Construction, TestFixture) { Opm::BlackoilPropsAd boprops_ad(props); } + + +BOOST_FIXTURE_TEST_CASE(SurfaceDensity, TestFixture) +{ + Opm::BlackoilPropsAd boprops_ad(props); + + const double* rho0 = props .surfaceDensity(); + const double* rho0AD = boprops_ad.surfaceDensity(); + + enum { Water = Opm::BlackoilPropsAd::Water }; + BOOST_CHECK_EQUAL(rho0AD[ Water ], rho0[ Water ]); + + enum { Oil = Opm::BlackoilPropsAd::Oil }; + BOOST_CHECK_EQUAL(rho0AD[ Oil ], rho0[ Oil ]); + + enum { Gas = Opm::BlackoilPropsAd::Gas }; + BOOST_CHECK_EQUAL(rho0AD[ Gas ], rho0[ Gas ]); +} + + +BOOST_FIXTURE_TEST_CASE(ViscosityValue, TestFixture) +{ + Opm::BlackoilPropsAd boprops_ad(props); + + const Opm::BlackoilPropsAd::Cells cells(5, 0); + + typedef Opm::BlackoilPropsAd::V V; + + V Vpw; + Vpw.resize(cells.size()); + Vpw[0] = 1*Opm::unit::barsa; + Vpw[1] = 2*Opm::unit::barsa; + Vpw[2] = 4*Opm::unit::barsa; + Vpw[3] = 8*Opm::unit::barsa; + Vpw[4] = 16*Opm::unit::barsa; + + const Opm::BlackoilPropsAd::V VmuWat = boprops_ad.muWat(Vpw, cells); + + // Zero pressure dependence in water viscosity + for (V::Index i = 0, n = VmuWat.size(); i < n; ++i) { + BOOST_CHECK_EQUAL(VmuWat[i], VmuWat[0]); + } +} + + +BOOST_FIXTURE_TEST_CASE(ViscosityAD, TestFixture) +{ + Opm::BlackoilPropsAd boprops_ad(props); + + const Opm::BlackoilPropsAd::Cells cells(5, 0); + + typedef Opm::BlackoilPropsAd::V V; + + V Vpw; + Vpw.resize(cells.size()); + Vpw[0] = 1*Opm::unit::barsa; + Vpw[1] = 2*Opm::unit::barsa; + Vpw[2] = 4*Opm::unit::barsa; + Vpw[3] = 8*Opm::unit::barsa; + Vpw[4] = 16*Opm::unit::barsa; + + typedef Opm::BlackoilPropsAd::ADB ADB; + + const V VmuWat = boprops_ad.muWat(Vpw, cells); + for (V::Index i = 0, n = Vpw.size(); i < n; ++i) { + const std::vector bp(1, grid.c_grid()->number_of_cells); + + const Opm::BlackoilPropsAd::Cells c(1, 0); + const V pw = V(1, 1) * Vpw[i]; + const ADB Apw = ADB::variable(0, pw, bp); + const ADB AmuWat = boprops_ad.muWat(Apw, c); + + BOOST_CHECK_EQUAL(AmuWat.value()[0], VmuWat[i]); + } +} From 0225e6c9ee386c322c8055d33be0c89f5b7c2766 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?B=C3=A5rd=20Skaflestad?= Date: Tue, 14 May 2013 17:45:20 +0200 Subject: [PATCH 8/8] Ignore autosave files from Vim. --- .gitignore | 1 + 1 file changed, 1 insertion(+) diff --git a/.gitignore b/.gitignore index f3e2100e6..2cf3eaafe 100644 --- a/.gitignore +++ b/.gitignore @@ -1,5 +1,6 @@ # Editor autosave files *~ +*.swp # Compiled Object files *.slo