This application generates, refines, and adjusts a mesh set on the command line.
This application generates, refines, and adjusts a mesh set on the command line.The resulting VTK files visually present each stage of the mesh modification procedure.
typedef enum
{
P4EST_CONFIG_NULL,
P4EST_CONFIG_UNIT,
P4EST_CONFIG_BRICK,
P4EST_CONFIG_THREE,
P4EST_CONFIG_EVIL,
P4EST_CONFIG_EVIL3,
P4EST_CONFIG_PILLOW,
P4EST_CONFIG_MOEBIUS,
P4EST_CONFIG_STAR,
P4EST_CONFIG_CUBED,
P4EST_CONFIG_DISK,
P4EST_CONFIG_XDISK,
P4EST_CONFIG_YDISK,
P4EST_CONFIG_PDISK,
P4EST_CONFIG_PERIODIC,
P4EST_CONFIG_ROTWRAP,
P4EST_CONFIG_CIRCLE,
P4EST_CONFIG_DROP,
P4EST_CONFIG_ICOSAHEDRON,
P4EST_CONFIG_SHELL2D,
P4EST_CONFIG_DISK2D,
P4EST_CONFIG_BOWTIE,
P4EST_CONFIG_SPHERE2D,
P4EST_CONFIG_LAST
}
simple_config_t;
typedef struct
{
simple_config_t config;
int mpisize;
int level;
unsigned checksum;
}
simple_regression_t;
typedef struct
{
}
user_data_t;
typedef struct
{
sc_MPI_Comm mpicomm;
int mpisize;
int mpirank;
}
mpi_context_t;
static int refine_level = 0;
static const simple_regression_t regression[] =
{{ P4EST_CONFIG_THREE, 1, 7, 0xa8d85863U },
{ P4EST_CONFIG_THREE, 2, 7, 0xa8d85863U },
{ P4EST_CONFIG_THREE, 3, 7, 0xa8d85863U },
{ P4EST_CONFIG_THREE, 4, 7, 0x20fb58edU },
{ P4EST_CONFIG_MOEBIUS, 1, 6, 0x98ab6cb2U },
{ P4EST_CONFIG_MOEBIUS, 3, 6, 0x98ab6cb2U },
{ P4EST_CONFIG_MOEBIUS, 5, 6, 0x98ab6cb2U },
{ P4EST_CONFIG_MOEBIUS, 6, 6, 0x6d2d6d6cU },
{ P4EST_CONFIG_STAR, 5, 6, 0x38d3736fU },
{ P4EST_CONFIG_STAR, 5, 7, 0xfb97aadfU },
{ P4EST_CONFIG_CUBED, 4, 3, 0x85581649U },
{ P4EST_CONFIG_CUBED, 5, 5, 0x64a1d105U },
{ P4EST_CONFIG_DISK, 5, 4, 0x4995411dU },
{ P4EST_CONFIG_DISK, 2, 6, 0x3f758706U },
{ P4EST_CONFIG_XDISK, 4, 4, 0x96324291 },
{ P4EST_CONFIG_YDISK, 4, 4, 0x752a4207 },
{ P4EST_CONFIG_PDISK, 4, 4, 0xf617437b },
{ P4EST_CONFIG_PDISK, 5, 5, 0x507fd0c9 },
{ P4EST_CONFIG_ROTWRAP, 1, 6, 0x9dd600c5U },
{ P4EST_CONFIG_ROTWRAP, 3, 6, 0x9dd600c5U },
{ P4EST_CONFIG_CIRCLE, 3, 6, 0xd6e4931b },
{ P4EST_CONFIG_DROP, 3, 6, 0xea6a6726 },
{ P4EST_CONFIG_BOWTIE, 1, 3, 0x63ba0805 },
{ P4EST_CONFIG_NULL, 0, 0, 0 }};
static void
{
user_data_t *data = (user_data_t *) quadrant->
p.
user_data;
data->a = which_tree;
}
static int
{
if ((
int) quadrant->
level >= (refine_level - (
int) (which_tree % 3))) {
return 0;
}
return 1;
}
return 1;
}
return 0;
}
return 1;
}
static int
{
if ((
int) quadrant->
level >= refine_level) {
return 0;
}
return 1;
}
return 0;
}
static int
{
if (which_tree == 0) {
ref.x = 3 * u2;
}
else if (which_tree == 1) {
ref.x = 2 * u2;
}
if ((
int) quadrant->
level >= refine_level) {
return 0;
}
if ((which_tree == 0 || which_tree == 1) &&
return 1;
}
return 0;
}
static int
{
return 1;
}
return 0;
}
static int
{
double xyz[3] = { 0, 0, 0 };
double XYZ[3] = { 0, 0, 0 };
double h2 =
xyz[0] = intsize * quadrant->x + h2;
xyz[1] = intsize * quadrant->
y + h2;
#ifdef P4_TO_P8
xyz[2] = intsize * quadrant->z + h2;
#endif
geom->X (geom, which_tree, xyz, XYZ);
return 0;
if (XYZ[2] > 0 && quadrant->
level >= 3)
return 0;
return 1;
}
int
main (int argc, char **argv)
{
int mpiret;
int wrongusage;
unsigned crc;
const char *usage;
mpi_context_t mpi_context, *mpi = &mpi_context;
simple_config_t config;
const simple_regression_t *r;
int nbrick_x = 1, nbrick_y = 1;
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);
usage =
"Arguments: <configuration> <level>\n"
" Configuration can be any of\n"
" unit|brick|three|evil|evil3|pillow|moebius|\n"
" star|cubed|disk|xdisk|ydisk|pdisk|periodic|\n"
" rotwrap|circle|drop|icosahedron|shell2d|disk2d|bowtie|sphere2d\n"
" 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")) {
config = P4EST_CONFIG_UNIT;
}
else if (!strcmp (argv[1], "brick")) {
config = P4EST_CONFIG_BRICK;
}
else if (!strcmp (argv[1], "three")) {
config = P4EST_CONFIG_THREE;
}
else if (!strcmp (argv[1], "evil")) {
config = P4EST_CONFIG_EVIL;
}
else if (!strcmp (argv[1], "evil3")) {
config = P4EST_CONFIG_EVIL3;
}
else if (!strcmp (argv[1], "pillow")) {
config = P4EST_CONFIG_PILLOW;
}
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], "cubed")) {
config = P4EST_CONFIG_CUBED;
}
else if (!strcmp (argv[1], "disk")) {
config = P4EST_CONFIG_DISK;
}
else if (!strcmp (argv[1], "xdisk")) {
config = P4EST_CONFIG_XDISK;
}
else if (!strcmp (argv[1], "ydisk")) {
config = P4EST_CONFIG_YDISK;
}
else if (!strcmp (argv[1], "pdisk")) {
config = P4EST_CONFIG_PDISK;
}
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], "circle")) {
config = P4EST_CONFIG_CIRCLE;
}
else if (!strcmp (argv[1], "drop")) {
config = P4EST_CONFIG_DROP;
}
else if (!strcmp (argv[1], "icosahedron")) {
config = P4EST_CONFIG_ICOSAHEDRON;
}
else if (!strcmp (argv[1], "shell2d")) {
config = P4EST_CONFIG_SHELL2D;
}
else if (!strcmp (argv[1], "disk2d")) {
config = P4EST_CONFIG_DISK2D;
}
else if (!strcmp (argv[1], "bowtie")) {
config = P4EST_CONFIG_BOWTIE;
}
else if (!strcmp (argv[1], "sphere2d")) {
config = P4EST_CONFIG_SPHERE2D;
}
else {
wrongusage = 1;
}
}
if (wrongusage) {
P4EST_GLOBAL_LERROR (usage);
sc_abort_collective ("Usage error");
}
refine_level = atoi (argv[2]);
if (config == P4EST_CONFIG_EVIL) {
refine_fn = refine_evil_fn;
coarsen_fn = coarsen_evil_fn;
}
else if (config == P4EST_CONFIG_EVIL3) {
refine_fn = refine_evil3_fn;
coarsen_fn = NULL;
}
else if (config == P4EST_CONFIG_ICOSAHEDRON) {
refine_fn = refine_icosahedron_fn;
coarsen_fn = NULL;
}
else {
refine_fn = refine_normal_fn;
coarsen_fn = NULL;
}
geom = NULL;
if (config == P4EST_CONFIG_BRICK) {
nbrick_x = argc > 3 ? atoi (argv[3]) : 3;
nbrick_y = argc > 4 ? atoi (argv[4]) : 2;
}
else if (config == P4EST_CONFIG_THREE || config == P4EST_CONFIG_EVIL3) {
}
else if (config == P4EST_CONFIG_PILLOW) {
}
else if (config == P4EST_CONFIG_MOEBIUS) {
}
else if (config == P4EST_CONFIG_STAR) {
}
else if (config == P4EST_CONFIG_CUBED) {
}
else if (config == P4EST_CONFIG_DISK) {
}
else if (config == P4EST_CONFIG_XDISK) {
}
else if (config == P4EST_CONFIG_YDISK) {
}
else if (config == P4EST_CONFIG_PDISK) {
}
else if (config == P4EST_CONFIG_PERIODIC) {
}
else if (config == P4EST_CONFIG_ROTWRAP) {
}
else if (config == P4EST_CONFIG_CIRCLE) {
}
else if (config == P4EST_CONFIG_DROP) {
}
else if (config == P4EST_CONFIG_ICOSAHEDRON) {
double R = 1.0;
if (argc >= 4)
R = atof (argv[3]);
}
else if (config == P4EST_CONFIG_SHELL2D) {
}
else if (config == P4EST_CONFIG_DISK2D) {
}
else if (config == P4EST_CONFIG_BOWTIE) {
}
else if (config == P4EST_CONFIG_SPHERE2D) {
}
else {
}
P4EST_GLOBAL_PRODUCTIONF ("Size of one quadrant: %d bytes\n",
sizeof (user_data_t), init_fn, geom);
if (coarsen_fn != NULL) {
}
#ifdef P4EST_ENABLE_DEBUG
#endif
P4EST_GLOBAL_STATISTICSF ("Tree checksum 0x%08x\n", crc);
if (mpi->mpirank == 0) {
for (r = regression; r->config != P4EST_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;
}
}
if (geom != NULL) {
}
sc_finalize ();
mpiret = sc_MPI_Finalize ();
SC_CHECK_MPI (mpiret);
return 0;
}
int(* p4est_coarsen_t)(p4est_t *p4est, p4est_topidx_t which_tree, p4est_quadrant_t *quadrants[])
Callback function prototype to decide for coarsening.
Definition: p4est.h:223
void p4est_refine(p4est_t *p4est, int refine_recursive, p4est_refine_t refine_fn, p4est_init_t init_fn)
Refine a forest.
void p4est_destroy(p4est_t *p4est)
Destroy a p4est.
void p4est_partition(p4est_t *p4est, int allow_for_coarsening, p4est_weight_t weight_fn)
Equally partition the forest.
void p4est_balance(p4est_t *p4est, p4est_connect_type_t btype, p4est_init_t init_fn)
2:1 balance the size differences of neighboring elements in a forest.
#define P4EST_LAST_OFFSET(l)
The offset of the highest (farthest from the origin) quadrant at level l.
Definition: p4est.h:68
#define P4EST_QUADRANT_INIT(q)
set statically allocated quadrant to defined values
Definition: p4est.h:240
#define P4EST_QUADRANT_LEN(l)
The length of a quadrant of level l.
Definition: p4est.h:61
unsigned p4est_checksum(p4est_t *p4est)
Compute the checksum for a forest.
void p4est_coarsen(p4est_t *p4est, int coarsen_recursive, p4est_coarsen_t coarsen_fn, p4est_init_t init_fn)
Coarsen a forest.
int(* p4est_refine_t)(p4est_t *p4est, p4est_topidx_t which_tree, p4est_quadrant_t *quadrant)
Callback function prototype to decide for refinement.
Definition: p4est.h:213
#define P4EST_ROOT_LEN
The length of a side of the root quadrant.
Definition: p4est.h:58
int32_t p4est_qcoord_t
Typedef for quadrant coordinates.
Definition: p4est_base.h:81
int32_t p4est_topidx_t
Typedef for counting topological entities (trees, tree vertices).
Definition: p4est_base.h:93
void p4est_init(sc_log_handler_t log_handler, int log_threshold)
Registers p4est with the SC Library and sets the logging behavior.
Routines for manipulating quadrants (neighbors, parents, children, etc.)
int p4est_quadrant_is_ancestor(const p4est_quadrant_t *q, const p4est_quadrant_t *r)
Test if a quadrant is an ancestor of another quadrant.
int p4est_quadrant_child_id(const p4est_quadrant_t *q)
Compute the position of this child within its siblings.
int p4est_quadrant_is_equal(const p4est_quadrant_t *q1, const p4est_quadrant_t *q2)
Test if two quadrants have equal Morton indices.
p4est_connectivity_t * p4est_connectivity_new_drop(void)
Create a connectivity structure for a five-trees geometry with a hole.
p4est_connectivity_t * p4est_connectivity_new_corner(void)
Create a connectivity structure for a three-tree mesh around a corner.
p4est_connectivity_t * p4est_connectivity_new_cubed(void)
Create a connectivity structure for the six sides of a unit cube.
void p4est_connectivity_destroy(p4est_connectivity_t *connectivity)
Destroy a connectivity structure.
p4est_connectivity_t * p4est_connectivity_new_disk(int periodic_a, int periodic_b)
Create a connectivity structure for a five-tree flat spherical disk.
p4est_connectivity_t * p4est_connectivity_new_unitsquare(void)
Create a connectivity structure for the unit square.
p4est_connectivity_t * p4est_connectivity_new_disk2d(void)
Create a connectivity structure that maps a 2d disk.
p4est_connectivity_t * p4est_connectivity_new_shell2d(void)
Create a connectivity structure that builds a 2d spherical shell.
p4est_connectivity_t * p4est_connectivity_new_rotwrap(void)
Create a connectivity structure for a periodic unit square.
p4est_connectivity_t * p4est_connectivity_new_brick(int mi, int ni, int periodic_a, int periodic_b)
A rectangular m by n array of trees with configurable periodicity.
p4est_connectivity_t * p4est_connectivity_new_circle(void)
Create a connectivity structure for an donut-like circle.
p4est_connectivity_t * p4est_connectivity_new_pillow(void)
Create a connectivity structure for two trees on top of each other.
p4est_connectivity_t * p4est_connectivity_new_icosahedron(void)
Create a connectivity for mapping the sphere using an icosahedron.
p4est_connectivity_t * p4est_connectivity_new_bowtie(void)
Create a connectivity structure that maps a 2d bowtie structure.
p4est_connectivity_t * p4est_connectivity_new_star(void)
Create a connectivity structure for a six-tree star.
@ P4EST_CONNECT_FULL
= CORNER.
Definition: p4est_connectivity.h:119
p4est_connectivity_t * p4est_connectivity_new_moebius(void)
Create a connectivity structure for a five-tree moebius band.
p4est_connectivity_t * p4est_connectivity_new_periodic(void)
Create a connectivity structure for an all-periodic unit square.
Interface routines with extended capabilities.
p4est_t * p4est_new_ext(sc_MPI_Comm mpicomm, p4est_connectivity_t *connectivity, p4est_locidx_t min_quadrants, int min_level, int fill_uniform, size_t data_size, p4est_init_t init_fn, void *user_pointer)
Create a new forest.
p4est_geometry_t * p4est_geometry_new_shell2d(p4est_connectivity_t *conn, double R2, double R1)
Create a geometry for mapping the annulus.
p4est_geometry_t * p4est_geometry_new_sphere2d(p4est_connectivity_t *conn, double R)
Create sphere geometry associated to cubed connectivity.
p4est_geometry_t * p4est_geometry_new_disk2d(p4est_connectivity_t *conn, double R0, double R1)
Create disk2d geometry associated to disk2d connectivity.
p4est_geometry_t * p4est_geometry_new_icosahedron(p4est_connectivity_t *conn, double R)
Create a geometry for mapping the sphere using 2d connectivity icosahedron.
void p4est_geometry_destroy(p4est_geometry_t *geom)
Can be used to conveniently destroy a geometry structure.
Routines for printing a forest and associated fields to VTK format.
void p4est_vtk_write_file(p4est_t *p4est, p4est_geometry_t *geom, const char *filename)
Write the p4est in VTK format.
This structure holds the 2D inter-tree connectivity information.
Definition: p4est_connectivity.h:190
Encapsulates a custom transformation from tree-local coordinates to user defined physical space.
Definition: p4est_geometry.h:86
The 2D quadrant datatype.
Definition: p4est.h:72
int8_t level
level of refinement
Definition: p4est.h:76
union p4est_quadrant::p4est_quadrant_data p
a union of additional data attached to a quadrant
p4est_qcoord_t y
coordinates
Definition: p4est.h:74
The p4est forest datatype.
Definition: p4est.h:136
void * user_pointer
convenience pointer for users, never touched by p4est
Definition: p4est.h:143
int mpirank
this process's MPI rank
Definition: p4est.h:139
void * user_data
never changed by p4est
Definition: p4est.h:81