Skip to content

Commit

Permalink
Feature triangle: store local first child on rank
Browse files Browse the repository at this point in the history
  • Loading branch information
cburstedde committed Jul 21, 2024
1 parent c370d5e commit 02201db
Show file tree
Hide file tree
Showing 3 changed files with 30 additions and 11 deletions.
13 changes: 12 additions & 1 deletion src/p4est_tnodes.c
Original file line number Diff line number Diff line change
Expand Up @@ -1336,6 +1336,7 @@ p4est_tnodes_new_Q2_P1 (p4est_t *p4est, p4est_lnodes_t * lnodes,
tnodes = P4EST_ALLOC_ZERO (p4est_tnodes_t, 1);
tnodes->lnodes = lnodes;
tnodes->lnodes_owned = 0;
tnodes->local_first_child = -1;

/* prepare coordinate allocation */
tnodes->coordinates = sc_array_new (3 * sizeof (double));
Expand Down Expand Up @@ -1389,14 +1390,22 @@ p4est_tnodes_new_Q2_P1 (p4est_t *p4est, p4est_lnodes_t * lnodes,
tnodes->local_element_offset[0] = 0;
for (el = 0; el < ne; enodes += P4EST_INSUL, ++el) {

if (construction_flags & P4EST_TNODES_STORE_LEVELS) {
if ((construction_flags & P4EST_TNODES_STORE_LEVELS) || tree == NULL) {
/* track tree number and quadrant level to find element level */
P4EST_ASSERT (el <= ecumul);
if (el == ecumul) {
p4est_quadrant_t *quadrant;

/* enter next local tree */
tree = p4est_tree_array_index (p4est->trees, ++tt);
ecumul += (p4est_locidx_t) tree->quadrants.elem_count;
P4EST_ASSERT (el < ecumul);
if (tnodes->local_first_child < 0) {
quadrant = p4est_quadrant_array_index (&tree->quadrants, 0);
tnodes->local_first_child = p4est_quadrant_child_id (quadrant);
}
}
P4EST_ASSERT (tree != NULL);

/* retrieve and assign proper element level */
level = (p4est_quadrant_array_index
Expand Down Expand Up @@ -1658,6 +1667,8 @@ p4est_tnodes_new_Q2_P1 (p4est_t *p4est, p4est_lnodes_t * lnodes,

/* synchronize simplex counts in parallel */
p4est_tnodes_simplex_counts (p4est, tnodes);
P4EST_ASSERT ((tnodes->local_first_child == -1) ==
(tnodes->local_first_tree > tnodes->local_last_tree));
P4EST_GLOBAL_PRODUCTIONF
("Done " P4EST_STRING "_tnodes_new_Q2 with %lld global simplices\n",
(long long) tnodes->global_tcount);
Expand Down
12 changes: 8 additions & 4 deletions src/p4est_tnodes.h
Original file line number Diff line number Diff line change
Expand Up @@ -47,10 +47,12 @@ typedef enum p4est_tnodes_flags
/** Generate geometric coordinates for nodes on the tree boundary.
* Since the \ref p4est_connectivity may be periodic, the same lnode
* entry (see \ref p4est_lnodes) may be referenced from more than one
* coordinate location. If periodicity is not expected, this flag is not
* needed. Otherwise, setting it disambiguates the coordinates between
* multiple instances for the same lnode entry. This enables for example
* the visualization of the periodic unit square as a factual square. */
* coordinate location. If periodicity is not expected, and the geometry
* is continuous across tree boundaries, this flag is not needed.
* Otherwise, setting it disambiguates the coordinates between multiple
* instances for the same lnode entry. This enables for example the
* visualization of the periodic unit square as a factual square, or the
* setup of geometries that are artificially mapped for display. */
P4EST_TNODES_COORDS_SEPARATE = 0x01,

/** Allocate and fill local_element_level array in \ref p4est_tnodes. */
Expand Down Expand Up @@ -96,6 +98,8 @@ typedef struct p4est_tnodes
* Array may be NULL if the information is not provided. */
int8_t *local_element_level;

int local_first_child; /**< First child id on
process, or -1 if empty. */
p4est_topidx_t local_first_tree; /**< First local tree on process,
-1 if process has no elements. */
p4est_topidx_t local_last_tree; /**< Last local tree on process,
Expand Down
16 changes: 10 additions & 6 deletions src/p8est_tnodes.h
Original file line number Diff line number Diff line change
Expand Up @@ -45,12 +45,14 @@ typedef enum p8est_tnodes_flags
P8EST_TNODES_FLAGS_NONE = 0,

/** Generate geometric coordinates for nodes on the tree boundary.
* Since the \ref p4est_connectivity may be periodic, the same lnode
* entry (see \ref p4est_lnodes) may be referenced from more than one
* coordinate location. If periodicity is not expected, this flag is not
* needed. Otherwise, setting it disambiguates the coordinates between
* multiple instances for the same lnode entry. This enables for example
* the visualization of the periodic unit square as a factual square. */
* Since the \ref p8est_connectivity may be periodic, the same lnode
* entry (see \ref p8est_lnodes) may be referenced from more than one
* coordinate location. If periodicity is not expected, and the geometry
* is continuous across tree boundaries, this flag is not needed.
* Otherwise, setting it disambiguates the coordinates between multiple
* instances for the same lnode entry. This enables for example the
* visualization of the periodic unit square as a factual square, or the
* setup of geometries that are artificially mapped for display. */
P8EST_TNODES_COORDS_SEPARATE = 0x01,

/** Allocate and fill local_element_level array in \ref p8est_tnodes. */
Expand Down Expand Up @@ -86,6 +88,8 @@ typedef struct p8est_tnodes
* Array may be NULL if the information is not provided. */
int8_t *local_element_level;

int local_first_child; /**< First child id on
process, or -1 if empty. */
p4est_topidx_t local_first_tree; /**< First local tree on process,
-1 if process has no elements. */
p4est_topidx_t local_last_tree; /**< Last local tree on process,
Expand Down

0 comments on commit 02201db

Please sign in to comment.