cburstedde / p4est

The "p4est" forest-of-octrees library
www.p4est.org/
GNU General Public License v2.0
253 stars 114 forks source link

Newly adapted quadrants in wrap #310

Closed hannesbrandt closed 2 months ago

hannesbrandt commented 3 months ago

This PR adds two arrays newly_refined and newly_coarsened to the p4est_wrap_t. The arrays store the local quadrant indices of quadrants that were refined or coarsened during the most recent call to p4est_wrap_adapt. For refinement, only the index of the quadrant with child id 0 is stored. The arrays are not updated during other function calls like p4est_wrap_partition. So, they always index into the local quadrants of the p4est as it was right after adaptation.

The arrays are only initalized and set, if the new wrap parameter store_adapted is set to true. Furthermore, we assert that the wrap's p4est is balanced before the adaptation, which ensures a single level of refinement.

cburstedde commented 3 months ago

Cool; would we want to delete the arrays once they no longer match the p4est (e. g. due to partition)?

hannesbrandt commented 3 months ago

The arrays may still be of value even after partitioning, e.g. when organizing communication of quadrant-related user data after a call of partition. This is for example planned for our upcoming partitioning strategies in forestclaw.

hannesbrandt commented 2 months ago

I have changed the allocation of the arrays. newly_refined and newly_coarsened are now allocated in wrap_adapt, instead of in wrap_new. As a consequence, p4est_wrap_set_store_adapted would now merely change the value of the corresponding wrap parameter, so I removed it. We could remove p4est_wrap_set_partitioning as well, since it just changes the partition_for_coarsening parameter.

cburstedde commented 2 months ago

I have changed the allocation of the arrays. newly_refined and newly_coarsened are now allocated in wrap_adapt, instead of in wrap_new. As a consequence, p4est_wrap_set_store_adapted would now merely change the value of the corresponding wrap parameter, so I removed it. We could remove p4est_wrap_set_partitioning as well, since it just changes the partition_for_coarsening parameter.

Sounds good! Please make sure to delete their translations from p4est_to_p8est.h.

cburstedde commented 2 months ago

Looks good; thanks!