Commit 25075c0f authored by Lukas Riedel's avatar Lukas Riedel 📝

Fix boundary condition manager test

Make tests properly fail if they never evaluate the respective
expressions. Update grid configuration to only contain a single cell.
parent 85549071
...@@ -40,6 +40,8 @@ using BC = Dune::Dorie::BoundaryCondition<typename Traits::RF>; ...@@ -40,6 +40,8 @@ using BC = Dune::Dorie::BoundaryCondition<typename Traits::RF>;
/* ------------------------------------------------------------------------- */ /* ------------------------------------------------------------------------- */
// Test BC factory creating BCs from YAML nodes // Test BC factory creating BCs from YAML nodes
// This tests checks if the construction throws appropriate exceptions for
// incompatible input.
/// BCFactory fixture. Create three factories with a different mode each. /// BCFactory fixture. Create three factories with a different mode each.
class BCFactory : public ::testing::Test class BCFactory : public ::testing::Test
...@@ -59,7 +61,7 @@ protected: ...@@ -59,7 +61,7 @@ protected:
void SetUp () override void SetUp () override
{ {
auto [inifile, log, helper] = Dune::Dorie::Setup::init(_argc, _argv); auto log = Dune::Dorie::create_logger(Dune::Dorie::log_base, helper);
_bcf_none = std::make_unique<BCF<Mode::none>>(log); _bcf_none = std::make_unique<BCF<Mode::none>>(log);
_bcf_richards = std::make_unique<BCF<Mode::richards>>(log); _bcf_richards = std::make_unique<BCF<Mode::richards>>(log);
_bcf_transport = std::make_unique<BCF<Mode::transport>>(log); _bcf_transport = std::make_unique<BCF<Mode::transport>>(log);
...@@ -126,6 +128,7 @@ TEST_F(BCFactory, Outflow) ...@@ -126,6 +128,7 @@ TEST_F(BCFactory, Outflow)
/* ------------------------------------------------------------------------- */ /* ------------------------------------------------------------------------- */
// Test BC manager and loaded BC data. // Test BC manager and loaded BC data.
// This verifies that YAML data is properly interpreted
/// BoundaryConditionManager fixture /// BoundaryConditionManager fixture
/** \tparam T BCMMode wrapped into an integral constant to appear as type /** \tparam T BCMMode wrapped into an integral constant to appear as type
...@@ -199,7 +202,7 @@ TEST_F(BCManager, Neumann) ...@@ -199,7 +202,7 @@ TEST_F(BCManager, Neumann)
auto gv = _grid->leafGridView(); auto gv = _grid->leafGridView();
auto cell = *Dune::elements(gv).begin(); auto cell = *Dune::elements(gv).begin();
if (not cell.hasBoundaryIntersections()) { if (not cell.hasBoundaryIntersections()) {
ADD_FAILURE(); FAIL();
} }
for (auto&& is : Dune::intersections(gv, cell)) { for (auto&& is : Dune::intersections(gv, cell)) {
const auto coords = is.geometry().center(); const auto coords = is.geometry().center();
...@@ -220,8 +223,11 @@ TEST_F(BCManager, Neumann) ...@@ -220,8 +223,11 @@ TEST_F(BCManager, Neumann)
dynamic_cast<NeumannBoundaryCondition<double>&>(*bc); dynamic_cast<NeumannBoundaryCondition<double>&>(*bc);
EXPECT_TRUE(bc_neumann.horizontal_projection()); EXPECT_TRUE(bc_neumann.horizontal_projection());
} }
return;
} }
} }
FAIL();
} }
TEST_F(BCManager, Dirichlet) TEST_F(BCManager, Dirichlet)
...@@ -229,7 +235,7 @@ TEST_F(BCManager, Dirichlet) ...@@ -229,7 +235,7 @@ TEST_F(BCManager, Dirichlet)
auto gv = _grid->leafGridView(); auto gv = _grid->leafGridView();
auto cell = *Dune::elements(gv).begin(); auto cell = *Dune::elements(gv).begin();
if (not cell.hasBoundaryIntersections()) { if (not cell.hasBoundaryIntersections()) {
ADD_FAILURE(); FAIL();
} }
for (auto&& is : Dune::intersections(gv, cell)) { for (auto&& is : Dune::intersections(gv, cell)) {
const auto coords = is.geometry().center(); const auto coords = is.geometry().center();
...@@ -259,8 +265,11 @@ TEST_F(BCManager, Dirichlet) ...@@ -259,8 +265,11 @@ TEST_F(BCManager, Dirichlet)
EXPECT_EQ(bc->type(), Operator::BCType::Neumann); EXPECT_EQ(bc->type(), Operator::BCType::Neumann);
EXPECT_DOUBLE_EQ(bc->evaluate(time), 0.0); EXPECT_DOUBLE_EQ(bc->evaluate(time), 0.0);
} }
return;
} }
} }
FAIL();
} }
TEST_F(BCManager, Outflow) TEST_F(BCManager, Outflow)
...@@ -268,11 +277,11 @@ TEST_F(BCManager, Outflow) ...@@ -268,11 +277,11 @@ TEST_F(BCManager, Outflow)
auto gv = _grid->leafGridView(); auto gv = _grid->leafGridView();
auto cell = *Dune::elements(gv).begin(); auto cell = *Dune::elements(gv).begin();
if (not cell.hasBoundaryIntersections()) { if (not cell.hasBoundaryIntersections()) {
ADD_FAILURE(); FAIL();
} }
for (auto&& is : Dune::intersections(gv, cell)) { for (auto&& is : Dune::intersections(gv, cell)) {
const auto coords = is.geometry().center(); const auto coords = is.geometry().center();
if (Dune::FloatCmp::eq(coords[1], 1.0)) if (Dune::FloatCmp::eq(coords[0], 0.0))
{ {
for (auto time: {0.0, 1.0, 1.5, 1.9}) { for (auto time: {0.0, 1.0, 1.5, 1.9}) {
_manager->set_time(time); _manager->set_time(time);
...@@ -284,8 +293,11 @@ TEST_F(BCManager, Outflow) ...@@ -284,8 +293,11 @@ TEST_F(BCManager, Outflow)
EXPECT_DOUBLE_EQ(time_int.begin, 0.0); EXPECT_DOUBLE_EQ(time_int.begin, 0.0);
EXPECT_DOUBLE_EQ(time_int.end, 2.0); EXPECT_DOUBLE_EQ(time_int.end, 2.0);
} }
return;
} }
} }
FAIL();
} }
// --- Main Function --- // // --- Main Function --- //
......
...@@ -5,7 +5,7 @@ _asset_path = "${PROJECT_SOURCE_DIR}/test" ...@@ -5,7 +5,7 @@ _asset_path = "${PROJECT_SOURCE_DIR}/test"
[grid] [grid]
dimensions = 2 dimensions = 2
initialLevel = 1 initialLevel = 0
gridType = rectangular gridType = rectangular
cells = 1 1 cells = 1 1
extensions = 1 1 extensions = 1 1
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment