예제 #1
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;
}
예제 #2
0
static void
test_the_p4est (p4est_connectivity_t * conn, int N)
{
  p4est_t            *p4est;
  p4est_ghost_t      *ghost;
  p4est_lnodes_t     *lnodes;

  p4est = p4est_new (sc_MPI_COMM_WORLD, conn, 0, NULL, NULL);
  ghost = p4est_ghost_new (p4est, P4EST_CONNECT_FULL);
  lnodes = p4est_lnodes_new (p4est, ghost, N);
  p4est_lnodes_destroy (lnodes);
  p4est_ghost_destroy (ghost);
  p4est_destroy (p4est);
}
예제 #3
0
파일: mesh2.c 프로젝트: holke/p4est
static void
mesh_run (mpi_context_t * mpi, p4est_connectivity_t * connectivity,
          int uniform, int compute_tree_index, int compute_level_lists,
          p4est_connect_type_t mesh_btype)
{
  int                 mpiret;
  unsigned            crc;
  long                local_used[4], global_used[4];
  p4est_t            *p4est;
  p4est_ghost_t      *ghost;
  p4est_mesh_t       *mesh;
  user_data_t        *ghost_data;

  p4est = p4est_new (mpi->mpicomm, connectivity,
                     sizeof (user_data_t), init_fn, NULL);
  if (!uniform)
    p4est_vtk_write_file (p4est, NULL, P4EST_STRING "_mesh_new");

  /* refinement */
  if (uniform) {
    p4est_refine (p4est, 1, refine_uniform, init_fn);
  }
  else {
    p4est_refine (p4est, 1, refine_normal, init_fn);
    p4est_vtk_write_file (p4est, NULL, P4EST_STRING "_mesh_refined");
  }

  /* balance */
  p4est_balance (p4est, P4EST_CONNECT_FULL, init_fn);
  if (!uniform)
    p4est_vtk_write_file (p4est, NULL, P4EST_STRING "_mesh_balanced");

  /* partition */
  p4est_partition (p4est, 0, NULL);
  if (!uniform) {
    p4est_vtk_write_file (p4est, NULL, P4EST_STRING "_mesh_partition");
  }
  crc = p4est_checksum (p4est);

  /* print and verify forest checksum */
  P4EST_GLOBAL_STATISTICSF ("Tree %s checksum 0x%08x\n",
                            uniform ? "uniform" : "adapted", crc);

  /* create ghost layer and mesh */
  ghost = p4est_ghost_new (p4est, P4EST_CONNECT_FULL);
  ghost_data = P4EST_ALLOC (user_data_t, ghost->ghosts.elem_count);
  p4est_ghost_exchange_data (p4est, ghost, ghost_data);
  mesh = p4est_mesh_new_ext (p4est, ghost,
                             compute_tree_index, compute_level_lists,
                             mesh_btype);
  test_mesh (p4est, ghost, mesh,
             compute_tree_index, compute_level_lists, mesh_btype,
             ghost_data, uniform);

  /* compute memory used */
  local_used[0] = (long) p4est_connectivity_memory_used (p4est->connectivity);
  local_used[1] = (long) p4est_memory_used (p4est);
  local_used[2] = (long) p4est_ghost_memory_used (ghost);
  local_used[3] = (long) p4est_mesh_memory_used (mesh);
  mpiret = sc_MPI_Allreduce (local_used, global_used, 4, sc_MPI_LONG,
                             sc_MPI_SUM, mpi->mpicomm);
  SC_CHECK_MPI (mpiret);
  P4EST_GLOBAL_PRODUCTIONF ("Total %s memory used %ld %ld %ld %ld\n",
                            uniform ? "uniform" : "adapted",
                            global_used[0], global_used[1],
                            global_used[2], global_used[3]);

  /* destroy ghost layer and mesh */
  P4EST_FREE (ghost_data);
  p4est_mesh_destroy (mesh);
  p4est_ghost_destroy (ghost);

  /* destroy the p4est structure */
  p4est_destroy (p4est);
}
예제 #4
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;
}