Improvement: Add test for (rather new) function t8_forest_leaf_neighbor_subface - #2388
Improvement: Add test for (rather new) function t8_forest_leaf_neighbor_subface#2388spenke91 wants to merge 4 commits into
Conversation
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #2388 +/- ##
==========================================
+ Coverage 82.28% 82.36% +0.08%
==========================================
Files 125 125
Lines 20701 20706 +5
==========================================
+ Hits 17033 17054 +21
+ Misses 3668 3652 -16 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
lenaploetzke
left a comment
There was a problem hiding this comment.
Thanks for adding the test, i have some first comments for you :)
| "t8_forest_leaf_neighbor_subface requires leaf neighbor to be one level coarser!\n"); | ||
| #endif | ||
|
|
||
| // Determine the virtual face neighbor of leaf along face. |
There was a problem hiding this comment.
I like the addition of comments! Can you also explain why we need a virtual neighbor here?
| // Determine the neighbor_leaf's children at neighbor_face (i.e., at the dual face of face). | ||
| std::array<t8_element_t *, T8_ECLASS_MAX_FACE_CHILDREN> | ||
| neigh_children_at_face; // assumes the forest is (locally) 2:1 balanced | ||
| scheme->element_new (neighbor_tree_class, neigh_children_at_face.size (), neigh_children_at_face.begin ()); |
There was a problem hiding this comment.
Isnt it enough to use num_neighbor_face_children instead of the size?
| num_children, nullptr); | ||
| // Find out which entry of neigh_children_at_face is equal to target_virtual_face_neighbor. | ||
| auto iter = std::find_if ( | ||
| neigh_children_at_face.begin (), neigh_children_at_face.end (), [&] (t8_element *candidate) -> bool { |
There was a problem hiding this comment.
I think here also end() is not necessary but only neigh_children_at_face.begin()+num_neighbor_face_children right?
|
|
||
| INSTANTIATE_TEST_SUITE_P (t8_gtest_face_neighbors, forest_face_neighbors_two_quad_mesh, AllSchemeCollections); | ||
|
|
||
| /** |
There was a problem hiding this comment.
We have a t8_gtest_adapt_callback file (where we define one test callback at the moment), i think this one could be a cool addition (such that we can reuse it in other tests). What do you think?
| /** | ||
| * \brief Class to test the functionality of \b t8_forest_leaf_neighbor_subface. | ||
| */ | ||
| class forest_face_neighbors_subface: public testing::TestWithParam<std::tuple<int, cmesh_example_base *> > { |
| void | ||
| TearDown () override | ||
| { | ||
| // Unref the |
| // ---------------------------------------------------------- | ||
| // -------- LOOP 1: Iterate over all local trees. | ||
| // ---------------------------------------------------------- | ||
| for (int itree = 0; itree < num_local_trees; itree++) { |
There was a problem hiding this comment.
| for (int itree = 0; itree < num_local_trees; itree++) { | |
| for (t8_locidx_t itree = 0; itree < num_local_trees; itree++) { |
?
| // ---------------------------------------------------------- | ||
| // -------- LOOP 2: Iterate over all local elements in the tree. | ||
| // ---------------------------------------------------------- | ||
| for (int ielem_tree = 0; ielem_tree < num_elems_tree; ielem_tree++) { |
| int check_face = -1; | ||
| int neigh_child_to_check = -1; | ||
| int i_child_at_face = -1; | ||
| ; |
There was a problem hiding this comment.
| ; | |
?
| // Make sure the face relation is also correct. | ||
| EXPECT_EQ (iface, dual_dual_face); | ||
|
|
||
| // (7.) Free memory of neigh_children and checkelem |
There was a problem hiding this comment.
| // (7.) Free memory of neigh_children and checkelem | |
| // (7.) Free memory of neigh_children and check_elem |
Closes #2295
Describe your changes here:
Adds a test to the function t8_forest_leaf_neighbor_subface added in #2216 .
All these boxes must be checked by the AUTHOR before requesting review:
Documentation:,Bugfix:,Feature:,Improvement:orOther:.All these boxes must be checked by the REVIEWERS before merging the pull request:
As a reviewer please read through all the code lines and make sure that the code is fully understood, bug free, well-documented and well-structured.
General
Tests
If the Pull request introduces code that is not covered by the github action (for example coupling with a new library):
Scripts and Wiki
scripts/internal/find_all_source_files.shto check the indentation of these files.License
doc/(or already has one).