diff --git a/src/p4est_wrap.c b/src/p4est_wrap.c index 0697fc830..ce7fc63e4 100644 --- a/src/p4est_wrap.c +++ b/src/p4est_wrap.c @@ -666,6 +666,7 @@ p4est_wrap_adapt (p4est_wrap_t * pp) pp->num_refine_flags); + checksum_entry = 0; if ((have_zlib = p4est_have_zlib())) { /* store p4est checksum on entry to compare with results after balancing */ global_num_entry = p4est->global_num_quadrants; @@ -822,9 +823,11 @@ p4est_wrap_partition (p4est_wrap_t * pp, int weight_exponent, p4est_ghost_destroy (pp->ghost); pp->match_aux = 0; - /* Remember the window onto global quadrant sequence before partition */ - pre_me = pp->p4est->global_first_quadrant[pp->p4est->mpirank]; - pre_next = pp->p4est->global_first_quadrant[pp->p4est->mpirank + 1]; + /* Remember the global first quadrants before partition */ + pp->old_global_first_quadrant = + P4EST_ALLOC (p4est_gloidx_t, pp->p4est->mpisize + 1); + memcpy (pp->old_global_first_quadrant, pp->p4est->global_first_quadrant, + sizeof (p4est_gloidx_t) * (pp->p4est->mpisize + 1)); /* Initialize output for the case that the partition does not change */ if (unchanged_first != NULL) { @@ -858,6 +861,8 @@ p4est_wrap_partition (p4est_wrap_t * pp, int weight_exponent, unchanged_old_first != NULL) { /* compute new windof of local quadrants */ + pre_me = pp->old_global_first_quadrant[pp->p4est->mpirank]; + pre_next = pp->old_global_first_quadrant[pp->p4est->mpirank + 1]; post_me = pp->p4est->global_first_quadrant[pp->p4est->mpirank]; post_next = pp->p4est->global_first_quadrant[pp->p4est->mpirank + 1]; @@ -874,6 +879,8 @@ p4est_wrap_partition (p4est_wrap_t * pp, int weight_exponent, pp->mesh = pp->mesh_aux; pp->ghost_aux = NULL; pp->mesh_aux = NULL; + P4EST_FREE (pp->old_global_first_quadrant); + pp->old_global_first_quadrant = NULL; } return changed; @@ -889,11 +896,14 @@ p4est_wrap_complete (p4est_wrap_t * pp) P4EST_ASSERT (pp->ghost_aux != NULL); P4EST_ASSERT (pp->mesh_aux != NULL); P4EST_ASSERT (pp->match_aux == 0); + P4EST_ASSERT (pp->old_global_first_quadrant != NULL); p4est_mesh_destroy (pp->mesh_aux); p4est_ghost_destroy (pp->ghost_aux); pp->ghost_aux = NULL; pp->mesh_aux = NULL; + P4EST_FREE (pp->old_global_first_quadrant); + pp->old_global_first_quadrant = NULL; } static p4est_wrap_leaf_t * diff --git a/src/p4est_wrap.h b/src/p4est_wrap.h index 9e4bd0f76..ec8c56806 100644 --- a/src/p4est_wrap.h +++ b/src/p4est_wrap.h @@ -106,6 +106,7 @@ typedef struct p4est_wrap int weight_exponent; uint8_t *flags, *temp_flags; p4est_locidx_t num_refine_flags, inside_counter, num_replaced; + p4est_gloidx_t *old_global_first_quadrant; /* for ghost and mesh use p4est_wrap_get_ghost, _mesh declared below */ p4est_ghost_t *ghost; diff --git a/src/p8est_wrap.h b/src/p8est_wrap.h index ae4ac5f2a..e6f5aeb65 100644 --- a/src/p8est_wrap.h +++ b/src/p8est_wrap.h @@ -106,6 +106,7 @@ typedef struct p8est_wrap int weight_exponent; uint8_t *flags, *temp_flags; p4est_locidx_t num_refine_flags, inside_counter, num_replaced; + p4est_gloidx_t *old_global_first_quadrant; /* for ghost and mesh use p8est_wrap_get_ghost, _mesh declared below */ p8est_ghost_t *ghost;