Skip to content

Commit

Permalink
Merge pull request #474 from DLR-AMR/uint64_t_to_t8_linearidx_t
Browse files Browse the repository at this point in the history
Replace all uint64_t by t8_linearidx_t for the default-schemes
  • Loading branch information
ililikakis authored Mar 15, 2023
2 parents 348e6d8 + 424f1ff commit 00619e6
Show file tree
Hide file tree
Showing 5 changed files with 28 additions and 25 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -383,7 +383,8 @@ t8_default_scheme_prism_c::t8_element_face_neighbor_inside (const t8_element_t

void
t8_default_scheme_prism_c::t8_element_set_linear_id (t8_element_t *elem,
int level, uint64_t id)
int level,
t8_linearidx_t id)
{
T8_ASSERT (0 <= level && level <= T8_DPRISM_MAXLEVEL);
T8_ASSERT (0 <= id && id < ((t8_linearidx_t) 1) << 3 * level);
Expand Down
32 changes: 16 additions & 16 deletions src/t8_schemes/t8_default/t8_default_prism/t8_dprism_bits.c
Original file line number Diff line number Diff line change
Expand Up @@ -72,10 +72,10 @@ t8_dprism_compare (const t8_dprism_t *p1, const t8_dprism_t *p2)
}

void
t8_dprism_init_linear_id (t8_dprism_t *p, int level, uint64_t id)
t8_dprism_init_linear_id (t8_dprism_t *p, int level, t8_linearidx_t id)
{
uint64_t tri_id = 0;
uint64_t line_id = 0;
t8_linearidx_t tri_id = 0;
t8_linearidx_t line_id = 0;
int i;
int triangles_of_size_i = 1;

Expand Down Expand Up @@ -512,7 +512,7 @@ t8_dprism_first_descendant (const t8_dprism_t *p, t8_dprism_t *s, int level)
t8_dline_first_descendant (&p->line, &s->line, level);
#ifdef T8_ENABLE_DEBUG
{
uint64_t id;
t8_linearidx_t id;
id = t8_dprism_linear_id (p, level);
T8_ASSERT (t8_dprism_linear_id (s, level) == id);
}
Expand Down Expand Up @@ -580,26 +580,26 @@ t8_dprism_vertex_ref_coords (const t8_dprism_t *p, const int vertex,
coords[2] = coords_int[2] / (double) T8_DPRISM_ROOT_LEN;
}

uint64_t
t8_linearidx_t
t8_dprism_linear_id (const t8_dprism_t *p, int level)
{
uint64_t id = 0;
uint64_t tri_id;
uint64_t line_id;
t8_linearidx_t id = 0;
t8_linearidx_t tri_id;
t8_linearidx_t line_id;
int i;
uint64_t prisms_of_size_i = 1;
/*line_level = Num_of_Line_children ^ (level - 1) */
uint64_t line_level;
t8_linearidx_t prisms_of_size_i = 1;
/*lines_at_level = Num_of_Line_children ^ (level - 1) */
t8_linearidx_t lines_at_level;
/*prism_shift = Num_of_Prism_children / Num_of_line-Children * 8 ^ (level - 1) */
uint64_t prism_shift;
t8_linearidx_t prism_shift;
T8_ASSERT (0 <= level && level <= T8_DPRISM_MAXLEVEL);
T8_ASSERT (p->line.level == p->tri.level);
/*id = 0 for root element */
if (level == 0) {
return 0;
}

line_level = sc_intpow64u (T8_DLINE_CHILDREN, level - 1);
lines_at_level = sc_intpow64u (T8_DLINE_CHILDREN, level - 1);
/* *INDENT-OFF* */
prism_shift =
(T8_DPRISM_CHILDREN / T8_DLINE_CHILDREN) *
Expand All @@ -620,10 +620,10 @@ t8_dprism_linear_id (const t8_dprism_t *p, int level)
for (i = level - 1; i >= 0; i--) {
/*The number to add to the id computed via the tri_id is 4*8^(level-i)
*for each plane in a prism of size i*/
id += line_id / line_level * prism_shift;
line_id = (uint64_t) (line_id % line_level);
id += line_id / lines_at_level * prism_shift;
line_id = (line_id % lines_at_level);
prism_shift /= T8_DPRISM_CHILDREN;
line_level /= T8_DLINE_CHILDREN;
lines_at_level /= T8_DLINE_CHILDREN;
}

return id;
Expand Down
4 changes: 2 additions & 2 deletions src/t8_schemes/t8_default/t8_default_prism/t8_dprism_bits.h
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ int t8_dprism_compare (const t8_dprism_t *p1,
* \param [in] level level of uniform grid to be considered.
*/
void t8_dprism_init_linear_id (t8_dprism_t *p, int level,
uint64_t id);
t8_linearidx_t id);

/** Computes the successor of a prism in a uniform grid of level \a level.
* \param [in] p prism whose id will be computed.
Expand Down Expand Up @@ -318,7 +318,7 @@ void t8_dprism_vertex_ref_coords (const t8_dprism_t *p,
* \param [in] p Prism whose id will be computed.
* \return Returns the linear position of this prism on a grid.
*/
uint64_t t8_dprism_linear_id (const t8_dprism_t *p, int level);
t8_linearidx_t t8_dprism_linear_id (const t8_dprism_t *p, int level);

/** Query whether all entries of a prism are in valid ranges.
* A prism is valid if and only if its triangle and line member are valid.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -286,7 +286,8 @@ t8_default_scheme_pyramid_c::t8_element_root_len (const t8_element_t *elem)

void
t8_default_scheme_pyramid_c::t8_element_set_linear_id (t8_element_t *elem,
int level, uint64_t id)
int level,
t8_linearidx_t id)
{
t8_dpyramid_init_linear_id ((t8_dpyramid_t *) elem, level, id);
T8_ASSERT (t8_element_is_valid (elem));
Expand Down
11 changes: 6 additions & 5 deletions src/t8_schemes/t8_default/t8_default_tet/t8_default_tet.c
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,8 @@ typedef t8_dtet_t t8_default_tet_t;

/* This function is used by other element functions and we thus need to
* declare it up here */
static uint64_t t8_default_tet_get_linear_id (const t8_element_t *elem,
int level);
static t8_linearidx_t t8_default_tet_get_linear_id (const t8_element_t *elem,
int level);

static size_t
t8_default_tet_size (void)
Expand Down Expand Up @@ -133,15 +133,16 @@ t8_default_tet_nca (const t8_element_t *elem1,
}

static void
t8_default_tet_set_linear_id (t8_element_t *elem, int level, uint64_t id)
t8_default_tet_set_linear_id (t8_element_t *elem, int level,
t8_linearidx_t id)
{
T8_ASSERT (0 <= level && level <= T8_DTET_MAXLEVEL);
T8_ASSERT (0 <= id && id < ((uint64_t) 1) << 3 * level);
T8_ASSERT (0 <= id && id < ((t8_linearidx_t) 1) << 3 * level);

t8_dtet_init_linear_id ((t8_default_tet_t *) elem, id, level);
}

static uint64_t
static t8_linearidx_t
t8_default_tet_get_linear_id (const t8_element_t *elem, int level)
{
T8_ASSERT (0 <= level && level <= T8_DTET_MAXLEVEL);
Expand Down

0 comments on commit 00619e6

Please sign in to comment.