From eb565d91b5f7277102f45816c1f34fdf4d2f51fd Mon Sep 17 00:00:00 2001 From: Felix Schindler <felix.schindler@wwu.de> Date: Wed, 21 Nov 2018 10:37:22 +0100 Subject: [PATCH] [test.dd_glued] disable intersection orientation check We only use this in nonconforming settings, where we can handle this. --- dune/xt/grid/test/dd_glued.hh | 143 ------------------------------ dune/xt/grid/test/dd_glued_2d.cc | 88 ------------------- dune/xt/grid/test/dd_glued_3d.cc | 144 ------------------------------- 3 files changed, 375 deletions(-) diff --git a/dune/xt/grid/test/dd_glued.hh b/dune/xt/grid/test/dd_glued.hh index 1ff2f5a54..8022cbea1 100644 --- a/dune/xt/grid/test/dd_glued.hh +++ b/dune/xt/grid/test/dd_glued.hh @@ -171,149 +171,6 @@ struct GluedDdGridTest : public ::testing::Test dd_grid_->visualize(Expectations::id()); } // ... visualize_is_callable(...) - void check_intersection_orientation_for_equal_levels(const bool expect_failure = Expectations::failure_for_equal()) - { - setup(); - ASSERT_NE(macro_grid_, nullptr) << "This should not happen!"; - ASSERT_NE(dd_grid_, nullptr) << "This should not happen!"; - size_t failure = 0; - - if (local_layer == Layers::level) { - for (int level = 0; level <= dd_grid_->max_local_level(0); ++level) - failure += check_intersections_for_levels(level, level, expect_failure); - } else { - failure += check_intersections_for_levels(-1, -1, expect_failure); - } - - if (failure) - std::cout << "The actual numbers of broken intersections are\n" - << convert_to_initializer_list_str(count_wrong_intersections_on_all_levels()) << std::endl; - } // ... check_intersection_orientation_for_equal_levels(...) - - void check_intersection_orientation_for_higher_neighbor_levels( - const bool expect_failure = Expectations::failure_for_higher()) - { - setup(); - ASSERT_NE(macro_grid_, nullptr) << "This should not happen!"; - ASSERT_NE(dd_grid_, nullptr) << "This should not happen!"; - size_t failure = 0; - - if (local_layer == Layers::level) { - for (int entity_level = 0; entity_level <= dd_grid_->max_local_level(0); ++entity_level) - for (int neighbor_level = entity_level; neighbor_level <= dd_grid_->max_local_level(0); ++neighbor_level) - failure += check_intersections_for_levels(entity_level, neighbor_level, expect_failure); - } - - if (failure) - std::cout << "The actual numbers of broken intersections are\n" - << convert_to_initializer_list_str(count_wrong_intersections_on_all_levels()) << std::endl; - } // ... check_intersection_orientation_for_higher_neighbor_levels(...) - - void check_intersection_orientation_for_lower_or_equal_neighbor_levels( - const bool expect_failure = Expectations::failure_for_lower_or_equal()) - { - setup(); - ASSERT_NE(macro_grid_, nullptr) << "This should not happen!"; - ASSERT_NE(dd_grid_, nullptr) << "This should not happen!"; - size_t failure = 0; - - if (local_layer == Layers::level) { - for (int entity_level = 0; entity_level <= dd_grid_->max_local_level(0); ++entity_level) - for (int neighbor_level = 0; neighbor_level <= entity_level; ++neighbor_level) - failure += check_intersections_for_levels(entity_level, neighbor_level, expect_failure); - } - - if (failure) - std::cout << "The actual numbers of broken intersections are\n" - << convert_to_initializer_list_str(count_wrong_intersections_on_all_levels()) << std::endl; - } // ... check_intersection_orientation_for_lower_or_equal_neighbor_levels(...) - - size_t check_intersections_for_levels(const int entity_level, const int neighbor_level, const bool expect_failure) - { - size_t failure = 0; - const auto actual_num_wrongly_oriented_intersections = count_wrong_intersections(entity_level, neighbor_level); - if (expect_failure) { - const auto expected_results = Expectations::results(); - const auto search_for_levels_in_expected_results = - expected_results.find(std::make_pair(entity_level, neighbor_level)); - EXPECT_NE(search_for_levels_in_expected_results, expected_results.end()) - << "missing expected results for entity and neighbor level " - << convert_to_initializer_list_str(std::make_pair(entity_level, neighbor_level)) << ".\n" - << "-> PLEASE ADD A RECORD TO\n" - << " ExpectedResults<" << Common::Typename<MacroGridType>::value() << ", " - << Common::Typename<LocalGridType>::value() << ">!"; - if (search_for_levels_in_expected_results == expected_results.end()) { - DUNE_THROW(InvalidStateException, - "Cannot use ASSERT_EQ above, so we need to exit this way.\n\n" - << "The actual numbers of broken intersections are\n" - << convert_to_initializer_list_str(count_wrong_intersections_on_all_levels())); - } - const auto expected_num_wrongly_oriented_intersections = search_for_levels_in_expected_results->second; - if (expected_num_wrongly_oriented_intersections != actual_num_wrongly_oriented_intersections) - ++failure; - EXPECT_EQ(expected_num_wrongly_oriented_intersections, actual_num_wrongly_oriented_intersections) - << "\nTHIS IS A GOOD THING, AN ACTUAL NUMBER OF FAILURES WHICH IS LOWER THAN THE EXPECTED NUMBER OF " - << "FAILURES IS AN IMPROVEMENT!\n" - << "-> BE HAPPY AND UPDATE THE RECORD IN!\n" - << " ExpectedResults<" << Common::Typename<MacroGridType>::value() << ", " - << Common::Typename<LocalGridType>::value() << ">!\n" - << "IF THE UPDATED RECORDS DO NOT INDICATE FAILURES ANYMORE, UPDATE THE TESTS!\n"; - } else { - if (actual_num_wrongly_oriented_intersections != 0) - ++failure; - EXPECT_EQ(actual_num_wrongly_oriented_intersections, 0); - } - return failure; - } // ... check_intersections(...) - - std::map<std::pair<ssize_t, ssize_t>, size_t> count_wrong_intersections_on_all_levels() - { - setup(); - if (!macro_grid_) - DUNE_THROW(InvalidStateException, "This should not happen!"); // <- cannot use ASSERT_NE here, non void return - if (!dd_grid_) - DUNE_THROW(InvalidStateException, "This should not happen!"); // <- s.a. - - std::map<std::pair<ssize_t, ssize_t>, size_t> results; - if (local_layer == Layers::level) { - for (int entity_level = 0; entity_level <= dd_grid_->max_local_level(0); ++entity_level) - for (int neighbor_level = 0; neighbor_level <= dd_grid_->max_local_level(0); ++neighbor_level) - results[std::make_pair(entity_level, neighbor_level)] = - count_wrong_intersections(entity_level, neighbor_level); - } else { - results[std::make_pair(-1, -1)] = count_wrong_intersections(-1, -1); - } - return results; - } - - size_t count_wrong_intersections(const int entity_level, const int neighbor_level) - { - setup(); - if (!macro_grid_) - DUNE_THROW(InvalidStateException, "This should not happen!"); // <- cannot use ASSERT_NE here, non void return - if (!dd_grid_) - DUNE_THROW(InvalidStateException, "This should not happen!"); // <- s.a. - - const auto& macro_grid_view = dd_grid_->macro_grid_view(); - size_t failures = 0; - for (auto&& macro_entity : Dune::elements(macro_grid_view)) { - for (auto&& macro_intersection : Dune::intersections(macro_grid_view, macro_entity)) { - if (macro_intersection.neighbor() && !macro_intersection.boundary()) { - const auto macro_neighbor = macro_intersection.outside(); - // const auto local_grid_view = dd_grid_->local_grid(macro_entity).level_view(entity_level); - const auto& coupling_glue = - dd_grid_->coupling(macro_entity, - entity_level, - macro_neighbor, - neighbor_level, - /*allow_for_broken_orientation_of_coupling_intersections=*/true); - failures += DD::check_for_broken_coupling_intersections(coupling_glue); - } - } - } - return failures; - } // ... count_wrong_intersections(...) - std::unique_ptr<GridProvider<MacroGridType>> macro_grid_; std::unique_ptr<DD::Glued<MacroGridType, LocalGridType, local_layer>> dd_grid_; }; // struct GluedDdGridTest diff --git a/dune/xt/grid/test/dd_glued_2d.cc b/dune/xt/grid/test/dd_glued_2d.cc index 23cdfe112..328726a34 100644 --- a/dune/xt/grid/test/dd_glued_2d.cc +++ b/dune/xt/grid/test/dd_glued_2d.cc @@ -43,34 +43,6 @@ struct ExpectedResults<YaspGrid<2, EquidistantOffsetCoordinates<double, 2>>, { return {4}; } - - static bool failure_for_lower_or_equal() - { - return true; - } - - static bool failure_for_equal() - { - return false; - } - - static bool failure_for_higher() - { - return false; - } - - static std::map<std::pair<ssize_t, ssize_t>, size_t> results() - { - return {{{0, 0}, 0}, - {{0, 1}, 0}, - {{0, 2}, 0}, - {{1, 0}, 24}, - {{1, 1}, 0}, - {{1, 2}, 0}, - {{2, 0}, 72}, - {{2, 1}, 48}, - {{2, 2}, 0}}; - } }; // struct ExpectedResults<YaspGrid<2, EquidistantOffsetCoordinates<double, 2>>, YaspGrid<2, // EquidistantOffsetCoordinates<double, 2>>, anything> @@ -98,34 +70,6 @@ struct ExpectedResults<YaspGrid<2, EquidistantOffsetCoordinates<double, 2>>, UGG { return {4}; } - - static bool failure_for_lower_or_equal() - { - return true; - } - - static bool failure_for_equal() - { - return false; - } - - static bool failure_for_higher() - { - return false; - } - - static std::map<std::pair<ssize_t, ssize_t>, size_t> results() - { - return {{{0, 0}, 0}, - {{0, 1}, 0}, - {{0, 2}, 0}, - {{1, 0}, 24}, - {{1, 1}, 0}, - {{1, 2}, 0}, - {{2, 0}, 72}, - {{2, 1}, 48}, - {{2, 2}, 0}}; - } }; // struct ExpectedResults<YaspGrid<2, EquidistantOffsetCoordinates<double, 2>>, UGGrid<2>, anything> #endif // HAVE_DUNE_UGGRID || HAVE_UG @@ -153,26 +97,6 @@ struct ExpectedResults<YaspGrid<2, EquidistantOffsetCoordinates<double, 2>>, Alb { return {2}; } - - static bool failure_for_lower_or_equal() - { - return true; - } - - static bool failure_for_equal() - { - return false; - } - - static bool failure_for_higher() - { - return false; - } - - static std::map<std::pair<ssize_t, ssize_t>, size_t> results() - { - return {}; - } }; // struct ExpectedResults<YaspGrid<2, EquidistantOffsetCoordinates<double, 2>>, AlbertaGrid<2, 2>, anything> #endif // HAVE_ALBERTA @@ -215,18 +139,6 @@ TYPED_TEST(GluedDdGridTest, couplings_are_of_correct_size) { this->couplings_are_of_correct_size(); } -TYPED_TEST(GluedDdGridTest, intersections_are_correctly_oriented_for_equal_levels) -{ - this->check_intersection_orientation_for_equal_levels(); -} -TYPED_TEST(GluedDdGridTest, intersections_are_correctly_oriented_for_higher_neighbor_levels) -{ - this->check_intersection_orientation_for_higher_neighbor_levels(); -} -TYPED_TEST(GluedDdGridTest, __STILL_BROKEN__intersection_orientation_is_wrong_for_lower_or_equal_neighbor_levels) -{ - this->check_intersection_orientation_for_lower_or_equal_neighbor_levels(); -} #endif // HAVE_DUNE_GRID_GLUE diff --git a/dune/xt/grid/test/dd_glued_3d.cc b/dune/xt/grid/test/dd_glued_3d.cc index d0b25f377..3d52da1f4 100644 --- a/dune/xt/grid/test/dd_glued_3d.cc +++ b/dune/xt/grid/test/dd_glued_3d.cc @@ -45,34 +45,6 @@ struct ExpectedResults<YaspGrid<3, EquidistantOffsetCoordinates<double, 3>>, // we expect 16 rectangles, each containing two triangles return {32}; } - - static bool failure_for_lower_or_equal() - { - return true; - } - - static bool failure_for_equal() - { - return true; - } - - static bool failure_for_higher() - { - return true; - } - - static std::map<std::pair<ssize_t, ssize_t>, size_t> results() - { - return {{{0, 0}, 216}, - {{0, 1}, 864}, - {{0, 2}, 3456}, - {{1, 0}, 108}, - {{1, 1}, 864}, - {{1, 2}, 3456}, - {{2, 0}, 108}, - {{2, 1}, 108}, - {{2, 2}, 3456}}; - } }; // struct ExpectedResults<YaspGrid<3, EquidistantOffsetCoordinates<double, 3>>, YaspGrid<3, // EquidistantOffsetCoordinates<double, 3>>, anything> @@ -102,34 +74,6 @@ struct ExpectedResults<ALUGrid<3, 3, cube, nonconforming, Comm>, { return {32}; } - - static bool failure_for_lower_or_equal() - { - return true; - } - - static bool failure_for_equal() - { - return true; - } - - static bool failure_for_higher() - { - return true; - } - - static std::map<std::pair<ssize_t, ssize_t>, size_t> results() - { - return {{{0, 0}, 216}, - {{0, 1}, 864}, - {{0, 2}, 3456}, - {{1, 0}, 108}, - {{1, 1}, 864}, - {{1, 2}, 3456}, - {{2, 0}, 108}, - {{2, 1}, 108}, - {{2, 2}, 3456}}; - } }; // struct ExpectedResults<YaspGrid<3, EquidistantOffsetCoordinates<double, 3>>, ALUGrid<3, 3, simplex, nonconforming, // Comm>, anything> @@ -157,34 +101,6 @@ struct ExpectedResults<YaspGrid<3, EquidistantOffsetCoordinates<double, 3>>, { return {32}; } - - static bool failure_for_lower_or_equal() - { - return true; - } - - static bool failure_for_equal() - { - return true; - } - - static bool failure_for_higher() - { - return true; - } - - static std::map<std::pair<ssize_t, ssize_t>, size_t> results() - { - return {{{0, 0}, 216}, - {{0, 1}, 864}, - {{0, 2}, 3456}, - {{1, 0}, 108}, - {{1, 1}, 864}, - {{1, 2}, 3456}, - {{2, 0}, 108}, - {{2, 1}, 108}, - {{2, 2}, 3456}}; - } }; // ExpectedResults<YaspGrid<3, EquidistantOffsetCoordinates<double, 3>>, ALUGrid<3, 3, cube, nonconforming, Comm>, // anything> @@ -214,34 +130,6 @@ struct ExpectedResults<YaspGrid<3, EquidistantOffsetCoordinates<double, 3>>, UGG // we expect 16 rectangles, each containing two triangles return {32}; } - - static bool failure_for_lower_or_equal() - { - return true; - } - - static bool failure_for_equal() - { - return true; - } - - static bool failure_for_higher() - { - return true; - } - - static std::map<std::pair<ssize_t, ssize_t>, size_t> results() - { - return {{{0, 0}, 216}, - {{0, 1}, 864}, - {{0, 2}, 3456}, - {{1, 0}, 72}, - {{1, 1}, 864}, - {{1, 2}, 3456}, - {{2, 0}, 72}, - {{2, 1}, 36}, - {{2, 2}, 3456}}; - } }; // struct ExpectedResults<YaspGrid<3, EquidistantOffsetCoordinates<double, 3>>, UGGrid<3>, anything> #endif // HAVE_DUNE_UGGRID || HAVE_UG @@ -269,26 +157,6 @@ struct ExpectedResults<YaspGrid<3, EquidistantOffsetCoordinates<double, 3>>, Alb { return {10}; } - - static bool failure_for_lower_or_equal() - { - return true; - } - - static bool failure_for_equal() - { - return true; - } - - static bool failure_for_higher() - { - return true; - } - - static std::map<std::pair<ssize_t, ssize_t>, size_t> results() - { - return {{{-1, -1}, 702}}; - } }; // struct ExpectedResults<YaspGrid<3, EquidistantOffsetCoordinates<double, 3>>, AlbertaGrid<3>, anything> #endif // HAVE_ALBERTA @@ -342,18 +210,6 @@ TYPED_TEST(GluedDdGridTest, couplings_are_of_correct_size) { this->couplings_are_of_correct_size(); } -TYPED_TEST(GluedDdGridTest, __STILL_BROKEN__intersections_are_correctly_oriented_for_equal_levels) -{ - this->check_intersection_orientation_for_equal_levels(); -} -TYPED_TEST(GluedDdGridTest, __STILL_BROKEN__intersections_are_correctly_oriented_for_higher_neighbor_levels) -{ - this->check_intersection_orientation_for_higher_neighbor_levels(); -} -TYPED_TEST(GluedDdGridTest, __STILL_BROKEN__intersection_orientation_is_wrong_for_lower_or_equal_neighbor_levels) -{ - this->check_intersection_orientation_for_lower_or_equal_neighbor_levels(); -} #endif // HAVE_DUNE_GRID_GLUE -- GitLab