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()); }