Example #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;
}
Example #2
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;
}
Example #3
0
File: mesh2.c Project: holke/p4est
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;
}
Example #4
0
p4est_wrap_t       *
p4est_wrap_new_cubed (sc_MPI_Comm mpicomm, int initial_level)
{
  return p4est_wrap_new_conn (mpicomm,
                              p4est_connectivity_new_cubed (), initial_level);
}