Skip to content

Feature: Ancestor search #1714

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
wants to merge 14 commits into
base: main
Choose a base branch
from
Open

Feature: Ancestor search #1714

wants to merge 14 commits into from

Conversation

holke
Copy link
Collaborator

@holke holke commented Jun 23, 2025

Closes #1715

Describe your changes here:

Currently waiting for #1640 to merge.
Will add a description afterwards.

All these boxes must be checked by the AUTHOR before requesting review:

  • The PR is small enough to be reviewed easily. If not, consider splitting up the changes in multiple PRs.
  • The title starts with one of the following prefixes: Documentation:, Bugfix:, Feature:, Improvement: or Other:.
  • If the PR is related to an issue, make sure to link it.
  • The author made sure that, as a reviewer, he/she would check all boxes below.

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

  • The reviewer executed the new code features at least once and checked the results manually.
  • The code follows the t8code coding guidelines.
  • New source/header files are properly added to the CMake files.
  • The code is well documented. In particular, all function declarations, structs/classes and their members have a proper doxygen documentation.
  • All new algorithms and data structures are sufficiently optimal in terms of memory and runtime (If this should be merged, but there is still potential for optimization, create a new issue).

Tests

  • The code is covered in an existing or new test case using Google Test.
  • The code coverage of the project (reported in the CI) should not decrease. If coverage is decreased, make sure that this is reasonable and acceptable.
  • Valgrind doesn't find any bugs in the new code. This script can be used to check for errors; see also this wiki article.

If the Pull request introduces code that is not covered by the github action (for example coupling with a new library):

  • Should this use case be added to the github action?
  • If not, does the specific use case compile and all tests pass (check manually).

Scripts and Wiki

  • If a new directory with source files is added, it must be covered by the script/find_all_source_files.scp to check the indentation of these files.
  • If this PR introduces a new feature, it must be covered in an example or tutorial and a Wiki article.

License

  • The author added a BSD statement to doc/ (or already has one).

@holke holke marked this pull request as draft June 23, 2025 09:22
@spenke91 spenke91 marked this pull request as ready for review June 23, 2025 13:51
@spenke91 spenke91 requested a review from Davknapp June 23, 2025 13:52
Copy link

codecov bot commented Jun 23, 2025

Codecov Report

Attention: Patch coverage is 0% with 46 lines in your changes missing coverage. Please review.

Project coverage is 73.88%. Comparing base (9e6f427) to head (8f9b60e).
Report is 26 commits behind head on main.

Files with missing lines Patch % Lines
src/t8_forest/t8_forest_private.cxx 0.00% 46 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main    #1714      +/-   ##
==========================================
- Coverage   74.06%   73.88%   -0.18%     
==========================================
  Files          99       99              
  Lines       18616    18667      +51     
==========================================
+ Hits        13788    13793       +5     
- Misses       4828     4874      +46     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

Copy link
Collaborator

@Davknapp Davknapp left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

A first round of remarks! Thanks for this addition!

@@ -57,6 +57,14 @@ t8_forest_get_tree_leaf_element_array_mutable (const t8_forest_t forest, t8_loci
return (t8_element_array_t *) t8_forest_get_tree_leaf_element_array (forest, ltreeid);
}

/* TODO: does the search fail when element_level is smaller then levels in the array?
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Have you opened issues for these Todos? That way they do not get lost that easily.


/* In case we do not find an element that is greater than the given element_id, the binary search returns
* the end-iterator of the element array. */
if (elem_iter == t8_element_array_end (elements)) {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think we should be consistent here with the std and return the index of the last element if no such element exist.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

additional remark, but maybe not necessary to react. I would find it more logical to also use std::upper_bound in that case. I know with the right lambda they are equivalent, but it feels right.

*/
// TODO: Move this function to the scheme class.
static bool
t8_forest_element_is_ancestor (const t8_scheme *scheme, t8_eclass_t eclass, const t8_element_t *element_A,
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
t8_forest_element_is_ancestor (const t8_scheme *scheme, t8_eclass_t eclass, const t8_element_t *element_A,
t8_forest_element_is_ancestor (const t8_scheme *scheme, const t8_eclass_t eclass, const t8_element_t *element_A,

}
}

/** Query whether one element is an ancestor of the other.
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
/** Query whether one element is an ancestor of the other.
/** Query whether element A is an ancestor of the element B.

Otherwise it sounds like both possibilities are checked, but this is not the case, as far as I understand the code.

@Davknapp Davknapp assigned holke and unassigned Davknapp Jun 25, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Feature: Ancestor search
2 participants