int main (int argc, char **argv) { MPI_Comm mpicomm; int mpiret; int N; mpiret = MPI_Init (&argc, &argv); SC_CHECK_MPI (mpiret); mpicomm = MPI_COMM_WORLD; sc_init (mpicomm, 1, 1, NULL, SC_LP_DEFAULT); p4est_init (NULL, SC_LP_DEFAULT); N = 43; test_identity (N); test_shell (N); test_sphere (N); /* clean up and exit */ sc_finalize (); mpiret = MPI_Finalize (); SC_CHECK_MPI (mpiret); return 0; }
int main (int argc, char **argv) { sc_MPI_Comm mpicomm; int mpiret; int size, rank; mpiret = sc_MPI_Init (&argc, &argv); SC_CHECK_MPI (mpiret); mpicomm = sc_MPI_COMM_WORLD; mpiret = sc_MPI_Comm_size (mpicomm, &size); SC_CHECK_MPI (mpiret); mpiret = sc_MPI_Comm_rank (mpicomm, &rank); SC_CHECK_MPI (mpiret); sc_init (mpicomm, 1, 1, NULL, SC_LP_DEFAULT); p4est_init (NULL, SC_LP_DEFAULT); (void) check_backward_compatibility (); check_int_types (); #ifndef P4_TO_P8 check_all (mpicomm, p4est_connectivity_new_unitsquare (), "test_unitsquare", 0xef45243bU, 0xbc5d0907U); check_all (mpicomm, p4est_connectivity_new_rotwrap (), "test_rotwrap2", 0x266d2739U, 0x29a31248U); check_all (mpicomm, p4est_connectivity_new_corner (), "test_corner", 0x9dad92ccU, 0x937b27afU); check_all (mpicomm, p4est_connectivity_new_moebius (), "test_moebius", 0xbbc10f7fU, 0x09b6319eU); check_all (mpicomm, p4est_connectivity_new_star (), "test_star", 0xfb28233fU, 0x8e8a32b3); #else check_all (mpicomm, p8est_connectivity_new_unitcube (), "test_unitcube", 0x2574801fU, 0x312559a7U); check_all (mpicomm, p8est_connectivity_new_periodic (), "test_periodic3", 0xdc7e8a93U, 0x0787ca2dU); check_all (mpicomm, p8est_connectivity_new_rotwrap (), "test_rotwrap", 0xa675888dU, 0x626cbe90U); check_all (mpicomm, p8est_connectivity_new_twocubes (), "test_twocubes", 0x7188978aU, 0x4124bcabU); check_all (mpicomm, p8est_connectivity_new_twowrap (), "test_twowrap", 0x8e3f994cU, 0x9dd49e94); check_all (mpicomm, p8est_connectivity_new_rotcubes (), "test_rotcubes", 0xc0e1b235U, 0x974af07a); check_all (mpicomm, p8est_connectivity_new_shell (), "test_shell", 0x558723a2U, 0x4dedf35eU); check_all (mpicomm, p8est_connectivity_new_brick (2, 3, 4, 0, 0, 1), "test_brick", 0x82174e14U, 0x211da6c5); #endif /* clean up and exit */ sc_finalize (); mpiret = sc_MPI_Finalize (); SC_CHECK_MPI (mpiret); return 0; }
int main (int argc, char **argv) { int mpiret; p4est_connectivity_t *conn_in, *conn_out; p4est_t *p4est; mpiret = sc_MPI_Init (&argc, &argv); SC_CHECK_MPI (mpiret); sc_init (sc_MPI_COMM_WORLD, 1, 1, NULL, SC_LP_DEFAULT); p4est_init (NULL, SC_LP_DEFAULT); #ifndef P4_TO_P8 conn_in = p4est_connectivity_new_cubed (); #else conn_in = p8est_connectivity_new_rotcubes (); #endif conn_out = p4est_connectivity_refine (conn_in, 5); p4est_connectivity_destroy (conn_in); p4est = p4est_new (sc_MPI_COMM_WORLD, conn_out, 0, NULL, NULL); p4est_vtk_write_file (p4est, NULL, P4EST_STRING "_test_connrefine"); p4est_destroy (p4est); p4est_connectivity_destroy (conn_out); sc_finalize (); mpiret = sc_MPI_Finalize (); SC_CHECK_MPI (mpiret); return 0; }
int main (int argc, char **argv) { int mpiret; p4est_connectivity_t *conn1, *conn2; mpiret = sc_MPI_Init (&argc, &argv); SC_CHECK_MPI (mpiret); sc_init (sc_MPI_COMM_WORLD, 1, 1, NULL, SC_LP_DEFAULT); p4est_init (NULL, SC_LP_DEFAULT); #ifndef P4_TO_P8 conn1 = p4est_connectivity_new_unitsquare (); conn2 = p4est_connectivity_new_rotwrap (); #else conn1 = p8est_connectivity_new_unitcube (); conn2 = p8est_connectivity_new_rotwrap (); #endif p4est_connectivity_join_faces (conn1, 0, 0, 0, 1, 0); p4est_connectivity_join_faces (conn1, 0, 0, P4EST_FACES - 2, P4EST_FACES - 1, 1); SC_CHECK_ABORT (p4est_connectivity_is_equivalent (conn1, conn2), "rotwrap not reproduced"); p4est_connectivity_destroy (conn1); p4est_connectivity_destroy (conn2); sc_finalize (); mpiret = sc_MPI_Finalize (); SC_CHECK_MPI (mpiret); return 0; }
int main (int argc, char **argv) { int mpiret; mpi_context_t mpi_context, *mpi = &mpi_context; p4est_t *p4est; p4est_connectivity_t *connectivity; p4est_ghost_t *ghost; /* initialize MPI and p4est internals */ mpiret = MPI_Init (&argc, &argv); SC_CHECK_MPI (mpiret); mpi->mpicomm = MPI_COMM_WORLD; /* your favourite comm here */ mpiret = MPI_Comm_size (mpi->mpicomm, &mpi->mpisize); SC_CHECK_MPI (mpiret); mpiret = MPI_Comm_rank (mpi->mpicomm, &mpi->mpirank); SC_CHECK_MPI (mpiret); /* this should alwaps be MPI_COMM_WORLD (no effect on p4est) */ sc_init (MPI_COMM_WORLD, 0, 0, NULL, SC_LP_DEFAULT); p4est_init (NULL, SC_LP_DEFAULT); /* create 2D connectivity and forest structures */ connectivity = p4est_connectivity_new_unitsquare (); p4est = p4est_new_ext (mpi->mpicomm, connectivity, 0, 0, 1, 0, NULL, NULL); /* refine and partition */ p4est_refine (p4est, 1, refine_fn, NULL); p4est_partition (p4est, NULL); /* write vtk output */ p4est_vtk_write_file (p4est, NULL, "p4est_ptest2"); /* create and destroy ghost layer */ ghost = p4est_ghost_new (p4est, P4EST_CONNECT_FULL); p4est_ghost_destroy (ghost); /* destroy the p4est and its connectivity structure */ p4est_destroy (p4est); p4est_connectivity_destroy (connectivity); /* clean up and exit */ sc_finalize (); mpiret = MPI_Finalize (); SC_CHECK_MPI (mpiret); return 0; }
int main (int argc, char *argv[]) { int mpiret; /* initialize MPI and p4est internals */ mpiret = sc_MPI_Init (&argc, &argv); SC_CHECK_MPI (mpiret); sc_init (sc_MPI_COMM_WORLD, 1, 1, NULL, SC_LP_DEFAULT); p4est_init (NULL, SC_LP_DEFAULT); #ifndef P4_TO_P8 test_reduce (p4est_connectivity_new_unitsquare (), "unitsquare"); test_reduce (p4est_connectivity_new_periodic (), "periodic"); test_reduce (p4est_connectivity_new_rotwrap (), "rotwrap"); test_reduce (p4est_connectivity_new_corner (), "corner"); test_reduce (p4est_connectivity_new_pillow (), "pillow"); test_reduce (p4est_connectivity_new_moebius (), "moebius"); test_reduce (p4est_connectivity_new_star (), "star"); test_reduce (p4est_connectivity_new_cubed (), "cubed"); test_reduce (p4est_connectivity_new_disk (), "disk"); test_reduce (p4est_connectivity_new_brick (3, 2, 0, 0), "brick00"); test_reduce (p4est_connectivity_new_brick (3, 2, 0, 1), "brick01"); test_reduce (p4est_connectivity_new_brick (3, 2, 1, 0), "brick10"); test_reduce (p4est_connectivity_new_brick (3, 2, 1, 1), "brick11"); #else test_reduce (p8est_connectivity_new_unitcube (), "unitcube"); test_reduce (p8est_connectivity_new_periodic (), "periodic"); test_reduce (p8est_connectivity_new_rotwrap (), "rotwrap"); test_reduce (p8est_connectivity_new_twocubes (), "twocubes"); test_reduce (p8est_connectivity_new_twowrap (), "twowrap"); test_reduce (p8est_connectivity_new_rotcubes (), "rotcubes"); test_reduce (p8est_connectivity_new_brick (4, 3, 2, 0, 0, 0), "brick000"); test_reduce (p8est_connectivity_new_brick (4, 3, 2, 0, 0, 1), "brick001"); test_reduce (p8est_connectivity_new_brick (4, 3, 2, 0, 1, 0), "brick010"); test_reduce (p8est_connectivity_new_brick (4, 3, 2, 0, 1, 1), "brick011"); test_reduce (p8est_connectivity_new_brick (4, 3, 2, 1, 0, 0), "brick100"); test_reduce (p8est_connectivity_new_brick (4, 3, 2, 1, 0, 1), "brick101"); test_reduce (p8est_connectivity_new_brick (4, 3, 2, 1, 1, 1), "brick111"); #endif /* clean up and exit */ sc_finalize (); mpiret = sc_MPI_Finalize (); SC_CHECK_MPI (mpiret); return 0; }
int main (int argc, char **argv) { sc_MPI_Comm mpicomm; int mpiret, retval; int level; const char *filename; p4est_connectivity_t *conn; sc_options_t *opt; mpiret = sc_MPI_Init (&argc, &argv); SC_CHECK_MPI (mpiret); mpicomm = sc_MPI_COMM_WORLD; sc_init (sc_MPI_COMM_WORLD, 1, 1, NULL, SC_LP_DEFAULT); p4est_init (NULL, SC_LP_DEFAULT); opt = sc_options_new (argv[0]); sc_options_add_int (opt, 'l', "level", &level, 0, "Upfront refinement level"); retval = sc_options_parse (p4est_package_id, SC_LP_ERROR, opt, argc, argv); if (retval == -1 || retval + 1 != argc) { sc_options_print_usage (p4est_package_id, SC_LP_PRODUCTION, opt, NULL); sc_abort_collective ("Usage error"); } filename = argv[retval]; P4EST_LDEBUGF ("Loading %s\n", filename); conn = p4est_connectivity_load (filename, NULL); run_load (mpicomm, conn, level); p4est_connectivity_destroy (conn); sc_options_destroy (opt); sc_finalize (); mpiret = sc_MPI_Finalize (); SC_CHECK_MPI (mpiret); return 0; }
int main (int argc, char **argv) { int mpiret; mpiret = sc_MPI_Init (&argc, &argv); SC_CHECK_MPI (mpiret); sc_init (sc_MPI_COMM_WORLD, 1, 1, NULL, SC_LP_DEFAULT); p4est_init (NULL, SC_LP_DEFAULT); #ifndef P4_TO_P8 test_complete (p4est_connectivity_new_unitsquare (), "unitsquare", 1); test_complete (p4est_connectivity_new_periodic (), "2D periodic", 0); test_complete (p4est_connectivity_new_rotwrap (), "rotwrap", 0); test_complete (p4est_connectivity_new_corner (), "corner", 1); test_complete (p4est_connectivity_new_moebius (), "moebius", 1); test_complete (p4est_connectivity_new_star (), "star", 1); test_complete (p4est_connectivity_new_brick (3, 18, 0, 1), "2D periodic brick", 0); test_complete (p4est_connectivity_new_brick (3, 18, 0, 0), "2D brick", 1); #else test_complete (p8est_connectivity_new_unitcube (), "unitcube", 1); test_complete (p8est_connectivity_new_periodic (), "3D periodic", 0); test_complete (p8est_connectivity_new_rotwrap (), "rotwrap", 0); test_complete (p8est_connectivity_new_twowrap (), "twowrap", 1); test_complete (p8est_connectivity_new_twocubes (), "twocubes", 1); test_complete (p8est_connectivity_new_rotcubes (), "rotcubes", 1); test_complete (p8est_connectivity_new_brick (3, 2, 8, 1, 0, 1), "3D periodic brick", 0); test_complete (p8est_connectivity_new_brick (3, 2, 8, 0, 0, 0), "3D brick", 1); #endif sc_finalize (); mpiret = sc_MPI_Finalize (); SC_CHECK_MPI (mpiret); return 0; }
int main (int argc, char **argv) { MPI_Comm mpicomm; int mpiret, retval; int rlevel, l; int periodic; sc_options_t *opt; mpiret = MPI_Init (&argc, &argv); SC_CHECK_MPI (mpiret); mpicomm = MPI_COMM_WORLD; sc_init (MPI_COMM_WORLD, 1, 1, NULL, SC_LP_DEFAULT); p4est_init (NULL, SC_LP_DEFAULT); opt = sc_options_new (argv[0]); sc_options_add_int (opt, 'l', "level", &rlevel, 0, "Upfront refinement level"); sc_options_add_switch (opt, 'p', "periodic", &periodic, "Periodic connectivity"); retval = sc_options_parse (p4est_package_id, SC_LP_ERROR, opt, argc, argv); if (retval == -1 || retval < argc) { sc_options_print_usage (p4est_package_id, SC_LP_PRODUCTION, opt, NULL); sc_abort_collective ("Usage error"); } for (l = 0; l <= rlevel; ++l) { run_bricks (mpicomm, periodic, l, rlevel); } sc_options_destroy (opt); sc_finalize (); mpiret = MPI_Finalize (); SC_CHECK_MPI (mpiret); return 0; }
int main (int argc, char **argv) { int mpirank, mpisize; int mpiret; sc_MPI_Comm mpicomm; p4est_t *p4est; p4est_connectivity_t *connectivity; mpiret = sc_MPI_Init (&argc, &argv); SC_CHECK_MPI (mpiret); mpicomm = sc_MPI_COMM_WORLD; mpiret = sc_MPI_Comm_size (mpicomm, &mpisize); SC_CHECK_MPI (mpiret); mpiret = sc_MPI_Comm_rank (mpicomm, &mpirank); SC_CHECK_MPI (mpiret); sc_init (mpicomm, 1, 1, NULL, SC_LP_DEFAULT); p4est_init (NULL, SC_LP_DEFAULT); /* create connectivity and forest structures */ #ifdef P4_TO_P8 connectivity = p8est_connectivity_new_rotcubes (); #else connectivity = p4est_connectivity_new_star (); #endif p4est = p4est_new_ext (mpicomm, connectivity, 15, 0, 0, 1, NULL, NULL); p4est_refine_ext (p4est, 1, P4EST_QMAXLEVEL, refine_fn, NULL, replace_fn); p4est_coarsen_ext (p4est, 1, 0, coarsen_fn, NULL, replace_fn); p4est_balance_ext (p4est, P4EST_CONNECT_FULL, NULL, replace_fn); p4est_destroy (p4est); p4est_connectivity_destroy (connectivity); sc_finalize (); mpiret = sc_MPI_Finalize (); SC_CHECK_MPI (mpiret); return 0; }
/* * Purpose of this program is to verify that * p8est_find_edge_transform and p8est_find_corner_transform * work as expected for several periodic connectivities. */ int main (int argc, char **argv) { p8est_connectivity_t *conn; sc_init (sc_MPI_COMM_NULL, 1, 1, NULL, SC_LP_DEFAULT); p4est_init (NULL, SC_LP_DEFAULT); conn = p8est_connectivity_new_periodic (); test_periodic (conn); p8est_connectivity_destroy (conn); conn = p8est_connectivity_new_rotwrap (); test_rotwrap (conn); p8est_connectivity_destroy (conn); test_weird (); sc_finalize (); return 0; }
int main(int argc, char *argv[]) { int mpiret; sc_MPI_Comm mpicomm; int proc_size; int nf; /* MPI init */ mpiret = sc_MPI_Init(&argc, &argv); SC_CHECK_MPI(mpiret); mpicomm = sc_MPI_COMM_WORLD; /* sc_init (mpicomm, 1, 1, NULL, SC_LP_ESSENTIAL); */ mpiret = MPI_Comm_size(mpicomm, &proc_size); SC_CHECK_MPI (mpiret); /* pXest init */ sc_init (mpicomm, 1, 1, NULL, SC_LP_ALWAYS); p4est_init(NULL, SC_LP_PRODUCTION); int min_quadrants = 0; int min_level = 0; int fill_uniform = 1; p4est_connectivity_t *conn = test_problem_build_conn(); p4est_geometry_t* p4est_geom = test_problem_build_geom(conn); p4est_t* p4est = test_problem_build_p4est( mpicomm, conn, min_quadrants, min_level, fill_uniform ); dgmath_jit_dbase_t* dgmath_jit_dbase = dgmath_jit_dbase_init(); global_p4est_pointer = p4est; global_dgmath_jit_dbase = dgmath_jit_dbase; global_geom_pointer = p4est_geom; /* run tests */ Suite *s1 = suite_create("Test the new style of hp-amr"); SRunner *sr = srunner_create(s1); TCase *tc1 = tcase_create("Test a step of hp-amr"); tcase_add_test(tc1, test_hp_amr_step); suite_add_tcase(s1,tc1); tcase_set_timeout(tc1, 100); srunner_run_all(sr, CK_ENV); nf = srunner_ntests_failed(sr); dgmath_jit_dbase_destroy(dgmath_jit_dbase); p4est_destroy(p4est); p4est_connectivity_destroy(conn); if(p4est_geom != NULL) p4est_geometry_destroy (p4est_geom); sc_finalize (); mpiret = sc_MPI_Finalize (); SC_CHECK_MPI(mpiret); srunner_free(sr); return nf == 0 ? 0 : 1; }
int main (int argc, char **argv) { int mpiret; sc_MPI_Comm mpicomm; p4est_t *p4est; p4est_connectivity_t *connectivity; p4est_locidx_t save_local_count; p4est_geometry_t *geom; mpiret = sc_MPI_Init (&argc, &argv); SC_CHECK_MPI (mpiret); mpicomm = sc_MPI_COMM_WORLD; sc_init (mpicomm, 1, 1, NULL, SC_LP_DEFAULT); p4est_init (NULL, SC_LP_DEFAULT); /* create connectivity and forest structures */ #ifdef P4_TO_P8 connectivity = p8est_connectivity_new_rotcubes (); geom = NULL; #else connectivity = p4est_connectivity_new_star (); geom = p4est_geometry_new_connectivity (connectivity); #endif p4est = p4est_new_ext (mpicomm, connectivity, 15, 0, 0, 0, NULL, NULL); save_local_count = p4est->local_num_quadrants; refine_callback_count = 0; p4est_refine_ext (p4est, 0, 2, test_refine, NULL, NULL); SC_CHECK_ABORT (refine_callback_count == save_local_count, "Refine count"); refine_callback_count = 0; p4est_refine (p4est, 1, test_refine, NULL); p4est_balance (p4est, P4EST_CONNECT_FULL, NULL); coarsen_all = 1; p4est_coarsen_both (p4est, 0, test_coarsen, NULL); coarsen_all = 0; p4est_coarsen_both (p4est, 1, test_coarsen, NULL); p4est_balance (p4est, P4EST_CONNECT_FULL, NULL); coarsen_all = 1; p4est_coarsen_both (p4est, 1, test_coarsen, NULL); p4est_vtk_write_file (p4est, geom, P4EST_STRING "_endcoarsen"); if (p4est->mpisize == 1) { SC_CHECK_ABORT (p4est->global_num_quadrants == (p4est_gloidx_t) connectivity->num_trees, "Coarsen all"); } p4est_destroy (p4est); if (geom != NULL) { p4est_geometry_destroy (geom); } p4est_connectivity_destroy (connectivity); sc_finalize (); mpiret = sc_MPI_Finalize (); SC_CHECK_MPI (mpiret); return 0; }
/** The main step 3 program. * * Setup of the example parameters; create the forest, with the state variable * stored in the quadrant data; refine, balance, and partition the forest; * timestep; clean up, and exit. */ int main (int argc, char **argv) { int mpiret; int recursive, partforcoarsen; sc_MPI_Comm mpicomm; p4est_t *p4est; p4est_connectivity_t *conn; step3_ctx_t ctx; /* Initialize MPI; see sc_mpi.h. * If configure --enable-mpi is given these are true MPI calls. * Else these are dummy functions that simulate a single-processor run. */ mpiret = sc_MPI_Init (&argc, &argv); SC_CHECK_MPI (mpiret); mpicomm = sc_MPI_COMM_WORLD; /* These functions are optional. If called they store the MPI rank as a * static variable so subsequent global p4est log messages are only issued * from processor zero. Here we turn off most of the logging; see sc.h. */ sc_init (mpicomm, 1, 1, NULL, SC_LP_ESSENTIAL); p4est_init (NULL, SC_LP_PRODUCTION); P4EST_GLOBAL_PRODUCTIONF ("This is the p4est %dD demo example/steps/%s_step3\n", P4EST_DIM, P4EST_STRING); ctx.bump_width = 0.1; ctx.max_err = 2.e-2; ctx.center[0] = 0.5; ctx.center[1] = 0.5; #ifdef P4_TO_P8 ctx.center[2] = 0.5; #endif #ifndef P4_TO_P8 /* randomly chosen advection direction */ ctx.v[0] = -0.445868402501118; ctx.v[1] = -0.895098523991131; #else ctx.v[0] = 0.485191768970225; ctx.v[1] = -0.427996381877778; ctx.v[2] = 0.762501176669961; #endif ctx.refine_period = 2; ctx.repartition_period = 4; ctx.write_period = 8; /* Create a forest that consists of just one periodic quadtree/octree. */ #ifndef P4_TO_P8 conn = p4est_connectivity_new_periodic (); #else conn = p8est_connectivity_new_periodic (); #endif /* *INDENT-OFF* */ p4est = p4est_new_ext (mpicomm, /* communicator */ conn, /* connectivity */ 0, /* minimum quadrants per MPI process */ 4, /* minimum level of refinement */ 1, /* fill uniform */ sizeof (step3_data_t), /* data size */ step3_init_initial_condition, /* initializes data */ (void *) (&ctx)); /* context */ /* *INDENT-ON* */ /* refine and coarsen based on an interpolation error estimate */ recursive = 1; p4est_refine (p4est, recursive, step3_refine_err_estimate, step3_init_initial_condition); p4est_coarsen (p4est, recursive, step3_coarsen_initial_condition, step3_init_initial_condition); /* Partition: The quadrants are redistributed for equal element count. The * partition can optionally be modified such that a family of octants, which * are possibly ready for coarsening, are never split between processors. */ partforcoarsen = 1; /* If we call the 2:1 balance we ensure that neighbors do not differ in size * by more than a factor of 2. This can optionally include diagonal * neighbors across edges or corners as well; see p4est.h. */ p4est_balance (p4est, P4EST_CONNECT_FACE, step3_init_initial_condition); p4est_partition (p4est, partforcoarsen, NULL); /* time step */ step3_timestep (p4est, 0.1); /* Destroy the p4est and the connectivity structure. */ p4est_destroy (p4est); p4est_connectivity_destroy (conn); /* Verify that allocations internal to p4est and sc do not leak memory. * This should be called if sc_init () has been called earlier. */ sc_finalize (); /* This is standard MPI programs. Without --enable-mpi, this is a dummy. */ mpiret = sc_MPI_Finalize (); SC_CHECK_MPI (mpiret); return 0; }
int main (int argc, char **argv) { sc_MPI_Comm mpicomm; int mpiret; int size, rank; unsigned crcF, crcC; p4est_connectivity_t *connectivity; p4est_t *p4est; p4est_t *p4estF, *p4estC; #ifdef P4_TO_P8 unsigned crcE; p4est_t *p4estE; #endif /* initialize */ mpiret = sc_MPI_Init (&argc, &argv); SC_CHECK_MPI (mpiret); mpicomm = sc_MPI_COMM_WORLD; mpiret = sc_MPI_Comm_size (mpicomm, &size); SC_CHECK_MPI (mpiret); mpiret = sc_MPI_Comm_rank (mpicomm, &rank); SC_CHECK_MPI (mpiret); sc_init (mpicomm, 1, 1, NULL, SC_LP_DEFAULT); p4est_init (NULL, SC_LP_DEFAULT); /* create forest and refine */ #ifndef P4_TO_P8 connectivity = p4est_connectivity_new_star (); #else connectivity = p8est_connectivity_new_rotcubes (); #endif p4est = p4est_new_ext (mpicomm, connectivity, 0, 0, 0, 0, NULL, NULL); p4est_refine (p4est, 1, refine_fn, NULL); /* test face balance */ p4estF = p4est_copy (p4est, 0); #ifndef P4_TO_P8 p4est_balance (p4estF, P4EST_CONNECT_FACE, NULL); #else p4est_balance (p4estF, P8EST_CONNECT_FACE, NULL); #endif crcF = p4est_checksum (p4estF); P4EST_GLOBAL_INFOF ("Face balance with %lld quadrants and crc 0x%08x\n", (long long) p4estF->global_num_quadrants, crcF); #ifdef P4_TO_P8 /* test edge balance */ p4estE = p4est_copy (p4est, 1); p4est_balance (p4estF, P8EST_CONNECT_EDGE, NULL); p4est_balance (p4estE, P8EST_CONNECT_EDGE, NULL); crcE = p4est_checksum (p4estE); SC_CHECK_ABORT (crcE == p4est_checksum (p4estF), "mismatch A"); P4EST_GLOBAL_INFOF ("Edge balance with %lld quadrants and crc 0x%08x\n", (long long) p4estE->global_num_quadrants, crcE); #endif /* test corner balance */ p4estC = p4est_copy (p4est, 1); #ifndef P4_TO_P8 p4est_balance (p4estF, P4EST_CONNECT_CORNER, NULL); p4est_balance (p4estC, P4EST_CONNECT_CORNER, NULL); #else p4est_balance (p4estF, P8EST_CONNECT_CORNER, NULL); p4est_balance (p4estC, P8EST_CONNECT_CORNER, NULL); #endif crcC = p4est_checksum (p4estC); SC_CHECK_ABORT (crcC == p4est_checksum (p4estF), "mismatch B"); P4EST_GLOBAL_INFOF ("Corner balance with %lld quadrants and crc 0x%08x\n", (long long) p4estC->global_num_quadrants, crcC); /* destroy forests and connectivity */ p4est_destroy (p4est); p4est_destroy (p4estF); #ifdef P4_TO_P8 p4est_destroy (p4estE); #endif p4est_destroy (p4estC); p4est_connectivity_destroy (connectivity); /* clean up and exit */ sc_finalize (); mpiret = sc_MPI_Finalize (); SC_CHECK_MPI (mpiret); return 0; }
int main(int argc, char *argv[]) { int mpiret; sc_MPI_Comm mpicomm; int proc_size; p4est_connectivity_t *conn; p4est_geometry_t *geom; p4est_t* p4est; int seed = time(NULL); srand(seed); /* MPI init */ mpiret = sc_MPI_Init(&argc, &argv); SC_CHECK_MPI(mpiret); mpicomm = sc_MPI_COMM_WORLD; sc_init (mpicomm, 1, 1, NULL, SC_LP_ESSENTIAL); mpiret = MPI_Comm_size(mpicomm, &proc_size); SC_CHECK_MPI (mpiret); /* pXest init */ p4est_init(NULL, SC_LP_PRODUCTION); conn = p4est_connectivity_new_disk(); /* geom = p4est_geometry_new_connectivity(conn); */ geom = p4est_geometry_new_disk(conn,1.,2.); p4est = p4est_new_ext (mpicomm, conn, -1, 0, 1, sizeof(curved_element_data_t), NULL, NULL); int world_rank,world_size; sc_MPI_Comm_rank(sc_MPI_COMM_WORLD, &world_rank); sc_MPI_Comm_size(sc_MPI_COMM_WORLD, &world_size); /* start just-in-time dg-math */ dgmath_jit_dbase_t* dgmath_jit_dbase = dgmath_jit_dbase_init(); geometric_factors_t* geometric_factors = geometric_factors_init(p4est); curved_element_data_init(p4est, geometric_factors, dgmath_jit_dbase, geom, 4); /* int local_nodes = curved_element_data_get_local_nodes(p4est); */ /* double* u = P4EST_ALLOC(double, local_nodes); */ /* for (int i = 0; i < local_nodes; i++){ */ /* /\* u = x *\/ */ /* u[i] = geometric_factors->xyz[i]; */ /* } */ int num_of_refinements = 2; /* p4est_vtk_write_all */ /* (p4est, */ /* geom, */ /* 0.99, */ /* 1, */ /* 1, */ /* 1, */ /* 0, */ /* 0, */ /* 0, */ /* "disk0" */ /* ); */ for (int i = 0; i < num_of_refinements; i++){ p4est_refine_ext (p4est, 0, -1, random_h_refine, NULL, refine_uniform_replace_callback); p4est_balance_ext(p4est, P4EST_CONNECT_FACE, NULL, refine_uniform_replace_callback); /* p4est_vtk_write_all */ /* (p4est, */ /* geom, */ /* 0.99, */ /* 1, */ /* 1, */ /* 1, */ /* 0, */ /* 0, */ /* 0, */ /* "disk" */ /* ); */ } curved_element_data_init(p4est, geometric_factors, dgmath_jit_dbase, geom, -1); int local_nodes = curved_element_data_get_local_nodes(p4est); double* u = P4EST_ALLOC(double, local_nodes); for (int i = 0; i < local_nodes; i++){ /* u = x */ u[i] = geometric_factors->xyz[i]; } /* curved_element_data_init(p4est, geometric_factors, dgmath_jit_dbase, geom, -1); */ /* store vector */ curved_element_data_copy_from_vec_to_storage ( p4est, u ); test_curved_data_t test_curved_data; test_curved_data.mortar_err = 0.; test_curved_data.hanging_proj_err = 0.; test_curved_data.full_proj_err = 0.; test_curved_data.print_data = 1; test_curved_data.no_reorient = 0; test_curved_data.geom = geom; p4est_ghost_t* ghost = p4est_ghost_new (p4est, P4EST_CONNECT_FACE); /* create space for storing the ghost data */ curved_element_data_t* ghost_data = P4EST_ALLOC (curved_element_data_t, ghost->ghosts.elem_count); p4est_ghost_exchange_data (p4est, ghost, ghost_data); curved_compute_flux_user_data_t curved_compute_flux_user_data; curved_compute_flux_user_data.dgmath_jit_dbase = dgmath_jit_dbase; curved_flux_fcn_ptrs_t flux_fcns = (test_curved_data_fetch_fcns(&test_curved_data)); curved_compute_flux_user_data.flux_fcn_ptrs = &flux_fcns; p4est->user_pointer = &curved_compute_flux_user_data; p4est_iterate (p4est, ghost, (void *) ghost_data, NULL, curved_compute_flux_on_local_elements, #if (P4EST_DIM)==3 NULL, #endif NULL); test_curved_data.mortar_err = 0.; if (world_rank == 0) printf("mortar_err = %.20f\n", test_curved_data.mortar_err ); p4est_ghost_destroy (ghost); P4EST_FREE (ghost_data); ghost = NULL; ghost_data = NULL; /* curved_hp_amr(p4est, */ /* &u, */ /* test_nonconform_random_hp, */ /* NULL, */ /* NULL, */ /* NULL, */ /* dgmath_jit_dbase */ /* ); */ /* curved_element_data_init(p4est, geometric_factors, dgmath_jit_dbase, geom, -1); */ /* double* u_vertex = P4EST_ALLOC(double, p4est->local_num_quadrants*(P4EST_CHILDREN)); */ /* element_data_store_nodal_vec_in_vertex_array */ /* ( */ /* p4est, */ /* u, */ /* u_vertex */ /* ); */ /* char sol_save_as [500]; */ /* sprintf(sol_save_as, "%s_test_nonconform_sym_level_%d_u", P4EST_STRING, i); */ /* curved_hacked_p4est_vtk_write_all */ /* (p4est, */ /* NULL, */ /* 0.99, */ /* 0, */ /* 1, */ /* 1, */ /* 0, */ /* 1, */ /* 0, */ /* sol_save_as, */ /* "u", */ /* u_vertex */ /* ); */ /* P4EST_FREE(u_vertex); */ /* ip_flux_params_t ip_flux_params; */ /* ip_flux_params.ip_flux_penalty_prefactor = atoi(argv[6]); */ /* ip_flux_params.ip_flux_penalty_calculate_fcn = sipg_flux_vector_calc_penalty_maxp2_over_minh; */ /* problem_data_t vecs; */ /* vecs.u = u; */ /* vecs.local_nodes = element_data_get_local_nodes(p4est); */ /* vecs.vector_flux_fcn_data = sipg_flux_vector_dirichlet_fetch_fcns */ /* ( */ /* zero_fcn, */ /* &ip_flux_params */ /* ); */ /* vecs.scalar_flux_fcn_data = sipg_flux_scalar_dirichlet_fetch_fcns(zero_fcn); */ /* weakeqn_ptrs_t fcns; */ /* fcns.apply_lhs = poisson_apply_aij; */ /* matrix_sym_tester */ /* ( */ /* p4est, */ /* &vecs, /\* only needed for # of nodes *\/ */ /* &fcns, */ /* .000000000000001, */ /* dgmath_jit_dbase, */ /* 0, */ /* 0 */ /* ); */ /* } */ P4EST_FREE(u); geometric_factors_destroy(geometric_factors); /* free pointers */ dgmath_jit_dbase_destroy(dgmath_jit_dbase); /* free pXest */ p4est_destroy(p4est); /* p4est_destroy(p4est); */ if (geom != NULL) { p4est_geometry_destroy (geom); } p4est_connectivity_destroy(conn); /* finalize mpi stuff */ sc_finalize(); mpiret = sc_MPI_Finalize (); SC_CHECK_MPI(mpiret); }
int main (int argc, char **argv) { int rank; int mpiret; sc_MPI_Comm mpicomm; p4est_t *p4est; p4est_connectivity_t *connectivity; mpiret = sc_MPI_Init (&argc, &argv); SC_CHECK_MPI (mpiret); mpicomm = sc_MPI_COMM_WORLD; mpiret = sc_MPI_Comm_rank (mpicomm, &rank); SC_CHECK_MPI (mpiret); sc_init (mpicomm, 1, 1, NULL, SC_LP_DEFAULT); p4est_init (NULL, SC_LP_DEFAULT); /* create connectivity and forest structures */ connectivity = p4est_connectivity_new_star (); p4est = p4est_new_ext (mpicomm, connectivity, 15, 0, 0, sizeof (user_data_t), init_fn, NULL); /* refine to make the number of elements interesting */ p4est_refine (p4est, 1, refine_fn, init_fn); /* balance the forest */ p4est_balance (p4est, P4EST_CONNECT_FULL, init_fn); /* do a uniform partition, include the weight function for testing */ p4est_partition (p4est, 0, weight_one); p4est_check_local_order (p4est, connectivity); /* do a weighted partition with many zero weights */ weight_counter = 0; weight_index = (rank == 1) ? 1342 : 0; p4est_partition (p4est, 0, weight_once); p4est_check_local_order (p4est, connectivity); /* clean up */ p4est_destroy (p4est); p4est_connectivity_destroy (connectivity); /* create connectivity and forest structures */ connectivity = p4est_connectivity_new_periodic (); p4est = p4est_new_ext (mpicomm, connectivity, 15, 0, 0, sizeof (user_data_t), init_fn, NULL); /* refine to make the number of elements interesting */ p4est_refine (p4est, 1, refine_fn, init_fn); /* balance the forest */ p4est_balance (p4est, P4EST_CONNECT_FULL, init_fn); /* do a uniform partition, include the weight function for testing */ p4est_partition (p4est, 0, weight_one); p4est_check_local_order (p4est, connectivity); /* clean up and exit */ p4est_destroy (p4est); p4est_connectivity_destroy (connectivity); sc_finalize (); mpiret = sc_MPI_Finalize (); SC_CHECK_MPI (mpiret); return 0; }
int main (int argc, char **argv) { int mpiret, retval; int mpirank; const char *argbasename; char afilename[BUFSIZ]; p4est_topidx_t tnum_flips; p8est_tets_t *ptg; p8est_connectivity_t *connectivity; p8est_t *p8est; MPI_Comm mpicomm; mpiret = MPI_Init (&argc, &argv); SC_CHECK_MPI (mpiret); mpicomm = MPI_COMM_WORLD; mpiret = MPI_Comm_rank (mpicomm, &mpirank); sc_init (MPI_COMM_WORLD, 1, 1, NULL, SC_LP_DEFAULT); p4est_init (NULL, SC_LP_DEFAULT); if (argc != 2) { SC_GLOBAL_LERRORF ("Usage: %s <tetgen file base name>\n", argv[0]); sc_abort (); } argbasename = argv[1]; /* read tetgen nodes and tetrahedra from files */ ptg = p8est_tets_read (argbasename); SC_CHECK_ABORTF (ptg != NULL, "Failed to read tetgen %s", argbasename); P4EST_GLOBAL_STATISTICSF ("Read %d nodes and %d tets %s attributes\n", (int) ptg->nodes->elem_count / 3, (int) ptg->tets->elem_count / 4, ptg->tet_attributes != NULL ? "with" : "without"); /* flip orientation to right-handed */ tnum_flips = p8est_tets_make_righthanded (ptg); P4EST_GLOBAL_STATISTICSF ("Performed %ld orientation flip(s)\n", (long) tnum_flips); /* create a connectivity from the tet mesh and save it */ connectivity = p8est_connectivity_new_tets (ptg); if (mpirank == 0) { snprintf (afilename, BUFSIZ, "%s", "read_tetgen.p8c"); retval = p8est_connectivity_save (afilename, connectivity); SC_CHECK_ABORT (retval == 0, "Failed connectivity_save"); } /* create a forest and visualize */ p8est = p8est_new (mpicomm, connectivity, 0, NULL, NULL); snprintf (afilename, BUFSIZ, "%s", "read_tetgen"); p8est_vtk_write_file (p8est, NULL, afilename); /* clean up */ p8est_destroy (p8est); p8est_connectivity_destroy (connectivity); p8est_tets_destroy (ptg); sc_finalize (); mpiret = MPI_Finalize (); SC_CHECK_MPI (mpiret); return 0; }
int main (int argc, char **argv) { int mpiret; int wrongusage; const char *usage; mpi_context_t mpi_context, *mpi = &mpi_context; p4est_connectivity_t *connectivity; simple_config_t config; /* initialize MPI and p4est internals */ mpiret = sc_MPI_Init (&argc, &argv); SC_CHECK_MPI (mpiret); mpi->mpicomm = sc_MPI_COMM_WORLD; mpiret = sc_MPI_Comm_size (mpi->mpicomm, &mpi->mpisize); SC_CHECK_MPI (mpiret); mpiret = sc_MPI_Comm_rank (mpi->mpicomm, &mpi->mpirank); SC_CHECK_MPI (mpiret); sc_init (mpi->mpicomm, 1, 1, NULL, SC_LP_DEFAULT); p4est_init (NULL, SC_LP_DEFAULT); /* process command line arguments */ usage = "Arguments: <configuration> <level>\n Configuration can be any of\n" #ifndef P4_TO_P8 " unit|three|moebius|star|periodic|rotwrap|cubed|disk\n" #else " unit|periodic|rotwrap|twocubes|twowrap|rotcubes|shell|sphere\n" #endif " Level controls the maximum depth of refinement\n"; wrongusage = 0; config = P4EST_CONFIG_NULL; if (!wrongusage && argc != 3) { wrongusage = 1; } if (!wrongusage) { if (!strcmp (argv[1], "unit")) { #ifndef P4_TO_P8 config = P4EST_CONFIG_UNIT; #else config = P8EST_CONFIG_UNIT; #endif } #ifndef P4_TO_P8 else if (!strcmp (argv[1], "three")) { config = P4EST_CONFIG_THREE; } else if (!strcmp (argv[1], "moebius")) { config = P4EST_CONFIG_MOEBIUS; } else if (!strcmp (argv[1], "star")) { config = P4EST_CONFIG_STAR; } else if (!strcmp (argv[1], "periodic")) { config = P4EST_CONFIG_PERIODIC; } else if (!strcmp (argv[1], "rotwrap")) { config = P4EST_CONFIG_ROTWRAP; } else if (!strcmp (argv[1], "cubed")) { config = P4EST_CONFIG_CUBED; } else if (!strcmp (argv[1], "disk")) { config = P4EST_CONFIG_DISK; } #else else if (!strcmp (argv[1], "periodic")) { config = P8EST_CONFIG_PERIODIC; } else if (!strcmp (argv[1], "rotwrap")) { config = P8EST_CONFIG_ROTWRAP; } else if (!strcmp (argv[1], "twocubes")) { config = P8EST_CONFIG_TWOCUBES; } else if (!strcmp (argv[1], "twowrap")) { config = P8EST_CONFIG_TWOWRAP; } else if (!strcmp (argv[1], "rotcubes")) { config = P8EST_CONFIG_ROTCUBES; } else if (!strcmp (argv[1], "shell")) { config = P8EST_CONFIG_SHELL; } else if (!strcmp (argv[1], "sphere")) { config = P8EST_CONFIG_SPHERE; } #endif else { wrongusage = 1; } } if (wrongusage) { P4EST_GLOBAL_LERROR (usage); sc_abort_collective ("Usage error"); } /* assign variables based on configuration */ refine_level = atoi (argv[2]); /* create connectivity and forest structures */ if (0) { } #ifndef P4_TO_P8 else if (config == P4EST_CONFIG_THREE) { connectivity = p4est_connectivity_new_corner (); } else if (config == P4EST_CONFIG_MOEBIUS) { connectivity = p4est_connectivity_new_moebius (); } else if (config == P4EST_CONFIG_STAR) { connectivity = p4est_connectivity_new_star (); } else if (config == P4EST_CONFIG_PERIODIC) { connectivity = p4est_connectivity_new_periodic (); } else if (config == P4EST_CONFIG_ROTWRAP) { connectivity = p4est_connectivity_new_rotwrap (); } else if (config == P4EST_CONFIG_CUBED) { connectivity = p4est_connectivity_new_cubed (); } else if (config == P4EST_CONFIG_DISK) { connectivity = p4est_connectivity_new_disk (); } #else else if (config == P8EST_CONFIG_PERIODIC) { connectivity = p8est_connectivity_new_periodic (); } else if (config == P8EST_CONFIG_ROTWRAP) { connectivity = p8est_connectivity_new_rotwrap (); } else if (config == P8EST_CONFIG_TWOCUBES) { connectivity = p8est_connectivity_new_twocubes (); } else if (config == P8EST_CONFIG_TWOWRAP) { connectivity = p8est_connectivity_new_twowrap (); } else if (config == P8EST_CONFIG_ROTCUBES) { connectivity = p8est_connectivity_new_rotcubes (); } else if (config == P8EST_CONFIG_SHELL) { connectivity = p8est_connectivity_new_shell (); } else if (config == P8EST_CONFIG_SPHERE) { connectivity = p8est_connectivity_new_sphere (); } #endif else { #ifndef P4_TO_P8 connectivity = p4est_connectivity_new_unitsquare (); #else connectivity = p8est_connectivity_new_unitcube (); #endif } #if 0 /* hack test */ hack_test (mpi, connectivity); #else /* run mesh tests */ mesh_run (mpi, connectivity, 1, 0, 1, P4EST_CONNECT_FULL); mesh_run (mpi, connectivity, 0, 1, 0, P4EST_CONNECT_FULL); mesh_run (mpi, connectivity, 0, 0, 0, P4EST_CONNECT_FACE); mesh_run (mpi, connectivity, 1, 1, 1, P4EST_CONNECT_FACE); #endif /* clean up and exit */ p4est_connectivity_destroy (connectivity); sc_finalize (); mpiret = sc_MPI_Finalize (); SC_CHECK_MPI (mpiret); return 0; }
int main (int argc, char **argv) { sc_MPI_Comm mpicomm; int mpiret; int mpirank; int first_arg; const char *prefix; p4est_connectivity_t *connectivity; sc_options_t *opt; /* initialize MPI */ mpiret = sc_MPI_Init (&argc, &argv); SC_CHECK_MPI (mpiret); mpicomm = sc_MPI_COMM_WORLD; mpiret = sc_MPI_Comm_rank (mpicomm, &mpirank); SC_CHECK_MPI (mpiret); /* initialize libsc and p4est */ sc_init (mpicomm, 1, 1, NULL, SC_LP_DEFAULT); p4est_init (NULL, SC_LP_DEFAULT); /* handle command line options */ opt = sc_options_new (argv[0]); sc_options_add_int (opt, 'l', "level", &refine_level, default_refine_level, "Refinement level"); sc_options_add_string (opt, 'o', "oprefix", &prefix, P4EST_STRING, "Output prefix"); first_arg = sc_options_parse (p4est_package_id, SC_LP_INFO, opt, argc, argv); SC_CHECK_ABORT (first_arg >= 0, "Option error"); /* create connectivity */ #ifndef P4_TO_P8 connectivity = p4est_connectivity_new_star (); #else connectivity = p8est_connectivity_new_rotcubes (); #endif /* test with vertex information */ test_loadsave (connectivity, prefix, mpicomm, mpirank); /* test without vertex information */ connectivity->num_vertices = 0; P4EST_FREE (connectivity->vertices); connectivity->vertices = NULL; P4EST_FREE (connectivity->tree_to_vertex); connectivity->tree_to_vertex = NULL; p4est_connectivity_set_attr (connectivity, 1); memset (connectivity->tree_to_attr, 0, connectivity->num_trees * sizeof (int8_t)); test_loadsave (connectivity, prefix, mpicomm, mpirank); /* clean up and exit */ p4est_connectivity_destroy (connectivity); sc_options_destroy (opt); sc_finalize (); mpiret = sc_MPI_Finalize (); SC_CHECK_MPI (mpiret); return 0; }
/** * Runs all tests. */ int main (int argc, char **argv) { const char *this_fn_name = P4EST_STRING "_test_subcomm"; /* options */ const p4est_locidx_t min_quadrants = 15; const int min_level = 4; const int fill_uniform = 0; /* parallel environment */ sc_MPI_Comm mpicomm = sc_MPI_COMM_WORLD; int mpisize, submpisize; int mpiret; #ifdef P4EST_ENABLE_DEBUG int rank; #endif /* p4est */ p4est_connectivity_t *connectivity; p4est_t *p4est; p4est_locidx_t *partition; /* initialize MPI */ mpiret = sc_MPI_Init (&argc, &argv); SC_CHECK_MPI (mpiret); /* exit if MPI communicator cannot be reduced */ mpiret = sc_MPI_Comm_size (mpicomm, &mpisize); SC_CHECK_MPI (mpiret); if (mpisize == 1) { mpiret = sc_MPI_Finalize (); SC_CHECK_MPI (mpiret); return 0; } /* initialize p4est */ sc_init (mpicomm, 1, 1, NULL, SC_LP_DEFAULT); p4est_init (NULL, SC_LP_DEFAULT); /* create connectivity */ #ifdef P4_TO_P8 connectivity = p8est_connectivity_new_unitcube (); #else connectivity = p4est_connectivity_new_unitsquare (); #endif /* create p4est object */ p4est = p4est_new_ext (mpicomm, connectivity, min_quadrants, min_level, fill_uniform, 0, NULL, NULL); /* write vtk: new */ p4est_vtk_write_file (p4est, NULL, P4EST_STRING "_subcomm_new"); /* set variables pertaining to the parallel environment */ #ifdef P4EST_ENABLE_DEBUG rank = p4est->mpirank; #endif submpisize = mpisize / 2; P4EST_ASSERT (submpisize <= p4est->global_num_quadrants); /* construct partitioning with empty ranks */ { p4est_locidx_t n_quads_per_proc, n_quads_leftover; int p; partition = P4EST_ALLOC (p4est_locidx_t, mpisize); n_quads_per_proc = p4est->global_num_quadrants / submpisize; n_quads_leftover = p4est->global_num_quadrants - (n_quads_per_proc * submpisize); for (p = 0; p < mpisize; p++) { if (p % 2) { /* if this rank will get quadrants */ partition[p] = n_quads_per_proc; } else { /* if this rank will be empty */ partition[p] = 0; } } partition[1] += n_quads_leftover; /* check partitioning */ #ifdef P4EST_ENABLE_DEBUG { p4est_gloidx_t sum = 0; for (p = 0; p < mpisize; p++) { sum += (p4est_gloidx_t) partition[p]; } P4EST_ASSERT (sum == p4est->global_num_quadrants); } #endif } /* * Test 1: Reduce MPI communicator to non-empty ranks */ P4EST_GLOBAL_INFOF ("%s: Into test 1\n", this_fn_name); { p4est_t *p4est_subcomm; int is_nonempty; /* create p4est copy and re-partition */ p4est_subcomm = p4est_copy_ext (p4est, 1, 1); (void) p4est_partition_given (p4est_subcomm, partition); /* write vtk: partitioned */ p4est_vtk_write_file (p4est_subcomm, NULL, P4EST_STRING "_subcomm_part"); /* reduce MPI communicator to non-empty ranks */ is_nonempty = p4est_comm_parallel_env_reduce (&p4est_subcomm); P4EST_ASSERT ((is_nonempty && 0 < partition[rank]) || (!is_nonempty && 0 == partition[rank])); if (is_nonempty) { /* write vtk: reduced communicator */ p4est_vtk_write_file (p4est_subcomm, NULL, P4EST_STRING "_subcomm_sub1"); /* destroy the p4est that has a reduced MPI communicator */ p4est_destroy (p4est_subcomm); } } mpiret = sc_MPI_Barrier (mpicomm); SC_CHECK_MPI (mpiret); P4EST_GLOBAL_INFOF ("%s: Done test 1\n", this_fn_name); /* * Test 2: Reduce MPI communicator to non-empty ranks, but now the MPI * communicator is not owned */ P4EST_GLOBAL_INFOF ("%s: Into test 2\n", this_fn_name); { p4est_t *p4est_subcomm; int is_nonempty; /* create p4est copy and re-partition */ p4est_subcomm = p4est_copy_ext (p4est, 1, 0 /* don't dup. comm. */ ); (void) p4est_partition_given (p4est_subcomm, partition); /* reduce MPI communicator to non-empty ranks */ is_nonempty = p4est_comm_parallel_env_reduce (&p4est_subcomm); P4EST_ASSERT ((is_nonempty && 0 < partition[rank]) || (!is_nonempty && 0 == partition[rank])); if (is_nonempty) { /* destroy the p4est that has a reduced MPI communicator */ p4est_destroy (p4est_subcomm); } } mpiret = sc_MPI_Barrier (mpicomm); SC_CHECK_MPI (mpiret); P4EST_GLOBAL_INFOF ("%s: Done test 2\n", this_fn_name); /* * Test 3: Reduce MPI communicator to non-empty ranks, but keep rank 0 */ P4EST_GLOBAL_INFOF ("%s: Into test 3\n", this_fn_name); { p4est_t *p4est_subcomm; int sub_exists; sc_MPI_Group group, group_reserve; int reserve_range[1][3]; /* create group of full MPI communicator */ mpiret = sc_MPI_Comm_group (mpicomm, &group); SC_CHECK_MPI (mpiret); /* create sub-group containing only rank 0 */ reserve_range[0][0] = 0; reserve_range[0][1] = 0; reserve_range[0][2] = 1; mpiret = sc_MPI_Group_range_incl (group, 1, reserve_range, &group_reserve); SC_CHECK_MPI (mpiret); /* create p4est copy and re-partition */ p4est_subcomm = p4est_copy_ext (p4est, 1, 1); (void) p4est_partition_given (p4est_subcomm, partition); /* reduce MPI communicator to non-empty ranks, but keep rank 0 */ sub_exists = p4est_comm_parallel_env_reduce_ext (&p4est_subcomm, group_reserve, 1, NULL); P4EST_ASSERT ((sub_exists && (0 < partition[rank] || rank == 0)) || (!sub_exists && 0 == partition[rank])); if (sub_exists) { /* write vtk: reduced communicator */ p4est_vtk_write_file (p4est_subcomm, NULL, P4EST_STRING "_subcomm_sub3"); /* destroy the p4est that has a reduced MPI communicator */ p4est_destroy (p4est_subcomm); } } mpiret = sc_MPI_Barrier (mpicomm); SC_CHECK_MPI (mpiret); P4EST_GLOBAL_INFOF ("%s: Done test 3\n", this_fn_name); /* * Test 4: Reduce MPI communicator to non-empty ranks, but keep last 2 ranks */ P4EST_GLOBAL_INFOF ("%s: Into test 4\n", this_fn_name); { p4est_t *p4est_subcomm; int sub_exists; sc_MPI_Group group, group_reserve; int reserve_range[1][3]; /* create group of full MPI communicator */ mpiret = sc_MPI_Comm_group (mpicomm, &group); SC_CHECK_MPI (mpiret); /* create sub-group containing only last 2 ranks */ reserve_range[0][0] = SC_MAX (0, mpisize - 2); reserve_range[0][1] = mpisize - 1; reserve_range[0][2] = 1; mpiret = sc_MPI_Group_range_incl (group, 1, reserve_range, &group_reserve); SC_CHECK_MPI (mpiret); /* create p4est copy and re-partition */ p4est_subcomm = p4est_copy_ext (p4est, 1, 1); (void) p4est_partition_given (p4est_subcomm, partition); /* reduce MPI communicator to non-empty ranks, but keep last 2 ranks */ sub_exists = p4est_comm_parallel_env_reduce_ext (&p4est_subcomm, group_reserve, 0, NULL); P4EST_ASSERT ((sub_exists && (0 < partition[rank] || mpisize - 2 <= rank)) || (!sub_exists && 0 == partition[rank])); if (sub_exists) { /* write vtk: reduced communicator */ p4est_vtk_write_file (p4est_subcomm, NULL, P4EST_STRING "_subcomm_sub4"); /* destroy the p4est that has a reduced MPI communicator */ p4est_destroy (p4est_subcomm); } } mpiret = sc_MPI_Barrier (mpicomm); SC_CHECK_MPI (mpiret); P4EST_GLOBAL_INFOF ("%s: Done test 4\n", this_fn_name); /* destroy */ P4EST_FREE (partition); p4est_destroy (p4est); p4est_connectivity_destroy (connectivity); /* finalize */ sc_finalize (); mpiret = sc_MPI_Finalize (); SC_CHECK_MPI (mpiret); return 0; }
int main (int argc, char **argv) { int mpiret; int wrongusage; unsigned crc; const char *usage; mpi_context_t mpi_context, *mpi = &mpi_context; p8est_t *p8est; p8est_connectivity_t *connectivity; p8est_geometry_t *geom; p8est_refine_t refine_fn; p8est_coarsen_t coarsen_fn; simple_config_t config; const simple_regression_t *r; /* initialize MPI and p4est internals */ mpiret = MPI_Init (&argc, &argv); SC_CHECK_MPI (mpiret); mpi->mpicomm = MPI_COMM_WORLD; mpiret = MPI_Comm_size (mpi->mpicomm, &mpi->mpisize); SC_CHECK_MPI (mpiret); mpiret = MPI_Comm_rank (mpi->mpicomm, &mpi->mpirank); SC_CHECK_MPI (mpiret); sc_init (mpi->mpicomm, 1, 1, NULL, SC_LP_DEFAULT); p4est_init (NULL, SC_LP_DEFAULT); /* process command line arguments */ usage = "Arguments: <configuration> <level>\n" " Configuration can be any of\n" " unit|periodic|rotwrap|twocubes|twowrap|rotcubes|shell|sphere\n" " Level controls the maximum depth of refinement\n"; wrongusage = 0; config = P8EST_CONFIG_NULL; if (!wrongusage && argc != 3) { wrongusage = 1; } if (!wrongusage) { if (!strcmp (argv[1], "unit")) { config = P8EST_CONFIG_UNIT; } else if (!strcmp (argv[1], "periodic")) { config = P8EST_CONFIG_PERIODIC; } else if (!strcmp (argv[1], "rotwrap")) { config = P8EST_CONFIG_ROTWRAP; } else if (!strcmp (argv[1], "twocubes")) { config = P8EST_CONFIG_TWOCUBES; } else if (!strcmp (argv[1], "twowrap")) { config = P8EST_CONFIG_TWOWRAP; } else if (!strcmp (argv[1], "rotcubes")) { config = P8EST_CONFIG_ROTCUBES; } else if (!strcmp (argv[1], "shell")) { config = P8EST_CONFIG_SHELL; } else if (!strcmp (argv[1], "sphere")) { config = P8EST_CONFIG_SPHERE; } else { wrongusage = 1; } } if (wrongusage) { P4EST_GLOBAL_LERROR (usage); sc_abort_collective ("Usage error"); } /* assign variables based on configuration */ refine_level = atoi (argv[2]); refine_fn = refine_normal_fn; coarsen_fn = NULL; /* create connectivity and forest structures */ geom = NULL; if (config == P8EST_CONFIG_PERIODIC) { connectivity = p8est_connectivity_new_periodic (); } else if (config == P8EST_CONFIG_ROTWRAP) { connectivity = p8est_connectivity_new_rotwrap (); } else if (config == P8EST_CONFIG_TWOCUBES) { connectivity = p8est_connectivity_new_twocubes (); refine_fn = refine_sparse_fn; } else if (config == P8EST_CONFIG_TWOWRAP) { connectivity = p8est_connectivity_new_twowrap (); refine_fn = refine_sparse_fn; } else if (config == P8EST_CONFIG_ROTCUBES) { connectivity = p8est_connectivity_new_rotcubes (); } else if (config == P8EST_CONFIG_SHELL) { connectivity = p8est_connectivity_new_shell (); geom = p8est_geometry_new_shell (1., .55); } else if (config == P8EST_CONFIG_SPHERE) { connectivity = p8est_connectivity_new_sphere (); geom = p8est_geometry_new_sphere (1., 0.191728, 0.039856); } else { connectivity = p8est_connectivity_new_unitcube (); } p8est = p8est_new_ext (mpi->mpicomm, connectivity, 1, 0, 0, sizeof (user_data_t), init_fn, NULL); #ifdef VTK_OUTPUT p8est_vtk_write_file (p8est, geom, "simple3_new"); #endif /* refinement and coarsening */ p8est_refine (p8est, 1, refine_fn, init_fn); if (coarsen_fn != NULL) { p8est_coarsen (p8est, 1, coarsen_fn, init_fn); } #ifdef VTK_OUTPUT p8est_vtk_write_file (p8est, geom, "simple3_refined"); #endif /* balance */ p8est_balance (p8est, P8EST_CONNECT_FULL, init_fn); #ifdef VTK_OUTPUT p8est_vtk_write_file (p8est, geom, "simple3_balanced"); #endif crc = p8est_checksum (p8est); /* partition */ p8est_partition (p8est, NULL); #ifdef VTK_OUTPUT p8est_vtk_write_file (p8est, geom, "simple3_partition"); #endif #ifdef P4EST_DEBUG /* rebalance should not change checksum */ p8est_balance (p8est, P8EST_CONNECT_FULL, init_fn); P4EST_ASSERT (p8est_checksum (p8est) == crc); #endif /* print and verify forest checksum */ P4EST_GLOBAL_STATISTICSF ("Tree checksum 0x%08x\n", crc); if (mpi->mpirank == 0) { for (r = regression; r->config != P8EST_CONFIG_NULL; ++r) { if (r->config != config || r->mpisize != mpi->mpisize || r->level != refine_level) continue; SC_CHECK_ABORT (crc == r->checksum, "Checksum mismatch"); P4EST_GLOBAL_INFO ("Checksum regression OK\n"); break; } } /* destroy the p8est and its connectivity structure */ p8est_destroy (p8est); P4EST_FREE (geom); p8est_connectivity_destroy (connectivity); /* clean up and exit */ sc_finalize (); mpiret = MPI_Finalize (); SC_CHECK_MPI (mpiret); return 0; }
int main (int argc, char **argv) { sc_MPI_Comm mpicomm; int mpiret; int mpisize, mpirank; p4est_t *p4est; p4est_connectivity_t *conn; sc_array_t *points_per_dim, *cone_sizes, *cones, *cone_orientations, *coords, *children, *parents, *childids, *leaves, *remotes; p4est_locidx_t first_local_quad = -1; /* initialize MPI */ mpiret = sc_MPI_Init (&argc, &argv); SC_CHECK_MPI (mpiret); mpicomm = sc_MPI_COMM_WORLD; mpiret = sc_MPI_Comm_size (mpicomm, &mpisize); SC_CHECK_MPI (mpiret); mpiret = sc_MPI_Comm_rank (mpicomm, &mpirank); SC_CHECK_MPI (mpiret); sc_init (mpicomm, 1, 1, NULL, SC_LP_DEFAULT); p4est_init (NULL, SC_LP_DEFAULT); #ifndef P4_TO_P8 conn = p4est_connectivity_new_moebius (); #else conn = p8est_connectivity_new_rotcubes (); #endif p4est = p4est_new_ext (mpicomm, conn, 0, 1, 1, 0, NULL, NULL); p4est_refine (p4est, 1, refine_fn, NULL); p4est_balance (p4est, P4EST_CONNECT_FULL, NULL); p4est_partition (p4est, 0, NULL); points_per_dim = sc_array_new (sizeof (p4est_locidx_t)); cone_sizes = sc_array_new (sizeof (p4est_locidx_t)); cones = sc_array_new (sizeof (p4est_locidx_t)); cone_orientations = sc_array_new (sizeof (p4est_locidx_t)); coords = sc_array_new (3 * sizeof (double)); children = sc_array_new (sizeof (p4est_locidx_t)); parents = sc_array_new (sizeof (p4est_locidx_t)); childids = sc_array_new (sizeof (p4est_locidx_t)); leaves = sc_array_new (sizeof (p4est_locidx_t)); remotes = sc_array_new (2 * sizeof (p4est_locidx_t)); p4est_get_plex_data (p4est, P4EST_CONNECT_FULL, (mpisize > 1) ? 2 : 0, &first_local_quad, points_per_dim, cone_sizes, cones, cone_orientations, coords, children, parents, childids, leaves, remotes); #ifdef P4EST_WITH_PETSC { PetscErrorCode ierr; DM plex, refTree; PetscInt pStart, pEnd; PetscSection parentSection; PetscSF pointSF; size_t zz, count; locidx_to_PetscInt (points_per_dim); locidx_to_PetscInt (cone_sizes); locidx_to_PetscInt (cones); locidx_to_PetscInt (cone_orientations); coords_double_to_PetscScalar (coords); locidx_to_PetscInt (children); locidx_to_PetscInt (parents); locidx_to_PetscInt (childids); locidx_to_PetscInt (leaves); locidx_pair_to_PetscSFNode (remotes); P4EST_GLOBAL_PRODUCTION ("Begin PETSc routines\n"); ierr = PetscInitialize (&argc, &argv, 0, help); CHKERRQ (ierr); ierr = DMPlexCreate (mpicomm, &plex); CHKERRQ (ierr); ierr = DMSetDimension (plex, P4EST_DIM); CHKERRQ (ierr); ierr = DMSetCoordinateDim (plex, 3); CHKERRQ (ierr); ierr = DMPlexCreateFromDAG (plex, P4EST_DIM, (PetscInt *) points_per_dim->array, (PetscInt *) cone_sizes->array, (PetscInt *) cones->array, (PetscInt *) cone_orientations->array, (PetscScalar *) coords->array); CHKERRQ (ierr); ierr = PetscSFCreate (mpicomm, &pointSF); CHKERRQ (ierr); ierr = DMPlexCreateDefaultReferenceTree (mpicomm, P4EST_DIM, PETSC_FALSE, &refTree); CHKERRQ (ierr); ierr = DMPlexSetReferenceTree (plex, refTree); CHKERRQ (ierr); ierr = DMDestroy (&refTree); CHKERRQ (ierr); ierr = PetscSectionCreate (mpicomm, &parentSection); CHKERRQ (ierr); ierr = DMPlexGetChart (plex, &pStart, &pEnd); CHKERRQ (ierr); ierr = PetscSectionSetChart (parentSection, pStart, pEnd); CHKERRQ (ierr); count = children->elem_count; for (zz = 0; zz < count; zz++) { PetscInt child = *((PetscInt *) sc_array_index (children, zz)); ierr = PetscSectionSetDof (parentSection, child, 1); CHKERRQ (ierr); } ierr = PetscSectionSetUp (parentSection); CHKERRQ (ierr); ierr = DMPlexSetTree (plex, parentSection, (PetscInt *) parents->array, (PetscInt *) childids->array); CHKERRQ (ierr); ierr = PetscSectionDestroy (&parentSection); CHKERRQ (ierr); ierr = PetscSFSetGraph (pointSF, pEnd - pStart, (PetscInt) leaves->elem_count, (PetscInt *) leaves->array, PETSC_COPY_VALUES, (PetscSFNode *) remotes->array, PETSC_COPY_VALUES); CHKERRQ (ierr); ierr = DMViewFromOptions (plex, NULL, "-dm_view"); CHKERRQ (ierr); /* TODO: test with rigid body modes as in plex ex3 */ ierr = DMDestroy (&plex); CHKERRQ (ierr); ierr = PetscFinalize (); P4EST_GLOBAL_PRODUCTION ("End PETSc routines\n"); } #endif sc_array_destroy (points_per_dim); sc_array_destroy (cone_sizes); sc_array_destroy (cones); sc_array_destroy (cone_orientations); sc_array_destroy (coords); sc_array_destroy (children); sc_array_destroy (parents); sc_array_destroy (childids); sc_array_destroy (leaves); sc_array_destroy (remotes); p4est_destroy (p4est); p4est_connectivity_destroy (conn); sc_finalize (); mpiret = sc_MPI_Finalize (); SC_CHECK_MPI (mpiret); return 0; }
END_TEST int main(int argc, char *argv[]) { int mpiret; sc_MPI_Comm mpicomm; int proc_size; int nf; p4est_connectivity_t *conn; p4est_t* p4est; /* MPI init */ mpiret = sc_MPI_Init(&argc, &argv); SC_CHECK_MPI(mpiret); mpicomm = sc_MPI_COMM_WORLD; /* sc_init (mpicomm, 1, 1, NULL, SC_LP_ESSENTIAL); */ mpiret = MPI_Comm_size(mpicomm, &proc_size); SC_CHECK_MPI (mpiret); /* pXest init */ p4est_init(NULL, SC_LP_PRODUCTION); #if (P4EST_DIM)==3 conn = p8est_connectivity_new_unitcube(); #else conn = p4est_connectivity_new_unitsquare(); #endif p4est = p4est_new(mpicomm, conn, 0, NULL, NULL); global_p4est_pointer = p4est; /* start just-in-time dg-math */ dgmath_jit_init(); /* run tests */ Suite *s1 = suite_create("Test Plotting Functions"); SRunner *sr = srunner_create(s1); TCase *tc1 = tcase_create("Test Surface and Contour plotting"); TCase *tc2 = tcase_create("Test Error Plotting"); tcase_add_test(tc1, test_surface_plot); tcase_add_test(tc2, test_error_plot); tcase_set_timeout(tc2, 100); /* suite_add_tcase(s1,tc1); */ suite_add_tcase(s1,tc2); srunner_run_all(sr, CK_ENV); nf = srunner_ntests_failed(sr); /* free pointers */ dgmath_jit_destroy(); /* free pXest */ p4est_destroy(p4est); p4est_connectivity_destroy(conn); /* finalize mpi stuff */ /* sc_finalize(); */ mpiret = sc_MPI_Finalize (); SC_CHECK_MPI(mpiret); srunner_free(sr); return nf == 0 ? 0 : 1; }
int main (int argc, char **argv) { sc_MPI_Comm mpicomm; int mpiret; int mpisize, mpirank; unsigned crc; #ifndef P4_TO_P8 size_t kz; int8_t l; p4est_quadrant_t *q; p4est_tree_t stree, *tree = &stree; #endif p4est_t *p4est; p4est_connectivity_t *connectivity; /* initialize MPI */ mpiret = sc_MPI_Init (&argc, &argv); SC_CHECK_MPI (mpiret); mpicomm = sc_MPI_COMM_WORLD; mpiret = sc_MPI_Comm_size (mpicomm, &mpisize); SC_CHECK_MPI (mpiret); mpiret = sc_MPI_Comm_rank (mpicomm, &mpirank); SC_CHECK_MPI (mpiret); sc_init (mpicomm, 1, 1, NULL, SC_LP_DEFAULT); p4est_init (NULL, SC_LP_DEFAULT); #ifndef P4_TO_P8 connectivity = p4est_connectivity_new_star (); #else connectivity = p8est_connectivity_new_rotcubes (); #endif p4est = p4est_new_ext (mpicomm, connectivity, 0, 0, 0, 4, NULL, NULL); #ifndef P4_TO_P8 /* build empty tree */ sc_array_init (&tree->quadrants, sizeof (p4est_quadrant_t)); for (l = 0; l <= P4EST_MAXLEVEL; ++l) { tree->quadrants_per_level[l] = 0; } tree->maxlevel = 0; /* insert two quadrants */ sc_array_resize (&tree->quadrants, 4); q = p4est_quadrant_array_index (&tree->quadrants, 0); p4est_quadrant_set_morton (q, 3, 13); q = p4est_quadrant_array_index (&tree->quadrants, 1); p4est_quadrant_set_morton (q, 1, 1); q = p4est_quadrant_array_index (&tree->quadrants, 2); p4est_quadrant_set_morton (q, 1, 2); q = p4est_quadrant_array_index (&tree->quadrants, 3); p4est_quadrant_set_morton (q, 1, 3); for (kz = 0; kz < tree->quadrants.elem_count; ++kz) { q = p4est_quadrant_array_index (&tree->quadrants, kz); q->p.user_data = sc_mempool_alloc (p4est->user_data_pool); ++tree->quadrants_per_level[q->level]; tree->maxlevel = (int8_t) SC_MAX (tree->maxlevel, q->level); } /* balance the tree, print and destroy */ #if 0 p4est_balance_subtree (p4est, P4EST_CONNECT_FULL, 0, NULL); p4est_tree_print (SC_LP_INFO, tree); #endif for (kz = 0; kz < tree->quadrants.elem_count; ++kz) { q = p4est_quadrant_array_index (&tree->quadrants, kz); sc_mempool_free (p4est->user_data_pool, q->p.user_data); } sc_array_reset (&tree->quadrants); #endif /* !P4_TO_P8 */ /* check reset data function */ p4est_reset_data (p4est, 0, init_fn, NULL); p4est_reset_data (p4est, 0, NULL, NULL); /* refine and balance the forest */ SC_CHECK_ABORT (p4est_is_balanced (p4est, P4EST_CONNECT_FULL), "Balance 1"); p4est_refine (p4est, 1, refine_fn, NULL); SC_CHECK_ABORT (!p4est_is_balanced (p4est, P4EST_CONNECT_FULL), "Balance 2"); p4est_balance (p4est, P4EST_CONNECT_FULL, NULL); SC_CHECK_ABORT (p4est_is_balanced (p4est, P4EST_CONNECT_FULL), "Balance 3"); /* check reset data function */ p4est_reset_data (p4est, 17, NULL, NULL); p4est_reset_data (p4est, 8, init_fn, NULL); /* checksum and partition */ crc = p4est_checksum (p4est); p4est_partition (p4est, 0, NULL); SC_CHECK_ABORT (p4est_checksum (p4est) == crc, "Partition"); SC_CHECK_ABORT (p4est_is_balanced (p4est, P4EST_CONNECT_FULL), "Balance 4"); /* check reset data function */ p4est_reset_data (p4est, 3, NULL, NULL); p4est_reset_data (p4est, 3, NULL, NULL); /* checksum and rebalance */ crc = p4est_checksum (p4est); p4est_balance (p4est, P4EST_CONNECT_FULL, NULL); SC_CHECK_ABORT (p4est_checksum (p4est) == crc, "Rebalance"); /* clean up and exit */ P4EST_ASSERT (p4est->user_data_pool->elem_count == (size_t) p4est->local_num_quadrants); p4est_destroy (p4est); p4est_connectivity_destroy (connectivity); sc_finalize (); mpiret = sc_MPI_Finalize (); SC_CHECK_MPI (mpiret); return 0; }
int main (int argc, char **argv) { sc_MPI_Comm mpicomm; int mpiret; int found_total; p4est_locidx_t jt, Al, Bl; p4est_locidx_t local_count; p4est_connectivity_t *conn; p4est_quadrant_t *A, *B; p4est_geometry_t *geom; p4est_t *p4est; sc_array_t *points; test_point_t *p; const char *vtkname; /* Initialize MPI */ mpiret = sc_MPI_Init (&argc, &argv); SC_CHECK_MPI (mpiret); mpicomm = sc_MPI_COMM_WORLD; /* Initialize packages */ sc_init (mpicomm, 1, 1, NULL, SC_LP_DEFAULT); p4est_init (NULL, SC_LP_DEFAULT); /* Create forest */ #ifndef P4_TO_P8 conn = p4est_connectivity_new_star (); geom = NULL; vtkname = "test_search2"; #else conn = p8est_connectivity_new_sphere (); geom = p8est_geometry_new_sphere (conn, 1., 0.191728, 0.039856); vtkname = "test_search3"; #endif p4est = p4est_new_ext (mpicomm, conn, 0, 0, 0, 0, NULL, &local_count); p4est_refine (p4est, 1, refine_fn, NULL); p4est_partition (p4est, 0, NULL); p4est_vtk_write_file (p4est, geom, vtkname); /* The following code should really be in a separate function. */ /* Prepare a point search -- fix size so the memory is not relocated */ points = sc_array_new_size (sizeof (test_point_t), 2); /* A */ p = (test_point_t *) sc_array_index (points, 0); p->name = "A"; A = &p->quad; P4EST_QUADRANT_INIT (A); p4est_quadrant_set_morton (A, 3, 23); A->p.piggy3.which_tree = 0; A->p.piggy3.local_num = -1; Al = -1; /* B */ p = (test_point_t *) sc_array_index (points, 1); p->name = "B"; B = &p->quad; P4EST_QUADRANT_INIT (B); p4est_quadrant_set_morton (B, 2, 13); B->p.piggy3.which_tree = conn->num_trees / 2; B->p.piggy3.local_num = -1; Bl = -1; /* Find quadrant numbers if existing */ for (jt = p4est->first_local_tree; jt <= p4est->last_local_tree; ++jt) { size_t zz; p4est_tree_t *tree = p4est_tree_array_index (p4est->trees, jt); p4est_quadrant_t *quad; sc_array_t *tquadrants = &tree->quadrants; for (zz = 0; zz < tquadrants->elem_count; ++zz) { quad = p4est_quadrant_array_index (tquadrants, zz); if (A->p.piggy3.which_tree == jt && !p4est_quadrant_compare (quad, A)) { Al = tree->quadrants_offset + (p4est_locidx_t) zz; P4EST_VERBOSEF ("Searching for A at %lld\n", (long long) Al); } if (B->p.piggy3.which_tree == jt && !p4est_quadrant_compare (quad, B)) { Bl = tree->quadrants_offset + (p4est_locidx_t) zz; P4EST_VERBOSEF ("Searching for B at %lld\n", (long long) Bl); } } } /* Go */ found_count = 0; p4est_search_local (p4est, 0, NULL, search_callback, points); mpiret = sc_MPI_Allreduce (&found_count, &found_total, 1, sc_MPI_INT, sc_MPI_SUM, mpicomm); SC_CHECK_MPI (mpiret); SC_CHECK_ABORT (found_total == (int) points->elem_count, "Point search"); SC_CHECK_ABORT (A->p.piggy3.local_num == Al, "Search A"); SC_CHECK_ABORT (B->p.piggy3.local_num == Bl, "Search B"); /* Use another search to count local quadrants */ local_count = 0; p4est_search_local (p4est, 0, count_callback, NULL, NULL); SC_CHECK_ABORT (local_count == p4est->local_num_quadrants, "Count search"); /* Clear memory */ sc_array_destroy (points); p4est_destroy (p4est); if (geom != NULL) { p4est_geometry_destroy (geom); } p4est_connectivity_destroy (conn); /* Test the build_local function and friends */ test_build_local (mpicomm); /* Finalize */ sc_finalize (); mpiret = sc_MPI_Finalize (); SC_CHECK_MPI (mpiret); return 0; }
int main (int argc, char **argv) { int mpiret; int changed; int loop; #ifdef P4EST_ENABLE_DEBUG int lp = SC_LP_DEFAULT; #else int lp = SC_LP_PRODUCTION; #endif p4est_locidx_t jl; p4est_wrap_leaf_t *leaf; p4est_ghost_t *ghost; p4est_mesh_t *mesh; sc_MPI_Comm mpicomm; p4est_wrap_t *wrap; mpiret = sc_MPI_Init (&argc, &argv); SC_CHECK_MPI (mpiret); mpicomm = sc_MPI_COMM_WORLD; sc_init (mpicomm, 0, 0, NULL, lp); p4est_init (NULL, lp); #ifndef P4_TO_P8 wrap = p4est_wrap_new_rotwrap (mpicomm, 0); #else wrap = p8est_wrap_new_rotwrap (mpicomm, 0); #endif ghost = p4est_wrap_get_ghost (wrap); SC_CHECK_ABORT (ghost != NULL, "Get ghost"); ghost = NULL; mesh = p4est_wrap_get_mesh (wrap); SC_CHECK_ABORT (mesh != NULL, "Get mesh"); mesh = NULL; for (loop = 0; loop < 3; ++loop) { /* mark for refinement */ for (jl = 0, leaf = p4est_wrap_leaf_first (wrap); leaf != NULL; jl++, leaf = p4est_wrap_leaf_next (leaf)) { if (leaf->which_quad % 3 == 0) { p4est_wrap_mark_refine (wrap, leaf->which_tree, leaf->which_quad); } } SC_CHECK_ABORT (jl == wrap->p4est->local_num_quadrants, "Iterator"); changed = wrap_adapt_partition (wrap, 1); SC_CHECK_ABORT (changed, "Wrap refine"); } for (loop = 0; loop < 2; ++loop) { /* mark some elements for coarsening that does not effect anything */ for (jl = 0, leaf = p4est_wrap_leaf_first (wrap); leaf != NULL; jl++, leaf = p4est_wrap_leaf_next (leaf)) { if (leaf->which_quad % 5 == 0) { p4est_wrap_mark_refine (wrap, leaf->which_tree, leaf->which_quad); p4est_wrap_mark_coarsen (wrap, leaf->which_tree, leaf->which_quad); } } SC_CHECK_ABORT (jl == wrap->p4est->local_num_quadrants, "Iterator"); changed = wrap_adapt_partition (wrap, 0); SC_CHECK_ABORT (!changed, "Wrap noop"); } for (loop = 0; loop < 2; ++loop) { /* mark for coarsening */ for (jl = 0, leaf = p4est_wrap_leaf_first (wrap); leaf != NULL; jl++, leaf = p4est_wrap_leaf_next (leaf)) { if ((leaf->which_quad / 13) % 17 != 3) { p4est_wrap_mark_coarsen (wrap, leaf->which_tree, leaf->which_quad); } } SC_CHECK_ABORT (jl == wrap->p4est->local_num_quadrants, "Iterator"); (void) wrap_adapt_partition (wrap, 0); } p4est_wrap_destroy (wrap); sc_finalize (); mpiret = sc_MPI_Finalize (); SC_CHECK_MPI (mpiret); return 0; }
int main (int argc, char **argv) { p4est_quadrant_t root; p4est_quadrant_t p; p4est_quadrant_t q; p4est_quadrant_t desc; int face, corner; #ifndef P4_TO_P8 int maxlevel = 9; #else int edge; int maxlevel = 6; #endif int mpiret, mpisize, mpirank; sc_MPI_Comm mpicomm; uint64_t i, ifirst, ilast; int level; sc_array_t *seeds, *seeds_check; int testval; int checkval; int j, nrand = 1000; /* initialize MPI */ mpiret = sc_MPI_Init (&argc, &argv); SC_CHECK_MPI (mpiret); mpicomm = sc_MPI_COMM_WORLD; mpiret = sc_MPI_Comm_size (mpicomm, &mpisize); SC_CHECK_MPI (mpiret); mpiret = sc_MPI_Comm_rank (mpicomm, &mpirank); SC_CHECK_MPI (mpiret); srandom (9212007); sc_init (mpicomm, 1, 1, NULL, SC_LP_DEFAULT); p4est_init (NULL, SC_LP_DEFAULT); seeds = sc_array_new (sizeof (p4est_quadrant_t)); seeds_check = sc_array_new (sizeof (p4est_quadrant_t)); memset (&root, 0, sizeof (p4est_quadrant_t)); root.level = 2; root.x = P4EST_QUADRANT_LEN (2); root.y = P4EST_QUADRANT_LEN (2); #ifdef P4_TO_P8 root.z = P4EST_QUADRANT_LEN (2); #endif P4EST_QUADRANT_INIT (&p); P4EST_QUADRANT_INIT (&q); #if 1 for (face = 0; face < P4EST_FACES; face++) { p4est_quadrant_face_neighbor (&root, face ^ 1, &p); P4EST_GLOBAL_VERBOSEF ("Testing face %d\n", face); for (level = 4; level <= maxlevel; level++) { P4EST_GLOBAL_VERBOSEF (" level %d\n", level); p4est_quadrant_first_descendant (&root, &desc, level); ifirst = p4est_quadrant_linear_id (&desc, level); p4est_quadrant_last_descendant (&root, &desc, level); ilast = p4est_quadrant_linear_id (&desc, level); for (i = ifirst; i <= ilast; i += P4EST_CHILDREN) { p4est_quadrant_set_morton (&q, level, i); #ifndef P4_TO_P8 testval = p4est_balance_seeds_face (&q, &p, face, P4EST_CONNECT_FACE, seeds); standard_seeds (seeds); checkval = check_balance_seeds (&q, &p, P4EST_CONNECT_FACE, seeds_check); SC_CHECK_ABORT (testval == checkval, "p4est_balance_seeds_face error"); compare_seeds (seeds, seeds_check); #else testval = p4est_balance_seeds_face (&q, &p, face, P8EST_CONNECT_FACE, seeds); standard_seeds (seeds); checkval = check_balance_seeds (&q, &p, P8EST_CONNECT_FACE, seeds_check); SC_CHECK_ABORT (testval == checkval, "p8est_balance_seeds_face error"); compare_seeds (seeds, seeds_check); testval = p4est_balance_seeds_face (&q, &p, face, P8EST_CONNECT_EDGE, seeds); standard_seeds (seeds); checkval = check_balance_seeds (&q, &p, P8EST_CONNECT_EDGE, seeds_check); SC_CHECK_ABORT (testval == checkval, "p8est_balance_seeds_face error"); compare_seeds (seeds, seeds_check); #endif testval = p4est_balance_seeds_face (&q, &p, face, P4EST_CONNECT_FULL, seeds); standard_seeds (seeds); checkval = check_balance_seeds (&q, &p, P4EST_CONNECT_FULL, seeds_check); SC_CHECK_ABORT (testval == checkval, "p4est_balance_seeds_face error"); compare_seeds (seeds, seeds_check); } } if (!face) { P4EST_GLOBAL_VERBOSE (" random levels\n"); for (j = 0; j < (int) nrand; j++) { level = ((random ()) % (P4EST_QMAXLEVEL - maxlevel)) + maxlevel + 1; p4est_quadrant_first_descendant (&root, &desc, level); ifirst = p4est_quadrant_linear_id (&desc, level); p4est_quadrant_last_descendant (&root, &desc, level); ilast = p4est_quadrant_linear_id (&desc, level); i = ((random ()) % (ilast + 1 - ifirst)) + ifirst; p4est_quadrant_set_morton (&q, level, i); #ifndef P4_TO_P8 testval = p4est_balance_seeds_face (&q, &p, face, P4EST_CONNECT_FACE, seeds); standard_seeds (seeds); checkval = check_balance_seeds (&q, &p, P4EST_CONNECT_FACE, seeds_check); SC_CHECK_ABORT (testval == checkval, "p4est_balance_seeds_face error"); compare_seeds (seeds, seeds_check); #else testval = p4est_balance_seeds_face (&q, &p, face, P8EST_CONNECT_FACE, seeds); standard_seeds (seeds); checkval = check_balance_seeds (&q, &p, P8EST_CONNECT_FACE, seeds_check); SC_CHECK_ABORT (testval == checkval, "p8est_balance_seeds_face error"); compare_seeds (seeds, seeds_check); testval = p4est_balance_seeds_face (&q, &p, face, P8EST_CONNECT_EDGE, seeds); standard_seeds (seeds); checkval = check_balance_seeds (&q, &p, P8EST_CONNECT_EDGE, seeds_check); SC_CHECK_ABORT (testval == checkval, "p8est_balance_seeds_face error"); compare_seeds (seeds, seeds_check); #endif testval = p4est_balance_seeds_face (&q, &p, face, P4EST_CONNECT_FULL, seeds); standard_seeds (seeds); checkval = check_balance_seeds (&q, &p, P4EST_CONNECT_FULL, seeds_check); SC_CHECK_ABORT (testval == checkval, "p4est_balance_seeds_face error"); compare_seeds (seeds, seeds_check); } } } #ifdef P4_TO_P8 for (edge = 0; edge < P8EST_EDGES; edge++) { p8est_quadrant_edge_neighbor (&root, edge ^ 3, &p); P4EST_GLOBAL_VERBOSEF ("Testing edge %d\n", edge); for (level = 4; level <= maxlevel; level++) { P4EST_GLOBAL_VERBOSEF (" level %d\n", level); p4est_quadrant_first_descendant (&root, &desc, level); ifirst = p4est_quadrant_linear_id (&desc, level); p4est_quadrant_last_descendant (&root, &desc, level); ilast = p4est_quadrant_linear_id (&desc, level); for (i = ifirst; i <= ilast; i += P4EST_CHILDREN) { p4est_quadrant_set_morton (&q, level, i); testval = p8est_balance_seeds_edge (&q, &p, edge, P8EST_CONNECT_FACE, seeds); standard_seeds (seeds); checkval = check_balance_seeds (&q, &p, P8EST_CONNECT_FACE, seeds_check); SC_CHECK_ABORT (testval == checkval, "p8est_balance_seeds_edge error"); compare_seeds (seeds, seeds_check); testval = p8est_balance_seeds_edge (&q, &p, edge, P8EST_CONNECT_EDGE, seeds); standard_seeds (seeds); checkval = check_balance_seeds (&q, &p, P8EST_CONNECT_EDGE, seeds_check); SC_CHECK_ABORT (testval == checkval, "p8est_balance_seeds_edge error"); compare_seeds (seeds, seeds_check); testval = p8est_balance_seeds_edge (&q, &p, edge, P8EST_CONNECT_FULL, seeds); standard_seeds (seeds); checkval = check_balance_seeds (&q, &p, P8EST_CONNECT_FULL, seeds_check); SC_CHECK_ABORT (testval == checkval, "p8est_balance_seeds_edge error"); compare_seeds (seeds, seeds_check); } } if (!edge) { P4EST_GLOBAL_VERBOSE (" random levels\n"); for (j = 0; j < (int) nrand; j++) { level = ((random ()) % (P4EST_QMAXLEVEL - maxlevel)) + maxlevel + 1; p4est_quadrant_first_descendant (&root, &desc, level); ifirst = p4est_quadrant_linear_id (&desc, level); p4est_quadrant_last_descendant (&root, &desc, level); ilast = p4est_quadrant_linear_id (&desc, level); i = ((random ()) % (ilast + 1 - ifirst)) + ifirst; p4est_quadrant_set_morton (&q, level, i); testval = p8est_balance_seeds_edge (&q, &p, edge, P8EST_CONNECT_FACE, seeds); standard_seeds (seeds); checkval = check_balance_seeds (&q, &p, P8EST_CONNECT_FACE, seeds_check); SC_CHECK_ABORT (testval == checkval, "p8est_balance_seeds_edge error"); compare_seeds (seeds, seeds_check); testval = p8est_balance_seeds_edge (&q, &p, edge, P8EST_CONNECT_EDGE, seeds); standard_seeds (seeds); checkval = check_balance_seeds (&q, &p, P8EST_CONNECT_EDGE, seeds_check); SC_CHECK_ABORT (testval == checkval, "p8est_balance_seeds_edge error"); compare_seeds (seeds, seeds_check); testval = p8est_balance_seeds_edge (&q, &p, edge, P8EST_CONNECT_FULL, seeds); standard_seeds (seeds); checkval = check_balance_seeds (&q, &p, P8EST_CONNECT_FULL, seeds_check); SC_CHECK_ABORT (testval == checkval, "p8est_balance_seeds_edge error"); compare_seeds (seeds, seeds_check); } } } #endif #endif for (corner = 0; corner < P4EST_FACES; corner++) { p4est_quadrant_corner_neighbor (&root, corner ^ (P4EST_CHILDREN - 1), &p); P4EST_GLOBAL_VERBOSEF ("Testing corner %d\n", corner); for (level = 4; level <= maxlevel; level++) { P4EST_GLOBAL_VERBOSEF (" level %d\n", level); p4est_quadrant_first_descendant (&root, &desc, level); ifirst = p4est_quadrant_linear_id (&desc, level); p4est_quadrant_last_descendant (&root, &desc, level); ilast = p4est_quadrant_linear_id (&desc, level); for (i = ifirst; i <= ilast; i += P4EST_CHILDREN) { p4est_quadrant_set_morton (&q, level, i); #ifndef P4_TO_P8 testval = p4est_balance_seeds_corner (&q, &p, corner, P4EST_CONNECT_FACE, seeds); standard_seeds (seeds); checkval = check_balance_seeds (&q, &p, P4EST_CONNECT_FACE, seeds_check); SC_CHECK_ABORT (testval == checkval, "p4est_balance_seeds_corner error"); compare_seeds (seeds, seeds_check); #else testval = p4est_balance_seeds_corner (&q, &p, corner, P8EST_CONNECT_FACE, seeds); standard_seeds (seeds); checkval = check_balance_seeds (&q, &p, P8EST_CONNECT_FACE, seeds_check); SC_CHECK_ABORT (testval == checkval, "p8est_balance_seeds_corner error"); compare_seeds (seeds, seeds_check); testval = p4est_balance_seeds_corner (&q, &p, corner, P8EST_CONNECT_EDGE, seeds); standard_seeds (seeds); checkval = check_balance_seeds (&q, &p, P8EST_CONNECT_EDGE, seeds_check); SC_CHECK_ABORT (testval == checkval, "p8est_balance_seeds_corner error"); compare_seeds (seeds, seeds_check); #endif testval = p4est_balance_seeds_corner (&q, &p, corner, P4EST_CONNECT_FULL, seeds); standard_seeds (seeds); checkval = check_balance_seeds (&q, &p, P4EST_CONNECT_FULL, seeds_check); SC_CHECK_ABORT (testval == checkval, "p4est_balance_seeds_corner error"); compare_seeds (seeds, seeds_check); } } if (!corner) { P4EST_GLOBAL_VERBOSE (" random levels\n"); for (j = 0; j < (int) nrand; j++) { level = ((random ()) % (P4EST_QMAXLEVEL - maxlevel)) + maxlevel + 1; p4est_quadrant_first_descendant (&root, &desc, level); ifirst = p4est_quadrant_linear_id (&desc, level); p4est_quadrant_last_descendant (&root, &desc, level); ilast = p4est_quadrant_linear_id (&desc, level); i = ((random ()) % (ilast + 1 - ifirst)) + ifirst; p4est_quadrant_set_morton (&q, level, i); #ifndef P4_TO_P8 testval = p4est_balance_seeds_corner (&q, &p, corner, P4EST_CONNECT_FACE, seeds); standard_seeds (seeds); checkval = check_balance_seeds (&q, &p, P4EST_CONNECT_FACE, seeds_check); SC_CHECK_ABORT (testval == checkval, "p4est_balance_seeds_corner error"); compare_seeds (seeds, seeds_check); #else testval = p4est_balance_seeds_corner (&q, &p, corner, P8EST_CONNECT_FACE, seeds); standard_seeds (seeds); checkval = check_balance_seeds (&q, &p, P8EST_CONNECT_FACE, seeds_check); SC_CHECK_ABORT (testval == checkval, "p8est_balance_seeds_corner error"); compare_seeds (seeds, seeds_check); testval = p4est_balance_seeds_corner (&q, &p, corner, P8EST_CONNECT_EDGE, seeds); standard_seeds (seeds); checkval = check_balance_seeds (&q, &p, P8EST_CONNECT_EDGE, seeds_check); SC_CHECK_ABORT (testval == checkval, "p8est_balance_seeds_corner error"); compare_seeds (seeds, seeds_check); #endif testval = p4est_balance_seeds_corner (&q, &p, corner, P4EST_CONNECT_FULL, seeds); standard_seeds (seeds); checkval = check_balance_seeds (&q, &p, P4EST_CONNECT_FULL, seeds_check); SC_CHECK_ABORT (testval == checkval, "p4est_balance_seeds_corner error"); compare_seeds (seeds, seeds_check); } } } sc_array_destroy (seeds); sc_array_destroy (seeds_check); sc_finalize (); mpiret = sc_MPI_Finalize (); SC_CHECK_MPI (mpiret); return 0; }
int main (int argc, char **argv) { int my_face, target_face, orientation; int face_ref, face_perm; int low[2], high[2], swap; int i, reverse; int ft[9], gt[9]; int *my_axis = &ft[0]; int *target_axis = &ft[3]; int *edge_reverse = &ft[6]; sc_init (sc_MPI_COMM_NULL, 1, 1, NULL, SC_LP_DEFAULT); p4est_init (NULL, SC_LP_DEFAULT); for (my_face = 0; my_face < 2 * P4EST_DIM; ++my_face) { for (target_face = 0; target_face < 2 * P4EST_DIM; ++target_face) { for (orientation = 0; orientation < 4; ++orientation) { /* find if my edges 0 and 2 are parallel to the x, y, or z-axis */ my_axis[0] = p8est_face_edges[my_face][0] / 4; my_axis[1] = p8est_face_edges[my_face][2] / 4; target_axis[0] = target_axis[1] = -1; edge_reverse[0] = edge_reverse[1] = 0; /* find matching target vertices */ face_ref = p8est_face_permutation_refs[my_face][target_face]; face_perm = p8est_face_permutation_sets[face_ref][orientation]; low[0] = low[1] = p8est_face_corners[target_face][p8est_face_permutations[face_perm] [0]]; high[0] = p8est_face_corners[target_face][p8est_face_permutations[face_perm] [1]]; high[1] = p8est_face_corners[target_face][p8est_face_permutations[face_perm] [2]]; if (low[0] > high[0]) { swap = low[0]; low[0] = high[0]; high[0] = swap; edge_reverse[0] = 1; } if (low[1] > high[1]) { swap = low[1]; low[1] = high[1]; high[1] = swap; edge_reverse[1] = 1; } /* find matching target edges */ for (i = 0; i < 12; ++i) { if (low[0] == p8est_edge_corners[i][0] && high[0] == p8est_edge_corners[i][1]) { P4EST_ASSERT (target_axis[0] == -1); target_axis[0] = i / 4; #ifndef P4EST_ENABLE_DEBUG if (target_axis[1] >= 0) break; #endif } else if (low[1] == p8est_edge_corners[i][0] && high[1] == p8est_edge_corners[i][1]) { P4EST_ASSERT (target_axis[1] == -1); target_axis[1] = i / 4; #ifndef P4EST_ENABLE_DEBUG if (target_axis[0] >= 0) break; #endif } } /* find what axis is normal to the faces */ my_axis[2] = my_face / 2; target_axis[2] = target_face / 2; edge_reverse[2] = 2 * (my_face % 2) + target_face % 2; #ifdef P4EST_ENABLE_DEBUG for (i = 0; i < 3; ++i) { P4EST_ASSERT (0 <= my_axis[i] && my_axis[i] < 3); P4EST_ASSERT (0 <= target_axis[i] && target_axis[i] < 3); } P4EST_ASSERT (my_axis[0] != my_axis[1] && my_axis[0] != my_axis[2] && my_axis[1] != my_axis[2]); P4EST_ASSERT (target_axis[0] != target_axis[1] && target_axis[0] != target_axis[2] && target_axis[1] != target_axis[2]); #endif /* output the results */ P4EST_LDEBUGF ("Results for %d %d %d are %d %d %d %d %d %d %d %d %d\n", my_face, target_face, orientation, ft[0], ft[1], ft[2], ft[3], ft[4], ft[5], ft[6], ft[7], ft[8]); /* compute the transformation code in a faster way and compare */ gt[0] = my_face < 2 ? 1 : 0; gt[1] = my_face < 4 ? 2 : 1; gt[2] = my_face / 2; reverse = p8est_face_permutation_refs[0][my_face] ^ p8est_face_permutation_refs[0][target_face] ^ (orientation == 0 || orientation == 3); gt[3 + reverse] = target_face < 2 ? 1 : 0; gt[3 + !reverse] = target_face < 4 ? 2 : 1; gt[5] = target_face / 2; reverse = p8est_face_permutation_refs[my_face][target_face] == 1; gt[6 + reverse] = orientation % 2; gt[6 + !reverse] = orientation / 2; gt[8] = 2 * (my_face % 2) + target_face % 2; /* ensure that both computations yield the same result */ SC_CHECK_ABORT (!memcmp (ft, gt, 9 * sizeof (int)), "Mismatch"); } } } sc_finalize (); return 0; }
int main (int argc, char **argv) { sc_MPI_Comm mpicomm; int mpiret; int mpisize, mpirank; p4est_t *p4est; p4est_connectivity_t *connectivity; sc_dmatrix_t *vtkvec; p4est_tree_t *tree; sc_array_t *quadrants; size_t zz, count; p4est_quadrant_t *q; int i; #ifndef P4_TO_P8 char filename[] = "p4est_balance_face"; #else char filename[] = "p8est_balance_edge"; #endif p4est_vtk_context_t *context; sc_array_t *level; int retval; /* initialize MPI */ mpiret = sc_MPI_Init (&argc, &argv); SC_CHECK_MPI (mpiret); mpicomm = sc_MPI_COMM_WORLD; mpiret = sc_MPI_Comm_size (mpicomm, &mpisize); SC_CHECK_MPI (mpiret); mpiret = sc_MPI_Comm_rank (mpicomm, &mpirank); SC_CHECK_MPI (mpiret); sc_init (mpicomm, 1, 1, NULL, SC_LP_DEFAULT); p4est_init (NULL, SC_LP_DEFAULT); #ifndef P4_TO_P8 connectivity = p4est_connectivity_new_unitsquare (); #else connectivity = p8est_connectivity_new_unitcube (); #endif p4est = p4est_new_ext (mpicomm, connectivity, 0, 2, 1, sizeof (balance_seeds_elem_t), init_fn, NULL); p4est_refine (p4est, 1, refine_fn, init_fn); context = p4est_vtk_context_new (p4est, filename); p4est_vtk_context_set_scale (context, 1. - 2. * SC_EPS); context = p4est_vtk_write_header (context); SC_CHECK_ABORT (context != NULL, P4EST_STRING "_vtk: Error writing header"); vtkvec = sc_dmatrix_new (p4est->local_num_quadrants, P4EST_CHILDREN); tree = p4est_tree_array_index (p4est->trees, 0); quadrants = &(tree->quadrants); count = quadrants->elem_count; for (zz = 0; zz < count; zz++) { q = p4est_quadrant_array_index (quadrants, zz); for (i = 0; i < P4EST_CHILDREN; i++) { vtkvec->e[zz][i] = (double) ((balance_seeds_elem_t *) (q->p.user_data))->flag; } } level = sc_array_new_data ((void *) vtkvec->e[0], sizeof (double), count * P4EST_CHILDREN); context = p4est_vtk_write_point_dataf (context, 1, 0, "level", level, context); SC_CHECK_ABORT (context != NULL, P4EST_STRING "_vtk: Error writing point data"); sc_array_destroy (level); retval = p4est_vtk_write_footer (context); SC_CHECK_ABORT (!retval, P4EST_STRING "_vtk: Error writing footer"); sc_dmatrix_destroy (vtkvec); p4est_destroy (p4est); p4est_connectivity_destroy (connectivity); sc_finalize (); mpiret = sc_MPI_Finalize (); SC_CHECK_MPI (mpiret); return 0; }