Skip to content

Commit a6ed769

Browse files
committed
improve ancestor_id
1 parent 52e44fe commit a6ed769

File tree

1 file changed

+13
-2
lines changed

1 file changed

+13
-2
lines changed

src/t8_schemes/t8_standalone/t8_standalone_implementation.hxx

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -649,10 +649,21 @@ struct t8_standalone_scheme
649649

650650
const t8_standalone_element<TEclass> *el = (const t8_standalone_element<TEclass> *) elem;
651651
t8_standalone_element<TEclass> ancestor;
652+
const int length = element_get_len (level);
652653
T8_ASSERT (0 <= el->level && el->level <= T8_ELEMENT_MAXLEVEL[TEclass]);
653654

654-
element_get_ancestor (el, level, &ancestor);
655-
return element_get_child_id ((const t8_element_t *) &ancestor);
655+
int cube_id = 0;
656+
for (int idim = 0; idim < T8_ELEMENT_DIM[TEclass]; idim++) {
657+
cube_id |= (el->coords[idim] & length) ? (1 << idim) : 0;
658+
}
659+
int child_id;
660+
if constexpr (T8_ELEMENT_NUM_EQUATIONS[TEclass]) {
661+
u_int8_t type = element_compute_type_at_level (el, level);
662+
child_id = t8_element_type_cubeid_to_Iloc<TEclass>[type][cube_id];
663+
}else{
664+
child_id = cube_id;
665+
}
666+
return child_id;
656667
}
657668

658669
/** Query whether a given set of elements is a family or not.

0 commit comments

Comments
 (0)