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[]) { 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 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; }
p4est_wrap_t * p4est_wrap_new_disk (sc_MPI_Comm mpicomm, int px, int py, int initial_level) { return p4est_wrap_new_conn (mpicomm, p4est_connectivity_new_disk (px, py), initial_level); }