Пример #1
0
static void
test_periodic (p8est_connectivity_t * conn)
{
  int                 i;
  int                 iface, nface;
  int                 iedge, icorner;
  int                 ft[9];
  size_t              zz;
  p4est_topidx_t      itree, ntree;
  p8est_edge_info_t   ei;
  p8est_edge_transform_t *et;
  p8est_corner_info_t ci;
  p8est_corner_transform_t *ct;
  sc_array_t         *eta, *cta;

  itree = 0;
  for (iface = 0; iface < 6; ++iface) {
    ntree = p8est_find_face_transform (conn, itree, iface, ft);
    nface = p8est_face_dual[iface];
    SC_CHECK_ABORT (ntree == itree, "PF tree");
    for (i = 0; i < 3; ++i) {
      SC_CHECK_ABORTF (ft[i] == ft[i + 3], "PF axis %d", i);
    }
    SC_CHECK_ABORT (ft[6] == 0 && ft[7] == 0, "PF reverse");
    SC_CHECK_ABORT (ft[8] == 2 * (iface % 2) + nface % 2, "PF code");
  }

  eta = &ei.edge_transforms;
  sc_array_init (eta, sizeof (p8est_edge_transform_t));
  for (iedge = 0; iedge < 12; ++iedge) {
    p8est_find_edge_transform (conn, itree, iedge, &ei);
    SC_CHECK_ABORT ((int) ei.iedge == iedge, "PE ei");
    SC_CHECK_ABORT (eta->elem_count == 1, "PE count");
    for (zz = 0; zz < eta->elem_count; ++zz) {
      et = p8est_edge_array_index (eta, zz);
      SC_CHECK_ABORT (et->ntree == itree, "PE tree");
      SC_CHECK_ABORT ((int) et->nedge + iedge == 8 * (iedge / 4) + 3,
                      "PE edge");
      SC_CHECK_ABORT (et->nflip == 0, "PE flip");
      SC_CHECK_ABORT (et->corners == et->nedge % 4, "PE corners");
      SC_CHECK_ABORT ((int) et->naxis[0] == iedge / 4 &&
                      et->naxis[1] < et->naxis[2] &&
                      et->naxis[0] + et->naxis[1] + et->naxis[2] == 3,
                      "PE axis");
    }
  }
  sc_array_reset (eta);

  cta = &ci.corner_transforms;
  sc_array_init (cta, sizeof (p8est_corner_transform_t));
  for (icorner = 0; icorner < 8; ++icorner) {
    p8est_find_corner_transform (conn, itree, icorner, &ci);
    SC_CHECK_ABORT ((int) ci.icorner == icorner, "PC ci");
    SC_CHECK_ABORT (cta->elem_count == 1, "PC count");
    for (zz = 0; zz < cta->elem_count; ++zz) {
      ct = p8est_corner_array_index (cta, zz);
      SC_CHECK_ABORT (ct->ntree == itree, "PC tree");
      SC_CHECK_ABORT (ct->ncorner + icorner == 7, "PC corner");
    }
  }
  sc_array_reset (cta);
}
Пример #2
0
static void
test_rotwrap (p8est_connectivity_t * conn)
{
  int                 i;
  int                 iface, nface;
  int                 iedge, icorner;
  int                 ft[9];
  size_t              zz;
  p4est_topidx_t      itree, ntree;
  p8est_edge_info_t   ei;
  p8est_edge_transform_t *et;
  p8est_corner_info_t ci;
  p8est_corner_transform_t *ct;
  sc_array_t         *eta, *cta;

  itree = 0;
  for (iface = 0; iface < 6; ++iface) {
    ntree = p8est_find_face_transform (conn, itree, iface, ft);
    if (iface == 2 || iface == 3) {
      SC_CHECK_ABORT (ntree == -1, "RF tree");
      continue;
    }
    nface = p8est_face_dual[iface];
    SC_CHECK_ABORT (ntree == itree, "RF tree");
    if (iface == 0 || iface == 1) {
      for (i = 0; i < 3; ++i) {
        SC_CHECK_ABORTF (ft[i] == (i + 1) % 3, "RFA axis A%d", i);
        SC_CHECK_ABORTF (ft[i] == ft[i + 3], "RFA axis B%d", i);
      }
      SC_CHECK_ABORT (ft[6] == 0 && ft[7] == 0, "RFA reverse");
    }
    else {
      for (i = 0; i < 3; ++i) {
        SC_CHECK_ABORTF (ft[i] == i, "RFB axis A%d", i);
      }
      SC_CHECK_ABORT (ft[0] == ft[4], "RFB axis B0");
      SC_CHECK_ABORT (ft[1] == ft[3], "RFB axis B1");
      SC_CHECK_ABORT (ft[2] == ft[5], "RFB axis B2");
      SC_CHECK_ABORT (ft[6] == (iface != 4) &&
                      ft[7] == (iface != 5), "RFB reverse");
    }
    SC_CHECK_ABORT (ft[8] == 2 * (iface % 2) + nface % 2, "RF code");
  }

  eta = &ei.edge_transforms;
  sc_array_init (eta, sizeof (p8est_edge_transform_t));
  for (iedge = 0; iedge < 12; ++iedge) {
    p8est_find_edge_transform (conn, itree, iedge, &ei);
    SC_CHECK_ABORT ((int) ei.iedge == iedge, "RE ei");
    SC_CHECK_ABORT ((int) eta->elem_count == 2 - (iedge / 4), "RE count AB");
    for (zz = 0; zz < eta->elem_count; ++zz) {
      et = p8est_edge_array_index (eta, zz);
      SC_CHECK_ABORT (et->ntree == itree, "RE tree");
      SC_CHECK_ABORT ((int) et->nedge == rotwrap_edges[iedge][zz], "RE edge");
      SC_CHECK_ABORT ((int) et->nflip == rotwrap_flip[iedge][zz], "RE flip");
      SC_CHECK_ABORT (et->corners == et->nedge % 4, "RE corners");
      SC_CHECK_ABORT ((int) et->naxis[0] == rotwrap_axes[iedge][zz] &&
                      et->naxis[1] < et->naxis[2] &&
                      et->naxis[0] + et->naxis[1] + et->naxis[2] == 3,
                      "RE axis");
    }
  }
  sc_array_reset (eta);

  cta = &ci.corner_transforms;
  sc_array_init (cta, sizeof (p8est_corner_transform_t));
  for (icorner = 0; icorner < 8; ++icorner) {
    p8est_find_corner_transform (conn, itree, icorner, &ci);
    SC_CHECK_ABORT ((int) ci.icorner == icorner, "RC ci");
    SC_CHECK_ABORT (cta->elem_count == 2, "RC count");
    for (zz = 0; zz < cta->elem_count; ++zz) {
      ct = p8est_corner_array_index (cta, zz);
      SC_CHECK_ABORT (ct->ntree == itree, "RC tree");
      SC_CHECK_ABORT ((int) ct->ncorner == rotwrap_corners[icorner][zz],
                      "RC corner");
    }
  }
  sc_array_reset (cta);
}
Пример #3
0
static void
test_weird (void)
{
  const p4est_topidx_t num_edges = 1, num_ett = 2;
  const p4est_topidx_t num_corners = 1, num_ctt = 4;
  int                 i;
  size_t              zz;
  p8est_edge_info_t   ei;
  p8est_edge_transform_t *et;
  p8est_corner_info_t ci;
  p8est_corner_transform_t *ct;
  sc_array_t         *eta, *cta;
  p8est_connectivity_t *conn;

  conn = p8est_connectivity_new (0, 1,
                                 num_edges, num_ett, num_corners, num_ctt);
  for (i = 0; i < 6; ++i) {
    conn->tree_to_tree[i] = 0;
    conn->tree_to_face[i] = (int8_t) i;
  }
  conn->tree_to_face[4] = 5;
  conn->tree_to_face[5] = 4;

  for (i = 0; i < 12; ++i) {
    conn->tree_to_edge[i] = -1;
  }
  conn->tree_to_edge[5] = 0;
  conn->tree_to_edge[7] = 0;
  conn->edge_to_tree[0] = 0;
  conn->edge_to_tree[1] = 0;
  conn->edge_to_edge[0] = 5;
  conn->edge_to_edge[1] = 19;
  conn->ett_offset[0] = 0;

  for (i = 0; i < 8; ++i) {
    conn->tree_to_corner[i] = -1;
  }
  conn->tree_to_corner[0] = 0;
  conn->tree_to_corner[1] = 0;
  conn->tree_to_corner[4] = 0;
  conn->tree_to_corner[5] = 0;
  conn->corner_to_tree[0] = 0;
  conn->corner_to_tree[1] = 0;
  conn->corner_to_tree[2] = 0;
  conn->corner_to_tree[3] = 0;
  conn->corner_to_corner[0] = 0;
  conn->corner_to_corner[1] = 1;
  conn->corner_to_corner[2] = 4;
  conn->corner_to_corner[3] = 5;
  conn->ctt_offset[0] = 0;

  P4EST_ASSERT (p8est_connectivity_is_valid (conn));

  eta = &ei.edge_transforms;
  sc_array_init (eta, sizeof (p8est_edge_transform_t));
  for (i = 0; i < 2; ++i) {
    p8est_find_edge_transform (conn, 0, weird_edges[i][0], &ei);
    SC_CHECK_ABORT ((int) ei.iedge == weird_edges[i][0], "WE ei");
    SC_CHECK_ABORT (eta->elem_count == 1, "WE count A");
    for (zz = 0; zz < eta->elem_count; ++zz) {
      et = p8est_edge_array_index (eta, zz);
      SC_CHECK_ABORT (et->ntree == 0, "WE tree");
      SC_CHECK_ABORT ((int) et->nedge == weird_edges[i][1], "WE edge");
      SC_CHECK_ABORT (et->nflip == 1, "WE flip");
      SC_CHECK_ABORT (et->corners == et->nedge % 4, "WE corners");
      SC_CHECK_ABORT (et->naxis[0] == 1 && et->naxis[1] == 0 &&
                      et->naxis[2] == 2, "WE axis");
    }
  }
  sc_array_reset (eta);

  cta = &ci.corner_transforms;
  sc_array_init (cta, sizeof (p8est_corner_transform_t));
  for (i = 0; i < 8; ++i) {
    p8est_find_corner_transform (conn, 0, i, &ci);
    SC_CHECK_ABORT ((int) ci.icorner == i, "WC ci");
    SC_CHECK_ABORT ((int) cta->elem_count == 2 - (i & 0x02), "WC count");
    for (zz = 0; zz < cta->elem_count; ++zz) {
      ct = p8est_corner_array_index (cta, zz);
      SC_CHECK_ABORT (ct->ntree == 0, "WC tree");
      SC_CHECK_ABORT ((size_t) ct->ncorner == 4 * zz + !(i % 2), "WC corner");
    }
  }
  sc_array_reset (cta);

  p8est_connectivity_destroy (conn);
}
Пример #4
0
void
p8est_quadrant_edge_neighbor_extra (const p4est_quadrant_t * q, p4est_topidx_t
                                    t, int edge, sc_array_t * quads,
                                    sc_array_t * treeids,
                                    p4est_connectivity_t * conn)
{
  p4est_quadrant_t    temp;
  p4est_quadrant_t   *qp;
  p4est_topidx_t     *tp;
  int                 face;
  p8est_edge_info_t   ei;
  p8est_edge_transform_t *et;
  sc_array_t         *eta;
  size_t              etree;

  eta = &ei.edge_transforms;

  P4EST_ASSERT (SC_ARRAY_IS_OWNER (quads));
  P4EST_ASSERT (quads->elem_count == 0);
  P4EST_ASSERT (quads->elem_size == sizeof (p4est_quadrant_t));
  P4EST_ASSERT (SC_ARRAY_IS_OWNER (treeids));
  P4EST_ASSERT (treeids->elem_count == 0);
  P4EST_ASSERT (treeids->elem_size == sizeof (p4est_topidx_t));

  p8est_quadrant_edge_neighbor (q, edge, &temp);
  if (p4est_quadrant_is_inside_root (&temp)) {
    qp = p4est_quadrant_array_push (quads);
    *qp = temp;
    tp = (p4est_topidx_t *) sc_array_push (treeids);
    *tp = t;
    return;
  }

  if (!p8est_quadrant_is_outside_edge (&temp)) {
    qp = p4est_quadrant_array_push (quads);
    tp = (p4est_topidx_t *) sc_array_push (treeids);

    face = p8est_edge_faces[edge][0];
    p4est_quadrant_face_neighbor (q, face, &temp);
    if (p4est_quadrant_is_inside_root (&temp)) {
      face = p8est_edge_faces[edge][1];
      *tp = p8est_quadrant_face_neighbor_extra (&temp, t, face, qp, conn);
      if (*tp == -1) {
        qp = (p4est_quadrant_t *) sc_array_pop (quads);
        tp = (p4est_topidx_t *) sc_array_pop (treeids);
      }
      return;
    }
    face = p8est_edge_faces[edge][1];
    p4est_quadrant_face_neighbor (q, face, &temp);
    P4EST_ASSERT (p4est_quadrant_is_inside_root (&temp));
    face = p8est_edge_faces[edge][0];
    *tp = p8est_quadrant_face_neighbor_extra (&temp, t, face, qp, conn);
    if (*tp == -1) {
      qp = (p4est_quadrant_t *) sc_array_pop (quads);
      tp = (p4est_topidx_t *) sc_array_pop (treeids);
    }
    return;
  }
  sc_array_init (eta, sizeof (p8est_edge_transform_t));
  p8est_find_edge_transform (conn, t, edge, &ei);
  sc_array_resize (quads, eta->elem_count);
  sc_array_resize (treeids, eta->elem_count);
  for (etree = 0; etree < eta->elem_count; etree++) {
    qp = p4est_quadrant_array_index (quads, etree);
    tp = (p4est_topidx_t *) sc_array_index (treeids, etree);
    et = p8est_edge_array_index (eta, etree);
    p8est_quadrant_transform_edge (&temp, qp, &ei, et, 1);
    *tp = et->ntree;
  }
  sc_array_reset (eta);
}