DLR-AMR / t8code

Parallel algorithms and data structures for tree-based adaptive mesh refinement (AMR) with arbitrary element shapes.
https://dlr-amr.github.io/t8code/
GNU General Public License v2.0
148 stars 52 forks source link

Maximum level and linear index #498

Open cburstedde opened 1 year ago

cburstedde commented 1 year ago

The linear_id and set_morton functions are restricted by the range of the linear index type. In t8code there is the assumption that the maximum level of any element shall not exceed the linear index range.

However, most element operations are not restricted by the linear index. The p4est maximum level has thus been raised to 29 for those not requiring a linear index, even in 3D, which is also the maximum level reported to t8code: P8EST_QMAXLEVEL. The maximum level for set_morton and linear_id in 3D is P8EST_OLD_QMAXLEVEL, which will remain at 18. Thus, the nca test crashes when trying to create elements above the latter.

I had proposed a solution under #1 in cburstedde/t8code. This has never been merged.

Right now I've prepared a bunch of commits to integrate the latest p4est and libsc into t8code, which will put our increased maxlevel update into effect, but for the tests to pass something has to be done about the p4est maxlevel in t8code. For example, we have added 128 bit integer alternate versions to set_morton and linear_id in p4est that survive P8EST_QMAXLEVEL. There is a whole set of 128 bit operations in libsc's src/sc_uint128.h.

How would you like to proceed? For now the simplest would be to use P4EST_OLD_QMAXLEVEL throughout but that would be a bit of a wasted opportunity.

P. S. This issue may be of interest to @sloede for wrapping p4est in julia.

cburstedde commented 1 year ago

I've added a minimal non-intrusive solution to #499. It may be temporary or live forever. :)

holke commented 1 year ago

Thanks, Carsten. Does the solution from #499 also cover the original PR? Sorry, that we did not integrate it, i think it got lost in the duplicate repository confusion.

Having the maxlevel beyond the linear id is a great feature which we should integrate for all Morton type elements in t8code. However, we should carefully investigate beforehand that we do not break anything with it. But since it works in p4est there should not be many pitfalls to it.

cburstedde commented 1 year ago

Thanks, Carsten. Does the solution from #499 also cover the original PR? Sorry, that we did not integrate it, i think it got lost in the duplicate repository confusion.

No worries, I should have split it into multiple PRs, and it was the wrong repo.

Having the maxlevel beyond the linear id is a great feature which we should integrate for all Morton type elements in t8code. However, we should carefully investigate beforehand that we do not break anything with it. But since it works in p4est there should not be many pitfalls to it.

Cool, you can just look at the old proposed diff and come up with what works best for t8code.