Skip to content

Commit

Permalink
Numbers in connectivity_new_disk are right
Browse files Browse the repository at this point in the history
  • Loading branch information
cburstedde committed Sep 10, 2018
1 parent d8bfbf2 commit 0d45850
Show file tree
Hide file tree
Showing 2 changed files with 51 additions and 8 deletions.
51 changes: 47 additions & 4 deletions src/p4est_connectivity.c
Original file line number Diff line number Diff line change
Expand Up @@ -1694,7 +1694,12 @@ p4est_connectivity_new_disk_nonperiodic (void)
p4est_connectivity_t *
p4est_connectivity_new_disk (int periodic_a, int periodic_b)
{
const int8_t in_ctc[8] = {0, 0, 1, 1, 2, 2, 3, 3};
const p4est_topidx_t in_ctt[8] = {0, 1, 0, 3, 1, 4, 3, 4};
int i, j;
int8_t *ctc;
p4est_topidx_t nc;
p4est_topidx_t *ttc, *ctt;
p4est_connectivity_t *conn = p4est_connectivity_new_disk_nonperiodic ();

/* periodic boundary is not yet supported */
Expand All @@ -1708,14 +1713,52 @@ p4est_connectivity_new_disk (int periodic_a, int periodic_b)
P4EST_FREE (conn->ctt_offset);

/* allocate arrays of proper size */
ttc = conn->tree_to_corner = P4EST_ALLOC (p4est_topidx_t, 5 * 4);
ctt = conn->corner_to_tree = P4EST_ALLOC (p4est_topidx_t, 8);
ctc = conn->corner_to_corner = P4EST_ALLOC (int8_t, 8);
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);

/* fill new arrays with proper data */
SC_ABORT_NOT_REACHED ();
conn->ctt_offset[0] = 0;
if (nc == 1) {
conn->ctt_offset[1] = 8;
}
else {
P4EST_ASSERT (nc == 2);
conn->ctt_offset[1] = 4;
conn->ctt_offset[2] = 8;
}
for (i = 0; i < 8; ++i) {
/* we have either 1 or 2 connecting corners */
conn->corner_to_corner[0] = i < 4 || nc == 1 ? 0 : 1;
}
if (periodic_a) {
/* tree 1, face 0 meets tree 3, face 1 */
conn->tree_to_tree[4 * 1 + 0] = 3;
conn->tree_to_face[4 * 1 + 0] = 1;
conn->tree_to_tree[4 * 3 + 1] = 1;
conn->tree_to_face[4 * 3 + 1] = 0;
}
if (periodic_b) {
/* tree 0, face 2 meets tree 4, face 3 */
conn->tree_to_tree[4 * 0 + 2] = 4;
conn->tree_to_face[4 * 0 + 2] = 3;
conn->tree_to_tree[4 * 4 + 3] = 0;
conn->tree_to_face[4 * 4 + 3] = 2;
}
/* assign corner trees */
memset (ttc, -1, 5 * 4 * sizeof (p4est_topidx_t));
ttc[4 * 0 + 0] = ttc[4 * 1 + 0] = 0;
ttc[4 * 0 + 1] = ttc[4 * 3 + 1] = !periodic_a;
ttc[4 * 1 + 2] = ttc[4 * 4 + 2] = !periodic_b;
ttc[4 * 3 + 3] = ttc[4 * 4 + 3] = !periodic_a || !periodic_b;
/* assign corner trees and corners */
for (i = 0; i < 8; ++i) {
j = i < 2 || i >= 6 ? i : !periodic_a ? ((i - 2) ^ 2) + 2 : i;
ctt[i] = in_ctt[j];
ctc[i] = in_ctc[j];
}

/* return modified connectivity */
P4EST_ASSERT (p4est_connectivity_is_valid (conn));
Expand Down
8 changes: 4 additions & 4 deletions test/test_conn_reduce2.c
Original file line number Diff line number Diff line change
Expand Up @@ -64,10 +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, 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_disk (0, 0), "disk00");
test_reduce (p4est_connectivity_new_disk (0, 1), "disk01");
test_reduce (p4est_connectivity_new_disk (1, 0), "disk11");
test_reduce (p4est_connectivity_new_disk (1, 1), "disk11");
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 0d45850

Please sign in to comment.