static void test_pertree (p4est_t * p4est, const p4est_gloidx_t * prev_pertree, p4est_gloidx_t * new_pertree) { const p4est_topidx_t num_trees = p4est->connectivity->num_trees; p4est_gloidx_t *pertree; /* test counting of quadrants in individual trees */ P4EST_ASSERT ((size_t) num_trees == p4est->trees->elem_count); if (new_pertree == NULL) { pertree = P4EST_ALLOC (p4est_gloidx_t, num_trees + 1); } else { pertree = new_pertree; } p4est_comm_count_pertree (p4est, pertree); SC_CHECK_ABORT (pertree[num_trees] == p4est->global_num_quadrants, "pertree check failed"); if (prev_pertree != NULL) { SC_CHECK_ABORT (!memcmp (pertree, prev_pertree, sizeof (p4est_gloidx_t) * (num_trees + 1)), "pertree now different"); } if (new_pertree == NULL) { P4EST_FREE (pertree); } }
static void test_deflate (p4est_t * p4est) { p4est_gloidx_t *pertree; p4est_t *p4est2; sc_array_t *qarr, *darr; pertree = P4EST_ALLOC (p4est_gloidx_t, p4est->connectivity->num_trees + 1); p4est_comm_count_pertree (p4est, pertree); darr = NULL; qarr = p4est_deflate_quadrants (p4est, p4est->data_size > 0 ? &darr : NULL); /* Data that describes the forest completely (a) shared data (identical on all processors): p4est->connectivity p4est->global_first_quadrant (does not need to be stored away) pertree (b) per-processor data (partition independent after allgatherv): qarr darr (if per-quadrant data size is greater 0 and it should be saved) */ /* Create a forest from this information and compare */ p4est2 = p4est_inflate (p4est->mpicomm, p4est->connectivity, p4est->global_first_quadrant, pertree, qarr, darr, p4est->user_pointer); SC_CHECK_ABORT (p4est_is_equal (p4est, p4est2, 1), "de/inflate"); p4est_destroy (p4est2); /* clean up allocated memory */ P4EST_FREE (pertree); sc_array_destroy (qarr); if (darr != NULL) { sc_array_destroy (darr); } }