Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Cleanup more #1437

Open
wants to merge 5 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 4 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions src/t8_cmesh/t8_cmesh.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -445,9 +445,9 @@ t8_cmesh_get_attribute (const t8_cmesh_t cmesh, const int package_id, const int

t8_gloidx_t *
t8_cmesh_get_attribute_gloidx_array (const t8_cmesh_t cmesh, const int package_id, const int key,
const t8_locidx_t ltree_id, [[maybe_unused]] const size_t data_count)
const t8_locidx_t ltree_id,
[[maybe_unused]] const size_t data_count) //TODO: remove data_count
{
T8_ASSERT (0 <= data_count);
return (t8_gloidx_t *) t8_cmesh_get_attribute (cmesh, package_id, key, ltree_id);
}

Expand Down
6 changes: 6 additions & 0 deletions src/t8_cmesh/t8_cmesh_examples.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -696,17 +696,20 @@ t8_cmesh_new_hypercube (t8_eclass_t eclass, sc_MPI_Comm comm, int do_bcast, int
if (periodic) {
t8_cmesh_set_join (cmesh, 0, 0, 4, 5, 0);
}
[[fallthrough]];
case T8_ECLASS_QUAD:
vertices[3] = 3;
vertices[2] = 2;
if (periodic) {
t8_cmesh_set_join (cmesh, 0, 0, 2, 3, 0);
}
[[fallthrough]];
case T8_ECLASS_LINE:
vertices[1] = 1;
if (periodic) {
t8_cmesh_set_join (cmesh, 0, 0, 0, 1, 0);
}
[[fallthrough]];
case T8_ECLASS_VERTEX:
vertices[0] = 0;
t8_cmesh_new_translate_vertices_to_attributes (vertices, vertices_coords, attr_vertices,
Expand Down Expand Up @@ -1268,10 +1271,13 @@ t8_cmesh_new_hypercube_pad_ext (const t8_eclass_t eclass, sc_MPI_Comm comm, cons
switch (dim) {
case 0:
polygons_x = 1;
[[fallthrough]];
case 1:
polygons_y = 1;
[[fallthrough]];
case 2:
polygons_z = 1;
[[fallthrough]];
default:
T8_ASSERT (polygons_x > 0);
T8_ASSERT (polygons_y > 0);
Expand Down
7 changes: 3 additions & 4 deletions src/t8_data/t8_shmem.c
Original file line number Diff line number Diff line change
Expand Up @@ -56,8 +56,7 @@ t8_shmem_array_is_writing_possible (const t8_shmem_array_t array)
int
t8_shmem_array_is_initialized (const t8_shmem_array_t array)
{
return (array != NULL && array->elem_size > 0 && array->elem_count >= 0 && array->array != NULL
&& array->comm != sc_MPI_COMM_NULL);
return (array != NULL && array->elem_size > 0 && array->array != NULL && array->comm != sc_MPI_COMM_NULL);
}
#endif

Expand Down Expand Up @@ -465,7 +464,7 @@ t8_shmem_array_index (t8_shmem_array_t array, size_t index)
{
T8_ASSERT (t8_shmem_array_is_initialized (array));
T8_ASSERT (!t8_shmem_array_is_writing_possible (array));
T8_ASSERT (0 <= index && index < array->elem_count);
T8_ASSERT (index < array->elem_count);

return ((char *) array->array) + index * array->elem_size;
}
Expand All @@ -475,7 +474,7 @@ t8_shmem_array_index_for_writing (t8_shmem_array_t array, size_t index)
{
T8_ASSERT (t8_shmem_array_is_initialized (array));
T8_ASSERT (t8_shmem_array_is_writing_possible (array));
T8_ASSERT (0 <= index && index < array->elem_count);
T8_ASSERT (index < array->elem_count);

return ((char *) array->array) + index * array->elem_size;
}
Expand Down
3 changes: 2 additions & 1 deletion src/t8_forest/t8_forest.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -1038,6 +1038,7 @@ t8_forest_element_face_normal (t8_forest_t forest, t8_locidx_t ltreeid, const t8
}
}
#endif
[[fallthrough]];
case T8_ECLASS_TRIANGLE: {
/* We construct the normal as the cross product of two spanning
* vectors for the triangle*/
Expand Down Expand Up @@ -3565,7 +3566,7 @@ static int
t8_forest_compare_elem_tree (const void *lelement_id, const void *ltree)
{
t8_locidx_t leid = *(const t8_locidx_t *) lelement_id;
const t8_tree_t tree = (const t8_tree_t) ltree;
const t8_tree_t tree = (t8_tree_t) ltree;

if (tree->elements_offset > leid) {
/* We have to look further to the left */
Expand Down
1 change: 0 additions & 1 deletion src/t8_forest/t8_forest_ghost.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -774,7 +774,6 @@ t8_forest_ghost_fill_remote (t8_forest_t forest, t8_forest_ghost_t ghost, int gh
size_t iowner;
/* Construct the owners at the face of the neighbor element */
t8_forest_element_owners_at_neigh_face (forest, itree, elem, iface, &owners);
T8_ASSERT (owners.elem_count >= 0);
/* Iterate over all owners and if any is not the current process,
* add this element as remote */
for (iowner = 0; iowner < owners.elem_count; iowner++) {
Expand Down
2 changes: 0 additions & 2 deletions src/t8_forest/t8_forest_iterate.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -300,8 +300,6 @@ t8_forest_search_tree (t8_forest_t forest, t8_locidx_t ltreeid, t8_forest_search
const t8_scheme *scheme = t8_forest_get_scheme (forest);
t8_element_array_t *leaf_elements = t8_forest_tree_get_leaves (forest, ltreeid);

/* assert for empty tree */
T8_ASSERT (t8_element_array_get_count (leaf_elements) >= 0);
/* Get the first and last leaf of this tree */
const t8_element_t *first_el = t8_element_array_index_locidx (leaf_elements, 0);
const t8_element_t *last_el
Expand Down
2 changes: 0 additions & 2 deletions src/t8_forest/t8_forest_search/t8_forest_search.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -117,8 +117,6 @@ t8_search_base::search_tree (const t8_locidx_t ltreeid)
const t8_scheme *ts = t8_forest_get_scheme (this->forest);
t8_element_array_t *leaf_elements = t8_forest_tree_get_leaves (this->forest, ltreeid);

/* assert for empty tree */
T8_ASSERT (t8_element_array_get_count (leaf_elements) >= 0);
/* Get the first and last leaf of this tree */
const t8_element_t *first_el = t8_element_array_index_locidx (leaf_elements, 0);
const t8_element_t *last_el
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -90,30 +90,43 @@ t8_geometry_lagrange::t8_geom_compute_basis (const double *ref_coords) const
return t8_geometry_lagrange::t8_geom_s2_basis (ref_coords);
case 2:
return t8_geometry_lagrange::t8_geom_s3_basis (ref_coords);
default:
SC_ABORTF ("Error: Lagrange geometry for degree %i %s not yet implemented. \n", *degree,
t8_eclass_to_string[active_tree_class]);
}

case T8_ECLASS_TRIANGLE:
switch (*degree) {
case 1:
return t8_geometry_lagrange::t8_geom_t3_basis (ref_coords);
case 2:
return t8_geometry_lagrange::t8_geom_t6_basis (ref_coords);
default:
SC_ABORTF ("Error: Lagrange geometry for degree %i %s not yet implemented. \n", *degree,
t8_eclass_to_string[active_tree_class]);
}
case T8_ECLASS_QUAD:
switch (*degree) {
case 1:
return t8_geometry_lagrange::t8_geom_q4_basis (ref_coords);
case 2:
return t8_geometry_lagrange::t8_geom_q9_basis (ref_coords);
default:
SC_ABORTF ("Error: Lagrange geometry for degree %i %s not yet implemented. \n", *degree,
t8_eclass_to_string[active_tree_class]);
}
case T8_ECLASS_HEX:
switch (*degree) {
case 1:
return t8_geometry_lagrange::t8_geom_h8_basis (ref_coords);
case 2:
return t8_geometry_lagrange::t8_geom_h27_basis (ref_coords);
default:
SC_ABORTF ("Error: Lagrange geometry for degree %i %s not yet implemented. \n", *degree,
t8_eclass_to_string[active_tree_class]);
}
default:
SC_ABORTF ("Error: Lagrange geometry for degree %i %s not yet implemented. \n", *degree,
SC_ABORTF ("Error: Lagrange geometry for eclass %s not yet implemented. \n",
t8_eclass_to_string[active_tree_class]);
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -498,7 +498,7 @@ t8_default_scheme_hex::element_set_linear_id (t8_element_t *elem, const int leve
{
T8_ASSERT (element_is_valid (elem));
T8_ASSERT (0 <= level && level <= HEX_LINEAR_MAXLEVEL);
T8_ASSERT (0 <= id && id < ((t8_linearidx_t) 1) << P8EST_DIM * level);
T8_ASSERT (id < ((t8_linearidx_t) 1) << P8EST_DIM * level);

p8est_quadrant_set_morton ((p8est_quadrant_t *) elem, level, id);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -258,7 +258,7 @@ t8_default_scheme_line::element_set_linear_id (t8_element_t *elem, int level, t8
{
T8_ASSERT (element_is_valid (elem));
T8_ASSERT (0 <= level && level <= T8_DLINE_MAXLEVEL);
T8_ASSERT (0 <= id && id < ((t8_linearidx_t) 1) << level);
T8_ASSERT (id < ((t8_linearidx_t) 1) << level);

t8_dline_init_linear_id ((t8_default_line_t *) elem, level, id);
}
Expand Down
2 changes: 1 addition & 1 deletion src/t8_schemes/t8_default/t8_default_line/t8_dline_bits.c
Original file line number Diff line number Diff line change
Expand Up @@ -250,7 +250,7 @@ void
t8_dline_init_linear_id (t8_dline_t *l, int level, t8_linearidx_t id)
{
T8_ASSERT (0 <= level && level <= T8_DLINE_MAXLEVEL);
T8_ASSERT (0 <= id && id < ((t8_linearidx_t) 1) << level);
T8_ASSERT (id < ((t8_linearidx_t) 1) << level);

/* Set the level */
l->level = level;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -349,7 +349,7 @@ void
t8_default_scheme_prism::element_set_linear_id (t8_element_t *elem, int level, t8_linearidx_t id) const
{
T8_ASSERT (0 <= level && level <= T8_DPRISM_MAXLEVEL);
T8_ASSERT (0 <= id && id < ((t8_linearidx_t) 1) << 3 * level);
T8_ASSERT (id < ((t8_linearidx_t) 1) << 3 * level);

t8_dprism_init_linear_id ((t8_default_prism_t *) elem, level, id);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -440,7 +440,6 @@ t8_dpyramid_update_index (t8_linearidx_t *id, const t8_dpyramid_type_t type, con
t8_linearidx_t test = 0;
t8_linearidx_t shift;
T8_ASSERT (id != NULL);
T8_ASSERT (*id >= 0);
int remain = -1;
do {
/* Iterate through the local-id. Get the current shift by the type of the
Expand All @@ -465,7 +464,7 @@ t8_dpyramid_init_linear_id (t8_dpyramid_t *p, const int level, t8_linearidx_t id
t8_linearidx_t p_sum2 = sc_intpow64u (6, level);

T8_ASSERT (0 <= level && level <= T8_DPYRAMID_MAXLEVEL);
T8_ASSERT (0 <= id && id <= 2 * p_sum1 - p_sum2);
T8_ASSERT (id <= 2 * p_sum1 - p_sum2);

p->pyramid.level = level;
p->pyramid.x = 0;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -250,7 +250,7 @@ t8_default_scheme_quad::element_set_linear_id (t8_element_t *elem, int level, t8
{
T8_ASSERT (element_is_valid (elem));
T8_ASSERT (0 <= level && level <= P4EST_QMAXLEVEL);
T8_ASSERT (0 <= id && id < ((t8_linearidx_t) 1) << P4EST_DIM * level);
T8_ASSERT (id < ((t8_linearidx_t) 1) << P4EST_DIM * level);

p4est_quadrant_set_morton ((p4est_quadrant_t *) elem, level, id);
T8_QUAD_SET_TDIM ((p4est_quadrant_t *) elem, 2);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -401,7 +401,7 @@ void
t8_default_scheme_tet::element_set_linear_id (t8_element_t *elem, int level, t8_linearidx_t id) const
{
T8_ASSERT (0 <= level && level <= T8_DTET_MAXLEVEL);
T8_ASSERT (0 <= id && id < ((t8_linearidx_t) 1) << 3 * level);
T8_ASSERT (id < ((t8_linearidx_t) 1) << 3 * level);
T8_ASSERT (element_is_valid (elem));

t8_dtet_init_linear_id ((t8_default_tet_t *) elem, id, level);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -418,7 +418,7 @@ t8_default_scheme_tri::element_set_linear_id (t8_element_t *elem, int level, t8_
{
T8_ASSERT (element_is_valid (elem));
T8_ASSERT (0 <= level && level <= T8_DTRI_MAXLEVEL);
T8_ASSERT (0 <= id && id < ((t8_linearidx_t) 1) << (2 * level));
T8_ASSERT (id < ((t8_linearidx_t) 1) << (2 * level));

t8_dtri_init_linear_id ((t8_dtri_t *) elem, id, level);
}
Expand Down
4 changes: 2 additions & 2 deletions src/t8_schemes/t8_default/t8_default_tri/t8_dtri_bits.c
Original file line number Diff line number Diff line change
Expand Up @@ -1456,7 +1456,7 @@ t8_dtri_init_linear_id_with_level (t8_dtri_t *t, t8_linearidx_t id, const int st
t8_linearidx_t local_index;
t8_dtri_cube_id_t cid;
t8_dtri_type_t type;
T8_ASSERT (0 <= id && id <= ((t8_linearidx_t) 1) << (T8_DTRI_DIM * end_level));
T8_ASSERT (id <= ((t8_linearidx_t) 1) << (T8_DTRI_DIM * end_level));
/*Ensure, that the function is called with a valid element */
T8_ASSERT (t->level == start_level);
T8_ASSERT (t8_dtri_is_valid (t));
Expand Down Expand Up @@ -1490,7 +1490,7 @@ t8_dtri_init_linear_id (t8_dtri_t *t, t8_linearidx_t id, int level)
t8_linearidx_t local_index;
t8_dtri_cube_id_t cid;
t8_dtri_type_t type;
T8_ASSERT (0 <= id && id <= ((t8_linearidx_t) 1) << (T8_DTRI_DIM * level));
T8_ASSERT (id <= ((t8_linearidx_t) 1) << (T8_DTRI_DIM * level));

t->level = level;
t->x = 0;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -313,8 +313,8 @@ int
t8_default_scheme_vertex::element_is_valid (const t8_element_t *elem)

{
const t8_dvertex *v = (const t8_dvertex_t *) elem;
return 0 <= v->level && v->level <= T8_DVERTEX_MAXLEVEL;
return 1;
//return 0<=level && level <= maxlevel
}

void
Expand Down
7 changes: 3 additions & 4 deletions src/t8_schemes/t8_standalone/t8_standalone_implementation.hxx
Original file line number Diff line number Diff line change
Expand Up @@ -922,7 +922,7 @@ struct t8_standalone_scheme
return;
}

T8_ASSERT (0 <= id);
T8_ASSERT (id < (size_t) element_count_leaves (elem, level));
T8_ASSERT (1 <= level && level <= T8_ELEMENT_MAXLEVEL[TEclass]);
t8_standalone_element<TEclass> child;

Expand Down Expand Up @@ -1004,7 +1004,7 @@ struct t8_standalone_scheme
}
id += parent_id;
}
T8_ASSERT (id >= 0);
T8_ASSERT (id < (size_t) element_count_leaves (elem, level));
return id;
}

Expand Down Expand Up @@ -1595,8 +1595,7 @@ struct t8_standalone_scheme
static constexpr t8_linearidx_t
num_descendants_at_leveldiff ([[maybe_unused]] const t8_element_t *elem, const t8_element_level leveldiff) noexcept
{
if (leveldiff < 0)
return 0;
T8_ASSERT (leveldiff <= get_maxlevel ());
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@Davknapp I fixed #1436 here as well, but didn't realize when we talked.

leveldiff is actually unsigned, so this branch could never be entered and Wextra warned me about it

if constexpr (TEclass == T8_ECLASS_PYRAMID) {
SC_ABORT ("Not implemented yet.\n");
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,18 +47,22 @@ get_vertices_ids (const t8_eclass_t eclass, int vertices_ids[T8_ECLASS_MAX_CORNE
vertices_ids[5] = 5;
vertices_ids[6] = 6;
vertices_ids[7] = 7;
[[fallthrough]];
case T8_ECLASS_QUAD:
vertices_ids[3] = 3;
vertices_ids[2] = 2;
[[fallthrough]];
case T8_ECLASS_LINE:
vertices_ids[1] = 1;
[[fallthrough]];
case T8_ECLASS_VERTEX:
vertices_ids[0] = 0;
break;
case T8_ECLASS_PRISM:
vertices_ids[3] = 4;
vertices_ids[4] = 5;
vertices_ids[5] = 7;
[[fallthrough]];
case T8_ECLASS_TRIANGLE:
vertices_ids[0] = 0;
vertices_ids[1] = 1;
Expand Down