-
Notifications
You must be signed in to change notification settings - Fork 70
Feature: add neighbor subface helper #2216
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
base: main
Are you sure you want to change the base?
Changes from all commits
8760dcf
7908780
2e89aef
fda9f6b
e265561
beb432b
5e29523
a7f955d
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -1885,6 +1885,39 @@ t8_forest_leaf_face_neighbors (t8_forest_t forest, t8_locidx_t ltreeid, const t8 | |||||||||||||||||||
| pelement_indices, pneigh_eclass, forest_is_balanced, NULL, NULL); | ||||||||||||||||||||
| } | ||||||||||||||||||||
|
|
||||||||||||||||||||
| int | ||||||||||||||||||||
| t8_forest_leaf_neighbor_subface (t8_forest_t forest, t8_locidx_t ltreeid, const t8_element_t *leaf, int face, | ||||||||||||||||||||
| t8_eclass_t neighbor_tree_class, const t8_element_t *neighbor_leaf, int neighbor_face) | ||||||||||||||||||||
| { | ||||||||||||||||||||
| t8_scheme const *scheme = t8_forest_get_scheme (forest); | ||||||||||||||||||||
|
|
||||||||||||||||||||
| t8_element_t *target = nullptr; | ||||||||||||||||||||
| scheme->element_new (neighbor_tree_class, 1, &target); | ||||||||||||||||||||
|
|
||||||||||||||||||||
| int dummy; // Can't pass a nullptr to t8_forest_element_face_neighbor below (see #2214) | ||||||||||||||||||||
| t8_forest_element_face_neighbor (forest, ltreeid, leaf, target, neighbor_tree_class, face, &dummy); | ||||||||||||||||||||
|
|
||||||||||||||||||||
| int const num_children = scheme->element_get_num_face_children (neighbor_tree_class, neighbor_leaf, neighbor_face); | ||||||||||||||||||||
|
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.
Suggested change
Contributor
Author
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. I can see why you'd want the variable name to be a little bit more explicit, but isn't the comment just paraphrasing what |
||||||||||||||||||||
|
|
||||||||||||||||||||
| std::array<t8_element_t *, 4> children; // assumes a 2:1 balanced forest | ||||||||||||||||||||
| scheme->element_new (neighbor_tree_class, 4, children.begin ()); | ||||||||||||||||||||
|
|
||||||||||||||||||||
| scheme->element_get_children_at_face (neighbor_tree_class, neighbor_leaf, neighbor_face, children.begin (), | ||||||||||||||||||||
| num_children, nullptr); | ||||||||||||||||||||
|
Comment on lines
+1902
to
+1906
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. It may well be that I missed something here, but shouldn't we use
Suggested change
Contributor
Author
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. There are two reasons for why we can't use
Maybe there is a properly named global constant which could be used instead of this magic number? |
||||||||||||||||||||
|
|
||||||||||||||||||||
|
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.
Suggested change
Contributor
Author
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. I guess this is meant to be a comment. However, after re-reading with fresh eyes this piece of code, I think this is just a |
||||||||||||||||||||
| int result = -1; | ||||||||||||||||||||
| for (int i_child = 0; i_child < num_children; ++i_child) { | ||||||||||||||||||||
| if (scheme->element_compare (neighbor_tree_class, target, children[i_child]) == 0) { | ||||||||||||||||||||
|
Comment on lines
+1909
to
+1910
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.
Suggested change
Contributor
Author
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. I'll make the adequate changes here when the previous comments are settled. |
||||||||||||||||||||
| result = i_child; | ||||||||||||||||||||
| } | ||||||||||||||||||||
| } | ||||||||||||||||||||
| T8_ASSERT(result != -1); // make sure the face was found | ||||||||||||||||||||
|
|
||||||||||||||||||||
|
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.
Suggested change
Contributor
Author
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. I think the "free memory" part is quite self evident here, but the "return sub-face ID" part is indeed not clear with the current state of the code. However maybe this just means that
dutkalex marked this conversation as resolved.
|
||||||||||||||||||||
| scheme->element_destroy (neighbor_tree_class, 4, children.begin ()); | ||||||||||||||||||||
| scheme->element_destroy (neighbor_tree_class, 1, &target); | ||||||||||||||||||||
| return result; | ||||||||||||||||||||
| } | ||||||||||||||||||||
|
|
||||||||||||||||||||
| void | ||||||||||||||||||||
| t8_forest_print_all_leaf_neighbors (t8_forest_t forest) | ||||||||||||||||||||
| { | ||||||||||||||||||||
|
|
||||||||||||||||||||
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.
Maybe we can find a more expressive name than
target? e.g.Or maybe we can even find something better?
sub_neighbor?Uh oh!
There was an error while loading. Please reload this page.
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.
"There are only two hard things in computer science: cache invalidation and naming things." 😉
I see your point, and I guess since I could not come up with a better name at the time and went for the rather undescriptive but concise option. I feel like
virtual_face_neighboris more descriptive thansub_neighbor, but it looses the "it's what we're looking for" idea. It seems hard to find a (reasonably sized) name which encodes unambiguously all this information. Maybe this means a small comment is necessary to clarify exactly what this is... What do you think?