Skip to content
Open
Show file tree
Hide file tree
Changes from all 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
131 changes: 66 additions & 65 deletions src/t8_cmesh/t8_cmesh.cxx

Large diffs are not rendered by default.

34 changes: 17 additions & 17 deletions src/t8_cmesh/t8_cmesh_examples.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,7 @@ t8_cmesh_new_from_p4est_ext (void *conn, int dim, sc_MPI_Comm comm, int set_part
* and raise a warning. */
if (!sc_package_is_registered (p4est_package_id)) {
t8_global_errorf ("WARNING: p4est is not yet initialized. Doing it now for you.\n");
p4est_init (NULL, SC_LP_ESSENTIAL);
p4est_init (nullptr, SC_LP_ESSENTIAL);
}

T8_ASSERT (dim == 2 || dim == 3);
Expand Down Expand Up @@ -430,7 +430,7 @@ t8_cmesh_new_from_class (const t8_eclass_t eclass, const sc_MPI_Comm comm)
break;
default:
SC_ABORT ("Invalid eclass\n");
return NULL;
return nullptr;
}
}

Expand Down Expand Up @@ -660,7 +660,7 @@ t8_cmesh_t
t8_cmesh_new_hypercube (t8_eclass_t eclass, sc_MPI_Comm comm, int do_bcast, int do_partition, int periodic)
{
t8_cmesh_t cmesh;
int num_trees_for_hypercube[T8_ECLASS_COUNT] = { 1, 1, 1, 2, 1, 6, 2, 3 };
int const num_trees_for_hypercube[T8_ECLASS_COUNT] = { 1, 1, 1, 2, 1, 6, 2, 3 };
int i;
t8_locidx_t vertices[8];
double attr_vertices[24];
Expand Down Expand Up @@ -829,7 +829,7 @@ t8_cmesh_new_hypercube (t8_eclass_t eclass, sc_MPI_Comm comm, int do_bcast, int
}
if (do_bcast) {
if (mpirank != 0) {
cmesh = NULL;
cmesh = nullptr;
}
cmesh = t8_cmesh_bcast (cmesh, 0, comm);
}
Expand Down Expand Up @@ -1890,7 +1890,7 @@ t8_cmesh_new_prism_cake (sc_MPI_Comm comm, int num_of_prisms)
6 * 3 doubles? */
double *vertices = T8_ALLOC (double, num_of_prisms * 6 * 3);
t8_cmesh_t cmesh;
double degrees = 360. / num_of_prisms;
double const degrees = 360. / num_of_prisms;

T8_ASSERT (num_of_prisms > 2);

Expand Down Expand Up @@ -2913,7 +2913,7 @@ t8_cmesh_new_quadrangulated_disk (const double radius, sc_MPI_Comm comm)
}

/* Face connectivity. */
t8_cmesh_set_join_by_vertices (cmesh, ntrees, all_eclasses, all_verts, NULL, 0);
t8_cmesh_set_join_by_vertices (cmesh, ntrees, all_eclasses, all_verts, nullptr, 0);

/* Commit the mesh */
t8_cmesh_commit (cmesh, comm);
Expand Down Expand Up @@ -2942,8 +2942,8 @@ t8_cmesh_new_triangulated_spherical_surface_octahedron (const double radius, sc_
all_eclasses[itree] = T8_ECLASS_TRIANGLE;
}

double vertices_top[3][3] = { { 1.0, 0.0, 0.0 }, { 0.0, 1.0, 0.0 }, { 0.0, 0.0, 1.0 } };
double vertices_bot[3][3] = { { 1.0, 0.0, 0.0 }, { 0.0, 1.0, 0.0 }, { 0.0, 0.0, -1.0 } };
double const vertices_top[3][3] = { { 1.0, 0.0, 0.0 }, { 0.0, 1.0, 0.0 }, { 0.0, 0.0, 1.0 } };
double const vertices_bot[3][3] = { { 1.0, 0.0, 0.0 }, { 0.0, 1.0, 0.0 }, { 0.0, 0.0, -1.0 } };

for (int turn = 0, itree = -1; turn < ntrees / 2; turn++) {
double rot_mat[3][3];
Expand Down Expand Up @@ -2993,7 +2993,7 @@ t8_cmesh_new_triangulated_spherical_surface_octahedron (const double radius, sc_
}

/* Face connectivity. */
t8_cmesh_set_join_by_vertices (cmesh, ntrees, all_eclasses, all_verts, NULL, 0);
t8_cmesh_set_join_by_vertices (cmesh, ntrees, all_eclasses, all_verts, nullptr, 0);

/* Commit the mesh */
t8_cmesh_commit (cmesh, comm);
Expand Down Expand Up @@ -3139,7 +3139,7 @@ t8_cmesh_new_triangulated_spherical_surface_icosahedron (const double radius, sc
}

/* Face connectivity. */
t8_cmesh_set_join_by_vertices (cmesh, ntrees, all_eclasses, all_verts, NULL, 0);
t8_cmesh_set_join_by_vertices (cmesh, ntrees, all_eclasses, all_verts, nullptr, 0);

/* Commit the mesh */
t8_cmesh_commit (cmesh, comm);
Expand Down Expand Up @@ -3228,7 +3228,7 @@ t8_cmesh_new_triangulated_spherical_surface_cube (const double radius, sc_MPI_Co
}

// Face connectivity.
t8_cmesh_set_join_by_vertices (cmesh, ntrees, all_eclasses, all_verts, NULL, 0);
t8_cmesh_set_join_by_vertices (cmesh, ntrees, all_eclasses, all_verts, nullptr, 0);

// Commit the mesh.
t8_cmesh_commit (cmesh, comm);
Expand Down Expand Up @@ -3297,14 +3297,14 @@ t8_cmesh_new_quadrangulated_spherical_surface (const double radius, sc_MPI_Comm
}

/* Face connectivity. */
t8_cmesh_set_join_by_vertices (cmesh, ntrees, all_eclasses, all_verts, NULL, 0);
t8_cmesh_set_join_by_vertices (cmesh, ntrees, all_eclasses, all_verts, nullptr, 0);

/* Commit the mesh */
t8_cmesh_commit (cmesh, comm);
return cmesh;
}

typedef t8_cmesh_t (t8_inner_sphere_creator_t) (const double inner_radius, sc_MPI_Comm comm);
using t8_inner_sphere_creator_t = t8_cmesh_t (const double, sc_MPI_Comm);

static t8_cmesh_t
t8_cmesh_new_spherical_shell (t8_eclass_t eclass, t8_geometry_c *geometry,
Expand Down Expand Up @@ -3356,7 +3356,7 @@ t8_cmesh_new_spherical_shell (t8_eclass_t eclass, t8_geometry_c *geometry,
const t8_locidx_t num_elements_in_tree = t8_forest_get_tree_num_leaf_elements (forest, itree_local);

/* Element class scheme of the current tree. */
t8_eclass_t eclass_2d = t8_forest_get_eclass (forest, itree_local);
t8_eclass_t const eclass_2d = t8_forest_get_eclass (forest, itree_local);

/* Loop over all local elements in the tree. */
for (t8_locidx_t ielement = 0; ielement < num_elements_in_tree; ++ielement) {
Expand Down Expand Up @@ -3430,7 +3430,7 @@ t8_cmesh_new_spherical_shell (t8_eclass_t eclass, t8_geometry_c *geometry,
sc_MPI_Comm_free (&local_comm);

/* Face connectivity. */
t8_cmesh_set_join_by_vertices (cmesh, ntrees, all_eclasses, all_verts, NULL, 0);
t8_cmesh_set_join_by_vertices (cmesh, ntrees, all_eclasses, all_verts, nullptr, 0);

/* Cleanup. */
T8_FREE (all_verts);
Expand Down Expand Up @@ -3565,7 +3565,7 @@ t8_cmesh_new_cubed_spherical_shell (const double inner_radius, const double shel
}

/* Face connectivity. */
t8_cmesh_set_join_by_vertices (cmesh, ntrees, all_eclasses, all_verts, NULL, 0);
t8_cmesh_set_join_by_vertices (cmesh, ntrees, all_eclasses, all_verts, nullptr, 0);

T8_FREE (all_verts);
T8_FREE (all_eclasses);
Expand Down Expand Up @@ -3716,7 +3716,7 @@ t8_cmesh_new_cubed_sphere (const double radius, sc_MPI_Comm comm)
}

/* Face connectivity. */
t8_cmesh_set_join_by_vertices (cmesh, ntrees, all_eclasses, all_verts, NULL, 0);
t8_cmesh_set_join_by_vertices (cmesh, ntrees, all_eclasses, all_verts, nullptr, 0);

/* Commit the mesh */
t8_cmesh_commit (cmesh, comm);
Expand Down
4 changes: 2 additions & 2 deletions src/t8_cmesh/t8_cmesh_geometry.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@
void
t8_cmesh_register_geometry (t8_cmesh_t cmesh, t8_geometry_c *geometry)
{
if (cmesh->geometry_handler == NULL) {
if (cmesh->geometry_handler == nullptr) {
/* The handler was not constructed, do it now. */
cmesh->geometry_handler = new t8_geometry_handler ();
}
Expand Down Expand Up @@ -108,7 +108,7 @@ t8_cmesh_get_tree_geom_hash (const t8_cmesh_t cmesh, const t8_gloidx_t gtreeid)
return geom->t8_geom_get_hash ();
}

t8_locidx_t ltreeid = t8_cmesh_get_local_id (cmesh, gtreeid);
t8_locidx_t const ltreeid = t8_cmesh_get_local_id (cmesh, gtreeid);
/* Look up the hash of the geometry in the attributes. */
const t8_geometry_hash *geometry_hash = (const t8_geometry_hash *) t8_cmesh_get_attribute (
cmesh, t8_get_package_id (), T8_CMESH_GEOMETRY_ATTRIBUTE_KEY, ltreeid);
Expand Down
4 changes: 2 additions & 2 deletions src/t8_cmesh/t8_cmesh_helpers.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -230,7 +230,7 @@ t8_cmesh_set_join_by_vertices (t8_cmesh_t cmesh, const t8_gloidx_t ntrees, const
} /* Loop over trees. */

/* Transfer the computed face connectivity to the `cmesh` object. */
if (cmesh != NULL) {
if (cmesh != nullptr) {
for (int itree = 0; itree < ntrees; itree++) {
const t8_eclass_t eclass = eclasses[itree];
const int nfaces = t8_eclass_num_faces[eclass];
Expand All @@ -248,7 +248,7 @@ t8_cmesh_set_join_by_vertices (t8_cmesh_t cmesh, const t8_gloidx_t ntrees, const
}

/* Pass the `conn` array to the caller if asked for. */
if (connectivity == NULL) {
if (connectivity == nullptr) {
T8_FREE (conn);
}
else {
Expand Down
52 changes: 26 additions & 26 deletions src/t8_cmesh/t8_cmesh_internal/t8_cmesh_commit.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -44,12 +44,12 @@
* It contains the global id of the ghost, the local id of the ghost,
* and the current number of inserted ghost attributes.
*/
typedef struct ghost_facejoins_struct
using t8_ghost_facejoin_t = struct ghost_facejoins_struct
{
t8_gloidx_t ghost_id; /**< The id of the ghost */
t8_locidx_t local_id; /**< The local id of the ghost */
t8_gloidx_t attr_id; /**< The current number of inserted ghost attributes */
} t8_ghost_facejoin_t;
};

static int
t8_ghost_facejoins_compare (const void *fj1, const void *fj2)
Expand All @@ -76,8 +76,8 @@ t8_ghost_facejoin_equal (const void *v1, const void *v2, [[maybe_unused]] const
static unsigned
t8_ghost_hash (const void *v, const void *u)
{
t8_gloidx_t ghost_id = ((t8_ghost_facejoin_t *) v)->ghost_id;
t8_locidx_t num_hashes = *((t8_locidx_t *) u);
t8_gloidx_t const ghost_id = ((t8_ghost_facejoin_t *) v)->ghost_id;
t8_locidx_t const num_hashes = *((t8_locidx_t *) u);

return ghost_id % num_hashes;
}
Expand Down Expand Up @@ -143,7 +143,7 @@ t8_cmesh_commit_replicated_new (t8_cmesh_t cmesh)
t8_ctree_t tree1;
size_t si;

if (cmesh->stash != NULL && cmesh->stash->classes.elem_count > 0) {
if (cmesh->stash != nullptr && cmesh->stash->classes.elem_count > 0) {
t8_stash_t stash = cmesh->stash;
sc_array_t *class_entries = &stash->classes;
t8_stash_class_struct_t *entry;
Expand Down Expand Up @@ -178,7 +178,7 @@ t8_cmesh_commit_replicated_new (t8_cmesh_t cmesh)
t8_stash_attribute_sort (cmesh->stash);
cmesh->num_trees = cmesh->num_local_trees = num_trees;
cmesh->first_tree = 0;
t8_cmesh_add_attributes (cmesh, NULL);
t8_cmesh_add_attributes (cmesh, nullptr);

/* Set all face connections */
t8_cmesh_trees_set_all_boundary (cmesh, cmesh->trees);
Expand Down Expand Up @@ -217,7 +217,7 @@ t8_cmesh_commit_partitioned_new (t8_cmesh_t cmesh, sc_MPI_Comm comm)

sc_hash_t *ghost_ids;
sc_mempool_t *ghost_facejoin_mempool;
t8_ghost_facejoin_t *ghost_facejoin = NULL, *temp_facejoin, **facejoin_pp;
t8_ghost_facejoin_t *ghost_facejoin = nullptr, *temp_facejoin, **facejoin_pp;
size_t joinfaces_it, iz;
t8_gloidx_t id1, id2;
t8_locidx_t temp_local_id = 0;
Expand Down Expand Up @@ -251,7 +251,7 @@ t8_cmesh_commit_partitioned_new (t8_cmesh_t cmesh, sc_MPI_Comm comm)
sc_flops_snap (&fi, &snapshot);
#endif

if (cmesh->tree_offsets != NULL) {
if (cmesh->tree_offsets != nullptr) {
const t8_gloidx_t *tree_offsets = (t8_gloidx_t *) t8_shmem_array_get_gloidx_array (cmesh->tree_offsets);
/* We partition using tree offsets */
/* Get the first tree and whether it is shared */
Expand All @@ -274,7 +274,7 @@ t8_cmesh_commit_partitioned_new (t8_cmesh_t cmesh, sc_MPI_Comm comm)

num_hashes = cmesh->num_local_trees > 0 ? cmesh->num_local_trees : 10;
ghost_facejoin_mempool = sc_mempool_new (sizeof (t8_ghost_facejoin_t));
ghost_ids = sc_hash_new (t8_ghost_hash, t8_ghost_facejoin_equal, &num_hashes, NULL);
ghost_ids = sc_hash_new (t8_ghost_hash, t8_ghost_facejoin_equal, &num_hashes, nullptr);

temp_facejoin = (t8_ghost_facejoin_t *) sc_mempool_alloc (ghost_facejoin_mempool);
temp_facejoin->attr_id = 0;
Expand All @@ -293,7 +293,7 @@ t8_cmesh_commit_partitioned_new (t8_cmesh_t cmesh, sc_MPI_Comm comm)
if (!id2_istree) {
/* id2 is a ghost */
temp_facejoin->ghost_id = id2;
if (sc_hash_insert_unique (ghost_ids, temp_facejoin, NULL)) {
if (sc_hash_insert_unique (ghost_ids, temp_facejoin, nullptr)) {
/* If we did not already stored id2 in the hash we do so and assign the next local ghost id */
temp_facejoin->local_id = cmesh->num_ghosts++;
temp_facejoin = (t8_ghost_facejoin_t *) sc_mempool_alloc (ghost_facejoin_mempool);
Expand All @@ -304,7 +304,7 @@ t8_cmesh_commit_partitioned_new (t8_cmesh_t cmesh, sc_MPI_Comm comm)
/* id1 is a ghost */
T8_ASSERT (id2_istree);
temp_facejoin->ghost_id = id1;
if (sc_hash_insert_unique (ghost_ids, temp_facejoin, NULL)) {
if (sc_hash_insert_unique (ghost_ids, temp_facejoin, nullptr)) {
/* If we did not already stored id1 in the hash we do so and assign the next local ghost id */
temp_facejoin->local_id = cmesh->num_ghosts++;
temp_facejoin = (t8_ghost_facejoin_t *) sc_mempool_alloc (ghost_facejoin_mempool);
Expand Down Expand Up @@ -397,7 +397,7 @@ t8_cmesh_commit_partitioned_new (t8_cmesh_t cmesh, sc_MPI_Comm comm)
id1_istree = cmesh->first_tree <= id1 && last_tree >= id1;
id2_istree = cmesh->first_tree <= id2 && last_tree >= id2;
temp_facejoin->ghost_id = id1;
tree1 = NULL;
tree1 = nullptr;
#if T8_ENABLE_DEBUG
ghost1 = NULL;
#endif
Expand All @@ -410,8 +410,8 @@ t8_cmesh_commit_partitioned_new (t8_cmesh_t cmesh, sc_MPI_Comm comm)
*/
/* TODO: This if else if else spaghetti code is quite ugly, think it over
* and find a better way */
face_neigh = face_neigh2 = NULL;
ttf = ttf2 = NULL;
face_neigh = face_neigh2 = nullptr;
ttf = ttf2 = nullptr;
if (id1_istree) {
/* First tree in the connection is a local tree */
tree1 = t8_cmesh_trees_get_tree_ext (cmesh->trees, joinface->id1 - cmesh->first_tree, &face_neigh, &ttf);
Expand All @@ -429,7 +429,7 @@ t8_cmesh_commit_partitioned_new (t8_cmesh_t cmesh, sc_MPI_Comm comm)
#if T8_ENABLE_DEBUG
ghost2 = NULL;
#endif
tree2 = NULL;
tree2 = nullptr;
temp_facejoin->ghost_id = joinface->id2;
if (id2_istree) {
/* Second tree in the connection is a local tree */
Expand All @@ -445,10 +445,10 @@ t8_cmesh_commit_partitioned_new (t8_cmesh_t cmesh, sc_MPI_Comm comm)
#endif
}
F = t8_eclass_max_num_faces[cmesh->dimension];
if (ttf != NULL) {
if (ttf != nullptr) {
/* The first entry is either a tree or ghost */
ttf[joinface->face1] = F * joinface->orientation + joinface->face2;
if (tree1 != NULL) {
if (tree1 != nullptr) {
/* First entry is a tree */
T8_ASSERT (ghost2 != NULL || tree2 != NULL);
face_neigh[joinface->face1]
Expand All @@ -460,10 +460,10 @@ t8_cmesh_commit_partitioned_new (t8_cmesh_t cmesh, sc_MPI_Comm comm)
face_neigh_g[joinface->face1] = id2;
}
}
if (ttf2 != NULL) {
if (ttf2 != nullptr) {
/* The second entry is either a tree or a ghost */
ttf2[joinface->face2] = F * joinface->orientation + joinface->face1;
if (tree2 != NULL) {
if (tree2 != nullptr) {
/* The second entry is a tree */
T8_ASSERT (tree1 != NULL || ghost1 != NULL);
face_neigh2[joinface->face2] = tree1 ? id1 - cmesh->first_tree : temp_local_id + cmesh->num_local_trees;
Expand Down Expand Up @@ -555,15 +555,15 @@ t8_cmesh_commit (t8_cmesh_t cmesh, sc_MPI_Comm comm)
"explicitly using t8_cmesh_set_dimension\n");

/* If profiling is enabled, we measure the runtime of commit. */
if (cmesh->profile != NULL) {
if (cmesh->profile != nullptr) {
cmesh->profile->commit_runtime = sc_MPI_Wtime ();
}
/* Get mpisize and rank */
mpiret = sc_MPI_Comm_size (comm, &cmesh->mpisize);
SC_CHECK_MPI (mpiret);
mpiret = sc_MPI_Comm_rank (comm, &cmesh->mpirank);
SC_CHECK_MPI (mpiret);
if (cmesh->set_from != NULL) {
if (cmesh->set_from != nullptr) {
cmesh->dimension = cmesh->set_from->dimension;
if (cmesh->face_knowledge == -1) {
/* Keep the face knowledge of the from cmesh, if -1 was specified */
Expand All @@ -572,7 +572,7 @@ t8_cmesh_commit (t8_cmesh_t cmesh, sc_MPI_Comm comm)

/* If present use the set geometry handler, otherwise take
* over the handler from set_from. */
if (cmesh->geometry_handler == NULL && cmesh->set_from->geometry_handler != NULL) {
if (cmesh->geometry_handler == nullptr && cmesh->set_from->geometry_handler != nullptr) {
cmesh->geometry_handler = cmesh->set_from->geometry_handler;
cmesh->geometry_handler->ref ();
}
Expand Down Expand Up @@ -619,12 +619,12 @@ t8_cmesh_commit (t8_cmesh_t cmesh, sc_MPI_Comm comm)
//t8_cmesh_trees_print (cmesh, cmesh->trees);
#endif

if (cmesh->set_from != NULL) {
if (cmesh->set_from != nullptr) {
/* Unref set_from and set it to NULL */
t8_cmesh_unref (&cmesh->set_from);
cmesh->set_from = NULL;
cmesh->set_from = nullptr;
}
if (cmesh->stash != NULL) {
if (cmesh->stash != nullptr) {
t8_stash_destroy (&cmesh->stash);
}

Expand All @@ -640,7 +640,7 @@ t8_cmesh_commit (t8_cmesh_t cmesh, sc_MPI_Comm comm)
"creating an issue.");
#endif /* T8_ENABLE_DEBUG */
/* If profiling is enabled, we measure the runtime of commit. */
if (cmesh->profile != NULL) {
if (cmesh->profile != nullptr) {
cmesh->profile->commit_runtime = sc_MPI_Wtime () - cmesh->profile->commit_runtime;
/* We also measure the number of shared trees,
* it is the average over all first_tree_shared*mpisize values. */
Expand Down
Loading