Skip to content

Commit

Permalink
Make periodic disk configurable in x and y.
Browse files Browse the repository at this point in the history
  • Loading branch information
cburstedde committed Sep 10, 2018
1 parent 7fb7cdb commit d8bfbf2
Show file tree
Hide file tree
Showing 6 changed files with 45 additions and 16 deletions.
4 changes: 2 additions & 2 deletions example/mesh/mesh2.c
Original file line number Diff line number Diff line change
Expand Up @@ -506,10 +506,10 @@ main (int argc, char **argv)
connectivity = p4est_connectivity_new_cubed ();
}
else if (config == P4EST_CONFIG_DISK) {
connectivity = p4est_connectivity_new_disk (0);
connectivity = p4est_connectivity_new_disk (0, 0);
}
else if (config == P4EST_CONFIG_PDISK) {
connectivity = p4est_connectivity_new_disk (1);
connectivity = p4est_connectivity_new_disk (1, 1);
}
#else
else if (config == P8EST_CONFIG_PERIODIC) {
Expand Down
4 changes: 2 additions & 2 deletions example/simple/simple2.c
Original file line number Diff line number Diff line change
Expand Up @@ -309,10 +309,10 @@ main (int argc, char **argv)
connectivity = p4est_connectivity_new_cubed ();
}
else if (config == P4EST_CONFIG_DISK) {
connectivity = p4est_connectivity_new_disk (0);
connectivity = p4est_connectivity_new_disk (0, 0);
}
else if (config == P4EST_CONFIG_PDISK) {
connectivity = p4est_connectivity_new_disk (1);
connectivity = p4est_connectivity_new_disk (1, 1);
}
else if (config == P4EST_CONFIG_PERIODIC) {
connectivity = p4est_connectivity_new_periodic ();
Expand Down
29 changes: 25 additions & 4 deletions src/p4est_connectivity.c
Original file line number Diff line number Diff line change
Expand Up @@ -1692,13 +1692,34 @@ p4est_connectivity_new_disk_nonperiodic (void)
}

p4est_connectivity_t *
p4est_connectivity_new_disk (int periodic)
p4est_connectivity_new_disk (int periodic_a, int periodic_b)
{
p4est_topidx_t nc;
p4est_connectivity_t *conn = p4est_connectivity_new_disk_nonperiodic ();

/* periodic boundary is not yet supported */
P4EST_ASSERT (!periodic);
if (!periodic_a && !periodic_b) {
return conn;
}
P4EST_ASSERT (conn->num_corners == 0);
P4EST_ASSERT (conn->tree_to_corner == NULL);
P4EST_ASSERT (conn->corner_to_tree == NULL);
P4EST_ASSERT (conn->corner_to_corner == NULL);
P4EST_FREE (conn->ctt_offset);

/* allocate arrays of proper size */
nc = conn->num_corners = (periodic_a ^ periodic_b) ? 2 : 1;
conn->tree_to_corner = P4EST_ALLOC (p4est_topidx_t, 5 * 4);
conn->ctt_offset = P4EST_ALLOC (p4est_topidx_t, nc + 1);
conn->corner_to_tree = P4EST_ALLOC (p4est_topidx_t, 8);
conn->corner_to_corner = P4EST_ALLOC (int8_t, 8);

return p4est_connectivity_new_disk_nonperiodic ();
/* fill new arrays with proper data */
SC_ABORT_NOT_REACHED ();

/* return modified connectivity */
P4EST_ASSERT (p4est_connectivity_is_valid (conn));
return conn;
}

#endif /* !P4_TO_P8 */
Expand Down Expand Up @@ -2432,7 +2453,7 @@ p4est_connectivity_new_byname (const char *name)
return p4est_connectivity_new_cubed ();
}
else if (!strcmp (name, "disk")) {
return p4est_connectivity_new_disk (0);
return p4est_connectivity_new_disk (0, 0);
}
else if (!strcmp (name, "moebius")) {
return p4est_connectivity_new_moebius ();
Expand Down
15 changes: 10 additions & 5 deletions src/p4est_connectivity.h
Original file line number Diff line number Diff line change
Expand Up @@ -411,12 +411,17 @@ p4est_connectivity_t *p4est_connectivity_new_cubed (void);
* 1 2 3
* 0.
*
* \param [in] periodic Bool p to make the disk all-periodic,
* which creates a 2D torus topology similar to
* \ref p4est_connectivity_new_brick (1, 1, p, p).
* Currently, only false is supported!
* The outside x faces may be identified topologically.
* The outside y faces may be identified topologically.
* Both identifications may be specified simultaneously.
* The shape and peridocicity are the same as those obtained with
* \ref p4est_connectivity_new_brick (1, 1, periodic_a, periodic_b).
*
* \param [in] periodic_a Bool to make disk periodic in x direction.
* \param [in] periodic_b Bool to make disk periodic in y direction.
*/
p4est_connectivity_t *p4est_connectivity_new_disk (int periodic);
p4est_connectivity_t *p4est_connectivity_new_disk (int periodic_a,
int periodic_b);

/** An m by n array with periodicity in x and y if periodic_a and periodic_b
* are true, respectively.
Expand Down
4 changes: 2 additions & 2 deletions src/p4est_wrap.c
Original file line number Diff line number Diff line change
Expand Up @@ -326,8 +326,8 @@ p4est_wrap_new_cubed (sc_MPI_Comm mpicomm, int initial_level)
p4est_wrap_t *
p4est_wrap_new_disk (sc_MPI_Comm mpicomm, int initial_level, int p)
{
return p4est_wrap_new_conn (mpicomm,
p4est_connectivity_new_disk (p), initial_level);
return p4est_wrap_new_conn
(mpicomm, p4est_connectivity_new_disk (p, p), initial_level);
}

#else
Expand Down
5 changes: 4 additions & 1 deletion test/test_conn_reduce2.c
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,10 @@ main (int argc, char *argv[])
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 (0), "disk");
test_reduce (p4est_connectivity_new_disk (0, 0), "disk");
test_reduce (p4est_connectivity_new_disk (0, 1), "xdisk");
test_reduce (p4est_connectivity_new_disk (1, 0), "ydisk");
test_reduce (p4est_connectivity_new_disk (1, 1), "pdisk");
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");
Expand Down

0 comments on commit d8bfbf2

Please sign in to comment.