Skip to content

Commit

Permalink
p4est_search: fix to pass true quadrant
Browse files Browse the repository at this point in the history
In the relatively new function p4est_search_reorder, we accept
a parameter to switch level skipping on or off as an optimization.
If on and only a single leaf is contained in a search quadrant,
we directly skip down to the leaf as next quadrant to consider.

We fix the bug that the quadrant was not real when skipping was off.
  • Loading branch information
cburstedde committed Aug 30, 2023
1 parent eb24772 commit 29768c1
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion src/p4est_search.c
Original file line number Diff line number Diff line change
Expand Up @@ -852,7 +852,7 @@ p4est_reorder_recursion (const p4est_local_recursion_t * rec,
is_leaf = 1;
is_same = p4est_quadrant_is_equal (quadrant, q);
if (rec->skip && !is_same) {
quadrant = q;
/* we are asked to optimize by skipping intermediate levels */
is_same = 1;
}
if (is_same) {
Expand All @@ -866,6 +866,9 @@ p4est_reorder_recursion (const p4est_local_recursion_t * rec,
P4EST_ASSERT (offset >= 0 &&
(size_t) offset < tree->quadrants.elem_count);
local_num = tree->quadrants_offset + offset;

/* make sure we pass the leaf itself to subsequent callbacks */
quadrant = q;
}
}
P4EST_ASSERT (!is_same || is_leaf);
Expand Down

0 comments on commit 29768c1

Please sign in to comment.