-
Notifications
You must be signed in to change notification settings - Fork 61
Feature: ancestor face computation function for the scheme #1958
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
holke
wants to merge
6
commits into
main
Choose a base branch
from
feature-ancestor_face
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
6 commits
Select commit
Hold shift + click to select a range
2c56595
Start implementation of ancestor_face helper function
holke d67a93b
add declaration of ancestor_face function to scheme
holke c89b612
Change access to underlying impl. Not a pointer
holke 7015869
Extend parent face test with two calls of ancestor face function
holke 058776f
rename variables since typo script doesnt like them
holke 598a563
Merge branch 'main' into feature-ancestor_face
holke File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -63,6 +63,50 @@ class t8_scheme_helpers: public t8_crtp_basic<TUnderlyingEclassScheme> { | |
| { | ||
| return TEclass; | ||
| } | ||
|
|
||
| /** Given a face of an element and a level coarser than (or equal to) | ||
| * the element's level, return the face number | ||
| * of the ancestor of the element that matches the element's face. Or return -1 if | ||
| * no face of the ancestor matches the face. | ||
| * \param [in] tree_class The eclass of the current tree. | ||
| * \param [in] element The element. | ||
| * \param [in] ancestor_level A refinement level smaller than (or equal to) \a element's level. | ||
| * \param [in] face Then number of a face of \a element. | ||
| * \return If \a face of \a element is a subface of a face of \a element's ancestor at level \a ancestor_level, | ||
| * the face number of this face. Otherwise -1. | ||
| * \note For the root element this function always returns \a face. | ||
| */ | ||
| inline int | ||
|
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Please check if this can be constexpr |
||
| element_face_get_ancestor_face (const t8_element_t *element, const int ancestor_level, const int face) const | ||
| { | ||
| auto underlying_impl = this->underlying (); // Reference to the underlying scheme implementation | ||
|
|
||
| const int element_level = underlying_impl.element_get_level (element); | ||
| T8_ASSERT (element_level >= ancestor_level); | ||
| if (element_level == ancestor_level) { | ||
| // On the same level, the return value is the face itself | ||
| return face; | ||
| } | ||
| // Allocate memory for a temporary element. | ||
| t8_element_t *parent; | ||
| underlying_impl.element_new (1, &parent); | ||
| // Pointer to a temoporary element, that will move up the refinement hierarchy | ||
| const t8_element_t *temp_element = element; | ||
| int temp_face = face; | ||
| for (int ilevel = element_level; ilevel > ancestor_level; --ilevel) { | ||
| // Go one level up in the refinement hierarchy with the face | ||
| temp_face = underlying_impl.element_face_get_parent_face (temp_element, temp_face); | ||
| if (temp_face == -1) { | ||
| // This face is not a subface of an ancestor face. | ||
| underlying_impl.element_destroy (1, &parent); | ||
| return -1; | ||
| } | ||
| underlying_impl.element_get_parent (temp_element, parent); | ||
| temp_element = parent; | ||
| } | ||
| underlying_impl.element_destroy (1, &parent); | ||
| return temp_face; | ||
| } | ||
| }; | ||
|
|
||
| #endif /* T8_SCHEME_HELPERS_HXX */ | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -27,6 +27,9 @@ | |
| #include "t8_gtest_dfs_base.hxx" | ||
| #include <test/t8_gtest_macros.hxx> | ||
|
|
||
| /* TODO: extend this test or new test. On each level, | ||
|
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Can you make an issue out of this ToDo? |
||
| * go multiple levels below and check against ancestor face */ | ||
|
|
||
| class class_child_parent_face: public TestDFS { | ||
| void | ||
| check_element () override | ||
|
|
@@ -49,6 +52,17 @@ class class_child_parent_face: public TestDFS { | |
| const int parentface = scheme->element_face_get_parent_face (eclass, children[ifacechild], childface); | ||
| /* Check, that this is equal to the face that we started with */ | ||
| EXPECT_EQ (iface, parentface); | ||
| const int element_level = scheme->element_get_level (eclass, element); | ||
| // Check the ancestor face function when input is the child and the level of the child. | ||
| // We expect the output face to be the input face | ||
| const int ancestor_face_same_level | ||
| = scheme->element_face_get_ancestor_face (eclass, children[ifacechild], element_level + 1, childface); | ||
| EXPECT_EQ (childface, ancestor_face_same_level); | ||
| // Check the ancestor face function when input is the element level/ | ||
| // We expect the output face to be the original face | ||
| const int ancestor_face_one_level_higher | ||
| = scheme->element_face_get_ancestor_face (eclass, children[ifacechild], element_level, childface); | ||
| EXPECT_EQ (iface, ancestor_face_one_level_higher); | ||
| } | ||
| scheme->element_destroy (eclass, num_face_children, children); | ||
| T8_TESTSUITE_FREE (children); | ||
|
|
||
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.