From 84da6a28f3b4bdcdbe3844f6c6787fcee463c1e7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Atgeirr=20Fl=C3=B8=20Rasmussen?= Date: Thu, 20 Nov 2014 14:43:24 +0100 Subject: [PATCH] Added simple test, work in progress. --- opm/core/tof/AnisotropicEikonal.cpp | 4 ++++ tests/test_anisotropiceikonal.cpp | 18 +++++++++++++----- 2 files changed, 17 insertions(+), 5 deletions(-) diff --git a/opm/core/tof/AnisotropicEikonal.cpp b/opm/core/tof/AnisotropicEikonal.cpp index 9a3e278a7..d1eecc10f 100644 --- a/opm/core/tof/AnisotropicEikonal.cpp +++ b/opm/core/tof/AnisotropicEikonal.cpp @@ -29,7 +29,11 @@ namespace Opm AnisotropicEikonal2d::AnisotropicEikonal2d(const UnstructuredGrid& grid) : grid_(grid) { + if (grid.dimensions != 2) { + OPM_THROW(std::logic_error, "Grid for AnisotropicEikonal2d must be 2d."); + } cell_neighbours_ = vertexNeighbours(grid); + orderCounterClockwise(grid, cell_neighbours_); } /// Solve the eikonal equation. diff --git a/tests/test_anisotropiceikonal.cpp b/tests/test_anisotropiceikonal.cpp index 68f6f7a9a..38ca9e573 100644 --- a/tests/test_anisotropiceikonal.cpp +++ b/tests/test_anisotropiceikonal.cpp @@ -29,6 +29,7 @@ #include #include +#include using namespace Opm; @@ -36,10 +37,17 @@ BOOST_AUTO_TEST_CASE(cartesian_2d) { const GridManager gm(2, 2); const UnstructuredGrid& grid = *gm.c_grid(); -} + AnisotropicEikonal2d ae(grid); -BOOST_AUTO_TEST_CASE(cartesian_3d) -{ - const GridManager gm(3, 2, 2); - const UnstructuredGrid& grid = *gm.c_grid(); + const std::vector metric = { + 1, 0, 0, 1, + 1, 0, 0, 1, + 1, 0, 0, 1 + }; + const std::vector start = { 0 }; + std::vector sol; + ae.solve(metric.data(), start, sol); + BOOST_REQUIRE(!sol.empty()); + std::vector truth = { 0, 1, 1, std::sqrt(2) }; + BOOST_CHECK_EQUAL_COLLECTIONS(sol.begin(), sol.end(), truth.begin(), truth.end()); }