diff --git a/src/t8_cmesh/t8_cmesh.cxx b/src/t8_cmesh/t8_cmesh.cxx index cc1cbbe98f..75c0191431 100644 --- a/src/t8_cmesh/t8_cmesh.cxx +++ b/src/t8_cmesh/t8_cmesh.cxx @@ -50,7 +50,7 @@ int t8_cmesh_is_initialized (t8_cmesh_t cmesh) { - if (!(cmesh != NULL && t8_refcount_is_active (&cmesh->rc) && !cmesh->committed)) { + if (!(cmesh != nullptr && t8_refcount_is_active (&cmesh->rc) && !cmesh->committed)) { return 0; } @@ -107,7 +107,7 @@ t8_cmesh_is_committed (const t8_cmesh_t cmesh) if (!is_checking) { is_checking = 1; - if (!(cmesh != NULL && t8_refcount_is_active (&cmesh->rc) && cmesh->committed)) { + if (!(cmesh != nullptr && t8_refcount_is_active (&cmesh->rc) && cmesh->committed)) { is_checking = 0; return 0; } @@ -216,7 +216,7 @@ t8_cmesh_init (t8_cmesh_t *pcmesh) /* Set the geometry handler to NULL. * It will get initialized either when a geometry is registered * or when the cmesh gets committed. */ - cmesh->geometry_handler = NULL; + cmesh->geometry_handler = nullptr; cmesh->vertex_connectivity = new t8_cmesh_vertex_connectivity (); #if T8_ENABLE_DEBUG cmesh->negative_volume_check = 1; @@ -239,13 +239,13 @@ t8_cmesh_set_derive (const t8_cmesh_t cmesh, const t8_cmesh_t set_from) T8_ASSERT (t8_cmesh_is_initialized (cmesh)); T8_ASSERT (set_from == NULL || t8_cmesh_is_committed (set_from)); - if (cmesh->set_from != NULL) { + if (cmesh->set_from != nullptr) { /* If we overwrite a previously set cmesh, then we unref it. */ t8_cmesh_unref (&cmesh->set_from); } cmesh->set_from = set_from; - if (set_from != NULL) { + if (set_from != nullptr) { t8_cmesh_set_dimension (cmesh, set_from->dimension); SC_CHECK_ABORT (cmesh->stash->attributes.elem_count == 0, "ERROR: Cannot add attributes to cmesh when deriving from another cmesh.\n"); @@ -290,9 +290,9 @@ t8_cmesh_set_partition_range (t8_cmesh_t cmesh, const int set_face_knowledge, co cmesh->num_local_trees = last_local_tree - cmesh->first_tree + 1; cmesh->set_partition = 1; /* Overwrite previous partition settings */ - if (cmesh->tree_offsets != NULL) { + if (cmesh->tree_offsets != nullptr) { t8_shmem_array_destroy (&cmesh->tree_offsets); - cmesh->tree_offsets = NULL; + cmesh->tree_offsets = nullptr; } cmesh->set_partition_level = -1; } @@ -302,14 +302,14 @@ t8_cmesh_set_partition_offsets (t8_cmesh_t cmesh, t8_shmem_array_t tree_offsets) { T8_ASSERT (t8_cmesh_is_initialized (cmesh)); - if (cmesh->tree_offsets != NULL && cmesh->tree_offsets != tree_offsets) { + if (cmesh->tree_offsets != nullptr && cmesh->tree_offsets != tree_offsets) { /* We overwrite a previously set offset array, so * we need to free its memory first. */ t8_shmem_array_destroy (&cmesh->tree_offsets); } cmesh->tree_offsets = tree_offsets; cmesh->set_partition = 1; - if (tree_offsets != NULL) { + if (tree_offsets != nullptr) { /* We overwrite any previously partition settings */ cmesh->first_tree = -1; cmesh->first_tree_shared = -1; @@ -332,9 +332,9 @@ t8_cmesh_set_partition_uniform (t8_cmesh_t cmesh, const int element_level, const /* We overwrite any previous partition settings */ cmesh->first_tree = -1; cmesh->num_local_trees = -1; - if (cmesh->tree_offsets != NULL) { + if (cmesh->tree_offsets != nullptr) { t8_shmem_array_destroy (&cmesh->tree_offsets); - cmesh->tree_offsets = NULL; + cmesh->tree_offsets = nullptr; } } } @@ -391,7 +391,7 @@ t8_cmesh_get_first_tree (const t8_cmesh_t cmesh) { T8_ASSERT (t8_cmesh_is_committed (cmesh)); - return cmesh->num_local_trees > 0 ? t8_cmesh_get_tree (cmesh, 0) : NULL; + return cmesh->num_local_trees > 0 ? t8_cmesh_get_tree (cmesh, 0) : nullptr; } /* returns the next local tree in the cmesh (by treeid) @@ -406,7 +406,7 @@ t8_cmesh_get_next_tree (const t8_cmesh_t cmesh, const t8_ctree_t tree) T8_ASSERT (tree != NULL); T8_ASSERT (t8_cmesh_treeid_is_local_tree (cmesh, tree->treeid)); T8_ASSERT (cmesh->committed); - return tree->treeid < cmesh->num_local_trees - 1 ? t8_cmesh_get_tree (cmesh, tree->treeid + 1) : NULL; + return tree->treeid < cmesh->num_local_trees - 1 ? t8_cmesh_get_tree (cmesh, tree->treeid + 1) : nullptr; } void @@ -421,7 +421,8 @@ t8_cmesh_set_attribute (t8_cmesh_t cmesh, const t8_gloidx_t gtree_id, const int T8_ASSERT (key < T8_CMESH_NEXT_POSSIBLE_KEY && key >= 0); } #endif - SC_CHECK_ABORT (cmesh->set_from == NULL, "ERROR: Cannot add attributes to cmesh when deriving from another cmesh.\n"); + SC_CHECK_ABORT (cmesh->set_from == nullptr, + "ERROR: Cannot add attributes to cmesh when deriving from another cmesh.\n"); t8_stash_add_attribute (cmesh->stash, gtree_id, package_id, key, data_size, data, !data_persists); } @@ -433,7 +434,7 @@ t8_cmesh_set_attribute_string (t8_cmesh_t cmesh, const t8_gloidx_t gtree_id, con T8_ASSERT (t8_cmesh_is_initialized (cmesh)); /* The size is the string's length + the terminating '\0' */ - size_t size = strlen (string) + 1; + size_t const size = strlen (string) + 1; /* Add the string as an attribute. */ t8_cmesh_set_attribute (cmesh, gtree_id, package_id, key, (void *) string, size, 0); } @@ -463,8 +464,9 @@ t8_cmesh_get_attribute (const t8_cmesh_t cmesh, const int package_id, const int T8_ASSERT (t8_cmesh_treeid_is_local_tree (cmesh, ltree_id) || t8_cmesh_treeid_is_ghost (cmesh, ltree_id)); const int is_ghost = t8_cmesh_treeid_is_ghost (cmesh, ltree_id); - return t8_cmesh_trees_get_attribute ( - cmesh->trees, is_ghost ? t8_cmesh_ltreeid_to_ghostid (cmesh, ltree_id) : ltree_id, package_id, key, NULL, is_ghost); + return t8_cmesh_trees_get_attribute (cmesh->trees, + is_ghost ? t8_cmesh_ltreeid_to_ghostid (cmesh, ltree_id) : ltree_id, package_id, + key, nullptr, is_ghost); } t8_gloidx_t * @@ -481,7 +483,7 @@ t8_cmesh_get_partition_table (const t8_cmesh_t cmesh) T8_ASSERT (t8_cmesh_is_committed (cmesh)); if (!cmesh->set_partition) { /* The mesh is not partitioned. We return NULL. */ - return NULL; + return nullptr; } /* If the mesh is not stored, NULL is returned, otherwise the * partition array. */ @@ -561,7 +563,7 @@ t8_cmesh_set_join (t8_cmesh_t cmesh, const t8_gloidx_t gtree1, const t8_gloidx_t static void t8_cmesh_init_profile (t8_cmesh_t cmesh) { - if (cmesh->profile == NULL) { + if (cmesh->profile == nullptr) { /* Allocate new profile if it is not enabled already */ cmesh->profile = T8_ALLOC_ZERO (t8_cprofile_struct_t, 1); } @@ -589,7 +591,7 @@ t8_cmesh_set_profiling (t8_cmesh_t cmesh, const int set_profiling) } else { /* Free any profile that is already set */ - if (cmesh->profile != NULL) { + if (cmesh->profile != nullptr) { T8_FREE (cmesh->profile); } } @@ -623,8 +625,8 @@ t8_cmesh_is_equal (const t8_cmesh_t cmesh_a, const t8_cmesh_t cmesh_b) T8_ECLASS_COUNT * sizeof (t8_locidx_t)); /* check tree_offsets */ - if (cmesh_a->tree_offsets != NULL) { - if (cmesh_b->tree_offsets == NULL) { + if (cmesh_a->tree_offsets != nullptr) { + if (cmesh_b->tree_offsets == nullptr) { return 0; } else { @@ -659,7 +661,7 @@ t8_cmesh_bcast (const t8_cmesh_t cmesh_in, const int root, sc_MPI_Comm comm) { int mpirank, mpisize, mpiret; int iclass; - t8_cmesh_t cmesh_out = NULL; /* NULL initializer prevents compiler warning. */ + t8_cmesh_t cmesh_out = nullptr; /* NULL initializer prevents compiler warning. */ struct { @@ -698,7 +700,7 @@ t8_cmesh_bcast (const t8_cmesh_t cmesh_in, const int root, sc_MPI_Comm comm) * We cannot broadcast the geometries, since they are pointers to derived * classes that we cannot know of on the receiving process. * Geometries must therefore be added after broadcasting. */ - if (cmesh_in->geometry_handler != NULL) { + if (cmesh_in->geometry_handler != nullptr) { SC_CHECK_ABORT (cmesh_in->geometry_handler->get_num_geometries () == 0, "Error: Broadcasting a cmesh with registered geometries is not possible.\n" "We recommend to broadcast first and register the geometries after.\n"); @@ -745,7 +747,7 @@ t8_cmesh_bcast (const t8_cmesh_t cmesh_in, const int root, sc_MPI_Comm comm) cmesh_out->first_tree_shared = 0; cmesh_out->num_ghosts = 0; T8_ASSERT (cmesh_out->set_partition == 0); - if (meta_info.cmesh.profile != NULL) { + if (meta_info.cmesh.profile != nullptr) { t8_cmesh_set_profiling (cmesh_in, 1); } for (iclass = 0; iclass < T8_ECLASS_COUNT; iclass++) { @@ -1099,10 +1101,10 @@ t8_cmesh_get_face_neighbor (const t8_cmesh_t cmesh, const t8_locidx_t ltreeid, c /* Decode the ttf information to get the orientation and the dual face */ t8_cmesh_tree_to_face_decode (cmesh->dimension, ttf, &dual_face_temp, &orientation_temp); - if (dual_face != NULL) { + if (dual_face != nullptr) { *dual_face = dual_face_temp; } - if (orientation != NULL) { + if (orientation != nullptr) { *orientation = orientation_temp; } /* Return the face neighbor */ @@ -1116,7 +1118,7 @@ t8_cmesh_get_tree_face_neighbor_eclass (const t8_cmesh_t cmesh, const t8_locidx_ T8_ASSERT (t8_cmesh_treeid_is_local_tree (cmesh, ltreeid) || t8_cmesh_treeid_is_ghost (cmesh, ltreeid)); T8_ASSERT (0 <= face); - const t8_locidx_t neighbor_id = t8_cmesh_get_face_neighbor (cmesh, ltreeid, face, NULL, NULL); + const t8_locidx_t neighbor_id = t8_cmesh_get_face_neighbor (cmesh, ltreeid, face, nullptr, nullptr); if (neighbor_id < 0) { // No neighbor was found. return T8_ECLASS_INVALID; @@ -1143,7 +1145,7 @@ void t8_cmesh_print_profile (const t8_cmesh_t cmesh) { T8_ASSERT (t8_cmesh_is_committed (cmesh)); - if (cmesh->profile != NULL) { + if (cmesh->profile != nullptr) { /* Only print something if profiling is enabled */ sc_statinfo_t stats[T8_CPROFILE_NUM_STATS]; t8_cprofile_t *profile = cmesh->profile; @@ -1179,7 +1181,7 @@ t8_cmesh_reset (t8_cmesh_t *pcmesh) T8_ASSERT (cmesh->rc.refcount == 0); /* free tree_offset */ - if (cmesh->tree_offsets != NULL) { + if (cmesh->tree_offsets != nullptr) { #if T8_ENABLE_DEBUG sc_MPI_Comm comm; /* Check whether a correct communicator was stored at tree_offsets. @@ -1195,37 +1197,37 @@ t8_cmesh_reset (t8_cmesh_t *pcmesh) /*TODO: write this */ if (!cmesh->committed) { t8_stash_destroy (&cmesh->stash); - if (cmesh->set_from != NULL) { + if (cmesh->set_from != nullptr) { /* We unref our reference of set_from */ t8_cmesh_unref (&cmesh->set_from); } } else { - if (cmesh->trees != NULL) { + if (cmesh->trees != nullptr) { t8_cmesh_trees_destroy (&cmesh->trees); } T8_ASSERT (cmesh->set_from == NULL); } - if (cmesh->profile != NULL) { + if (cmesh->profile != nullptr) { T8_FREE (cmesh->profile); } - if (cmesh->geometry_handler != NULL) { + if (cmesh->geometry_handler != nullptr) { cmesh->geometry_handler->unref (); - cmesh->geometry_handler = NULL; + cmesh->geometry_handler = nullptr; } /* unref the partition scheme (if set) */ - if (cmesh->set_partition_scheme != NULL) { + if (cmesh->set_partition_scheme != nullptr) { cmesh->set_partition_scheme->unref (); } - if (cmesh->vertex_connectivity != NULL) { + if (cmesh->vertex_connectivity != nullptr) { delete cmesh->vertex_connectivity; } T8_FREE (cmesh); - *pcmesh = NULL; + *pcmesh = nullptr; } void @@ -1389,13 +1391,13 @@ t8_cmesh_uniform_set_return_parameters_to_empty (t8_gloidx_t *first_local_tree, int8_t *first_tree_shared) { *first_local_tree = *last_local_tree = -1; - if (child_in_tree_begin != NULL) { + if (child_in_tree_begin != nullptr) { *child_in_tree_begin = -1; } - if (child_in_tree_end != NULL) { + if (child_in_tree_end != nullptr) { *child_in_tree_end = -1; } - if (first_tree_shared != NULL) { + if (first_tree_shared != nullptr) { *first_tree_shared = 0; } } @@ -1461,11 +1463,11 @@ t8_cmesh_uniform_bounds_equal_element_count (t8_cmesh_t cmesh, const int level, T8_ASSERT (tree_scheme != NULL); *first_local_tree = 0; - if (child_in_tree_begin != NULL) { + if (child_in_tree_begin != nullptr) { *child_in_tree_begin = 0; } *last_local_tree = 0; - if (child_in_tree_end != NULL) { + if (child_in_tree_end != nullptr) { *child_in_tree_end = 0; } @@ -1513,7 +1515,7 @@ t8_cmesh_uniform_bounds_equal_element_count (t8_cmesh_t cmesh, const int level, if (cmesh->mpirank == 0) { first_global_child = 0; - if (child_in_tree_begin != NULL) { + if (child_in_tree_begin != nullptr) { *child_in_tree_begin = 0; } } @@ -1537,14 +1539,14 @@ t8_cmesh_uniform_bounds_equal_element_count (t8_cmesh_t cmesh, const int level, *first_local_tree = first_global_child / children_per_tree; child_in_tree_begin_temp = first_global_child - *first_local_tree * children_per_tree; - if (child_in_tree_begin != NULL) { + if (child_in_tree_begin != nullptr) { *child_in_tree_begin = child_in_tree_begin_temp; } *last_local_tree = (last_global_child - 1) / children_per_tree; is_empty = *first_local_tree >= *last_local_tree && first_global_child >= last_global_child; - if (first_tree_shared != NULL) { + if (first_tree_shared != nullptr) { #if T8_ENABLE_DEBUG prev_last_tree = (first_global_child - 1) / children_per_tree; T8_ASSERT (cmesh->mpirank > 0 || prev_last_tree <= 0); @@ -1560,7 +1562,7 @@ t8_cmesh_uniform_bounds_equal_element_count (t8_cmesh_t cmesh, const int level, *first_tree_shared = 0; } } - if (child_in_tree_end != NULL) { + if (child_in_tree_end != nullptr) { *child_in_tree_end = (last_global_child - *last_local_tree * children_per_tree); } if (is_empty) { @@ -1633,7 +1635,7 @@ t8_cmesh_uniform_bounds_from_unpartioned (const t8_cmesh_t cmesh, const t8_gloid * all trees to find the trees in which these are contained. * We cast to long double and double to prevent overflow. */ /* Since the full cmesh is available on each process, the computation of local_num_children equals the global number of children*/ - uint64_t global_num_children = (uint64_t) local_num_children; + uint64_t const global_num_children = (uint64_t) local_num_children; const t8_gloidx_t first_child = t8_cmesh_get_first_element_of_process ((uint32_t) cmesh->mpirank, (uint32_t) cmesh->mpisize, global_num_children); const t8_gloidx_t last_child = t8_cmesh_get_first_element_of_process ( @@ -1673,7 +1675,7 @@ t8_cmesh_uniform_bounds_from_unpartioned (const t8_cmesh_t cmesh, const t8_gloid if (current_tree_element_offset <= first_child_next_non_empty && first_child_next_non_empty < current_tree_element_offset + num_leaf_elems_in_tree) { - if (child_in_tree_begin != NULL) { + if (child_in_tree_begin != nullptr) { *child_in_tree_begin = first_child_next_non_empty - current_tree_element_offset; } /* We have found the first tree; since this process is empty, we can immediately return, @@ -1682,7 +1684,7 @@ t8_cmesh_uniform_bounds_from_unpartioned (const t8_cmesh_t cmesh, const t8_gloid *last_local_tree = igtree - 1; /* If our first element is not the very first element in the tree, we share * this tree with the previous process. */ - if (first_tree_shared != NULL) { + if (first_tree_shared != nullptr) { *first_tree_shared = current_tree_element_offset < first_child_next_non_empty ? 1 : 0; } } @@ -1702,20 +1704,20 @@ t8_cmesh_uniform_bounds_from_unpartioned (const t8_cmesh_t cmesh, const t8_gloid /* Check if the first element is on the current tree */ if (current_tree_element_offset <= first_child && first_child < current_tree_element_offset + num_leaf_elems_in_tree) { - if (child_in_tree_begin != NULL) { + if (child_in_tree_begin != nullptr) { *child_in_tree_begin = first_child - current_tree_element_offset; } *first_local_tree = igtree; /* If our first element is not the very first element in the tree, we share * this tree with the previous process. */ - if (first_tree_shared != NULL) { + if (first_tree_shared != nullptr) { *first_tree_shared = current_tree_element_offset < first_child ? 1 : 0; } } /* Check if the last element is on the current tree */ if (current_tree_element_offset < last_child && last_child <= current_tree_element_offset + num_leaf_elems_in_tree) { - if (child_in_tree_end != NULL) { + if (child_in_tree_end != nullptr) { *child_in_tree_end = last_child - current_tree_element_offset; } *last_local_tree = igtree; @@ -1733,7 +1735,6 @@ t8_cmesh_uniform_bounds_from_unpartioned (const t8_cmesh_t cmesh, const t8_gloid T8_ASSERT (num_trees == 0); t8_cmesh_uniform_set_return_parameters_to_empty (first_local_tree, child_in_tree_begin, last_local_tree, child_in_tree_end, first_tree_shared); - return; } /** @@ -1796,16 +1797,16 @@ t8_cmesh_bounds_send_start_or_end (const t8_cmesh_t cmesh, const bool start_mess else { /* We are the current proc, so we just copy the data. */ (*first_or_last_local_tree) = global_id_of_first_or_last_tree; if (start_message && first_or_last_element_in_tree_index_of_iproc > 0) { - if (first_tree_shared != NULL) { + if (first_tree_shared != nullptr) { *first_tree_shared = 1; } } else { - if (first_tree_shared != NULL) { + if (first_tree_shared != nullptr) { *first_tree_shared = 0; } } - if (child_in_tree_end_or_begin != NULL) { + if (child_in_tree_end_or_begin != nullptr) { /* If we send the last element add 1 to the id. During later processing of the cmesh we iterate * as long as ielement < child_in_tree_end. Therefore we have to shift by one. */ *child_in_tree_end_or_begin = first_or_last_element_in_tree_index_of_iproc; @@ -1847,7 +1848,7 @@ recv_message (const bool start, t8_gloidx_t *first_last_local_tree, t8_gloidx_t if (start) { *child_in_tree_begin_temp = message[1]; } - if (child_in_tree_begin_end != NULL) { + if (child_in_tree_begin_end != nullptr) { *child_in_tree_begin_end = message[1]; T8_ASSERT (*child_in_tree_begin_end == -1 || (start ? (0 <= *child_in_tree_begin_end && *child_in_tree_begin_end < global_num_elements) @@ -1855,12 +1856,12 @@ recv_message (const bool start, t8_gloidx_t *first_last_local_tree, t8_gloidx_t } if (message[1] > 0 && start) { /* The first tree is shared */ - if (first_tree_shared != NULL) { + if (first_tree_shared != nullptr) { *first_tree_shared = 1; } } else { - if (first_tree_shared != NULL) { + if (first_tree_shared != nullptr) { *first_tree_shared = 0; } } @@ -2226,7 +2227,7 @@ t8_cmesh_uniform_bounds_from_partition (const t8_cmesh_t cmesh, const t8_gloidx_ if (send_end_message) { t8_cmesh_bounds_send_start_or_end (cmesh, false, proc_is_empty, last_puretree_of_iproc, first_tree_shared_shift, iproc, send_requests, send_buffer, ¤t_pos_in_send_buffer, - last_element_in_tree_index_of_iproc, last_local_tree, NULL, + last_element_in_tree_index_of_iproc, last_local_tree, nullptr, child_in_tree_end, &expect_end_message, global_num_elements, comm); #if T8_ENABLE_DEBUG num_message_sent += (iproc != cmesh->mpirank) ? 1 : 0; @@ -2272,7 +2273,8 @@ t8_cmesh_uniform_bounds_from_partition (const t8_cmesh_t cmesh, const t8_gloidx_ = t8_shmem_array_binary_search (offset_array, last_element - 1, cmesh->mpisize - 1, find_bounds_in_offset); T8_ASSERT (0 <= recv_from && recv_from < cmesh->mpisize); - recv_message (false, last_local_tree, child_in_tree_end, NULL, NULL, global_num_elements, cmesh, recv_from, comm); + recv_message (false, last_local_tree, child_in_tree_end, nullptr, nullptr, global_num_elements, cmesh, recv_from, + comm); #if T8_ENABLE_DEBUG num_received_end_messages++; num_message_recv++; @@ -2286,7 +2288,7 @@ t8_cmesh_uniform_bounds_from_partition (const t8_cmesh_t cmesh, const t8_gloidx_ T8_ASSERT (num_received_start_messages == 1); T8_ASSERT (num_received_end_messages == 1); - if (first_tree_shared != NULL) { + if (first_tree_shared != nullptr) { if (!this_proc_is_empty && cmesh->mpirank > 0 && child_in_tree_begin_temp > 0) { /* The first tree is shared */ *first_tree_shared = 1; @@ -2308,7 +2310,6 @@ t8_cmesh_uniform_bounds_from_partition (const t8_cmesh_t cmesh, const t8_gloidx_ T8_ASSERT (total_num_sent == total_num_recv); #endif t8_debugf ("Done with t8_cmesh_uniform_bounds_from_partition.\n"); - return; } /* TODO: Shared trees, binary search in offset-array to avoid recv_any, @@ -2392,7 +2393,7 @@ t8_cmesh_get_local_bounding_box (const t8_cmesh_t cmesh, double bounds[6]) T8_ASSERT (num_local_trees > 0); double tree_bounds[6] = { 0.0 }; t8_geometry_handler *geom_handler = cmesh->geometry_handler; - if (geom_handler == NULL) { + if (geom_handler == nullptr) { t8_errorf ("Error: Trying to compute bounding box for cmesh with no geometry.\n"); return false; } diff --git a/src/t8_cmesh/t8_cmesh_examples.cxx b/src/t8_cmesh/t8_cmesh_examples.cxx index 738ab04d0e..3086b386ee 100644 --- a/src/t8_cmesh/t8_cmesh_examples.cxx +++ b/src/t8_cmesh/t8_cmesh_examples.cxx @@ -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); @@ -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; } } @@ -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]; @@ -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); } @@ -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); @@ -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); @@ -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]; @@ -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); @@ -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); @@ -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); @@ -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, @@ -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) { @@ -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); @@ -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); @@ -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); diff --git a/src/t8_cmesh/t8_cmesh_geometry.cxx b/src/t8_cmesh/t8_cmesh_geometry.cxx index e1547fd3bd..72cc2d59f6 100644 --- a/src/t8_cmesh/t8_cmesh_geometry.cxx +++ b/src/t8_cmesh/t8_cmesh_geometry.cxx @@ -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 (); } @@ -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); diff --git a/src/t8_cmesh/t8_cmesh_helpers.cxx b/src/t8_cmesh/t8_cmesh_helpers.cxx index 17e7c2411c..8466e4a1e2 100644 --- a/src/t8_cmesh/t8_cmesh_helpers.cxx +++ b/src/t8_cmesh/t8_cmesh_helpers.cxx @@ -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]; @@ -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 { diff --git a/src/t8_cmesh/t8_cmesh_internal/t8_cmesh_commit.cxx b/src/t8_cmesh/t8_cmesh_internal/t8_cmesh_commit.cxx index 4d460b947b..c5a7a991d4 100644 --- a/src/t8_cmesh/t8_cmesh_internal/t8_cmesh_commit.cxx +++ b/src/t8_cmesh/t8_cmesh_internal/t8_cmesh_commit.cxx @@ -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) @@ -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; } @@ -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; @@ -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); @@ -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; @@ -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 */ @@ -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; @@ -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); @@ -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); @@ -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 @@ -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); @@ -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 */ @@ -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] @@ -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; @@ -555,7 +555,7 @@ 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 */ @@ -563,7 +563,7 @@ t8_cmesh_commit (t8_cmesh_t cmesh, sc_MPI_Comm comm) 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 */ @@ -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 (); } @@ -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); } @@ -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. */ diff --git a/src/t8_cmesh/t8_cmesh_internal/t8_cmesh_partition.cxx b/src/t8_cmesh/t8_cmesh_internal/t8_cmesh_partition.cxx index d79fc19f1b..751b9a1d62 100644 --- a/src/t8_cmesh/t8_cmesh_internal/t8_cmesh_partition.cxx +++ b/src/t8_cmesh/t8_cmesh_internal/t8_cmesh_partition.cxx @@ -101,7 +101,7 @@ t8_partition_new_ghost_ids (const t8_cmesh_t cmesh, const t8_part_tree_t recv_pa tree_id_glo = face_neighbors[iface]; if (cmesh->first_tree <= tree_id_glo && tree_id_glo < cmesh->first_tree + cmesh->num_local_trees) { /* the face neighbor is a local tree */ - (void) t8_cmesh_trees_get_tree_ext (cmesh->trees, tree_id_glo - cmesh->first_tree, &tree_neighbors, NULL); + (void) t8_cmesh_trees_get_tree_ext (cmesh->trees, tree_id_glo - cmesh->first_tree, &tree_neighbors, nullptr); /* Get the number of the face of tree that is connected with ghost * and set the new local ghost id */ face_tree = ttf[iface] % t8_eclass_max_num_faces[cmesh->dimension]; @@ -117,7 +117,7 @@ t8_partition_new_ghost_ids (const t8_cmesh_t cmesh, const t8_part_tree_t recv_pa #if T8_ENABLE_DEBUG ret = #endif - sc_hash_insert_unique (cmesh->trees->ghost_globalid_to_local_id, new_hash, NULL); + sc_hash_insert_unique (cmesh->trees->ghost_globalid_to_local_id, new_hash, nullptr); /* The entry must not have existed before */ T8_ASSERT (ret); } @@ -194,7 +194,7 @@ t8_cmesh_gather_treecount_ext (const t8_cmesh_t cmesh, sc_MPI_Comm comm, const i T8_ASSERT (t8_cmesh_comm_is_valid (cmesh, comm)); tree_offset = cmesh->first_tree_shared ? -cmesh->first_tree - 1 : cmesh->first_tree; - if (cmesh->tree_offsets == NULL) { + if (cmesh->tree_offsets == nullptr) { t8_shmem_init (comm); t8_shmem_set_type (comm, T8_SHMEM_BEST_TYPE); /* Only allocate the shmem array, if it is not already allocated */ @@ -534,8 +534,8 @@ t8_cmesh_send_ghost (const t8_cmesh_t cmesh, const struct t8_cmesh *cmesh_from, t8_gloidx_t tree_id, *ghost_neighbors, neighbor; const t8_gloidx_t *from_offsets; t8_locidx_t *tree_neighbors; - t8_cghost_t ghost = NULL; - t8_ctree_t ctree = NULL; + t8_cghost_t ghost = nullptr; + t8_ctree_t ctree = nullptr; t8_eclass_t eclass; int proc, iface; size_t left = 0, right = cmesh->mpirank; @@ -549,11 +549,11 @@ t8_cmesh_send_ghost (const t8_cmesh_t cmesh, const struct t8_cmesh *cmesh_from, from_offsets = t8_shmem_array_get_gloidx_array (cmesh_from->tree_offsets); } else { - from_offsets = NULL; + from_offsets = nullptr; } if (tree < cmesh_from->num_local_trees) { /* Given local id belongs to a tree. We compute its global id */ - ctree = t8_cmesh_trees_get_tree_ext (cmesh_from->trees, tree, &tree_neighbors, NULL); + ctree = t8_cmesh_trees_get_tree_ext (cmesh_from->trees, tree, &tree_neighbors, nullptr); tree_id = tree + cmesh_from->first_tree; eclass = ctree->eclass; } @@ -561,7 +561,7 @@ t8_cmesh_send_ghost (const t8_cmesh_t cmesh, const struct t8_cmesh *cmesh_from, /* Given local id belongs to a ghost. We store the ghost and its * global id */ ghost - = t8_cmesh_trees_get_ghost_ext (cmesh_from->trees, tree - cmesh_from->num_local_trees, &ghost_neighbors, NULL); + = t8_cmesh_trees_get_ghost_ext (cmesh_from->trees, tree - cmesh_from->num_local_trees, &ghost_neighbors, nullptr); tree_id = ghost->treeid; eclass = ghost->eclass; } @@ -576,8 +576,8 @@ t8_cmesh_send_ghost (const t8_cmesh_t cmesh, const struct t8_cmesh *cmesh_from, * then we send the tree/ghost. */ for (iface = 0; iface < t8_eclass_num_faces[eclass]; iface++) { /* Get the global id of the considered neighbor */ - neighbor = ctree != NULL ? t8_cmesh_get_global_id ((t8_cmesh_t) cmesh_from, tree_neighbors[iface]) - : ghost_neighbors[iface]; + neighbor = ctree != nullptr ? t8_cmesh_get_global_id ((t8_cmesh_t) cmesh_from, tree_neighbors[iface]) + : ghost_neighbors[iface]; if (neighbor == tree_id) { /* There is no neighbor at this face */ continue; @@ -664,7 +664,7 @@ t8_cmesh_partition_copy_data (char *send_buffer, t8_cmesh_t cmesh, const t8_cmes //ssize_t last_attribute_diff; t8_attribute_info_struct_t *attr_info; void *first_attribute; - t8_locidx_t num_ghost_send = send_as_ghost->elem_count; + t8_locidx_t const num_ghost_send = send_as_ghost->elem_count; t8_locidx_t ghosts_left; t8_locidx_t *face_neighbor, ghost_id, itree; t8_gloidx_t *face_neighbor_g, *face_neighbor_gnew, new_neighbor; @@ -676,7 +676,7 @@ t8_cmesh_partition_copy_data (char *send_buffer, t8_cmesh_t cmesh, const t8_cmes /* TODO: This is currently inefficient since we copy each tree for itself. * Best practice is to copy chunks of trees out of the different part * arrays of cmesh_from */ - if (total_alloc == 0 || send_buffer == NULL) { + if (total_alloc == 0 || send_buffer == nullptr) { t8_debugf ("No data to store in buffer.\n"); return; } @@ -689,7 +689,7 @@ t8_cmesh_partition_copy_data (char *send_buffer, t8_cmesh_t cmesh, const t8_cmes /* offset from the beginning to the current tree */ temp_offset_tree = 0; for (itree = send_first; itree <= send_last; itree++) { - tree = t8_cmesh_trees_get_tree_ext (cmesh_from->trees, itree, &face_neighbor, NULL); + tree = t8_cmesh_trees_get_tree_ext (cmesh_from->trees, itree, &face_neighbor, nullptr); (void) memcpy (send_buffer + temp_offset_tree, tree, sizeof (t8_ctree_struct_t)); temp_offset_tree += sizeof (t8_ctree_struct_t); @@ -724,7 +724,7 @@ t8_cmesh_partition_copy_data (char *send_buffer, t8_cmesh_t cmesh, const t8_cmes temp_offset_tree = 0; /* Set attribute offsets of trees and attribute data offsets of info objects */ - tree_cpy = NULL; + tree_cpy = nullptr; last_num_att = 0; last_size = 0; last_offset = attr_info_bytes; @@ -795,7 +795,7 @@ t8_cmesh_partition_copy_data (char *send_buffer, t8_cmesh_t cmesh, const t8_cmes /* The ghost that we send was a local ghost */ ghost = t8_cmesh_trees_get_ghost_ext (cmesh_from->trees, ghost_id - cmesh_from->num_local_trees, &face_neighbor_g, &ttf); - tree = NULL; + tree = nullptr; /* Set entries of the new ghost */ ghost_cpy->eclass = ghost->eclass; ghost_cpy->treeid = ghost->treeid; @@ -808,8 +808,8 @@ t8_cmesh_partition_copy_data (char *send_buffer, t8_cmesh_t cmesh, const t8_cmes ghost_att_size = t8_cmesh_trees_ghost_attribute_size (ghost); } else { - attr_info = NULL; - first_attribute = NULL; + attr_info = nullptr; + first_attribute = nullptr; ghost_att_size = 0; } /* Copy face_neighbor entries and ttf entries */ @@ -820,7 +820,7 @@ t8_cmesh_partition_copy_data (char *send_buffer, t8_cmesh_t cmesh, const t8_cmes /* The ghost we send was a local tree */ T8_ASSERT (0 <= ghost_id && ghost_id < cmesh_from->num_local_trees); tree = t8_cmesh_trees_get_tree_ext (cmesh_from->trees, ghost_id, &face_neighbor, &ttf); - ghost = NULL; + ghost = nullptr; T8_ASSERT (ghost_id == tree->treeid); /* Set entries of the new ghost */ ghost_cpy->eclass = tree->eclass; @@ -834,8 +834,8 @@ t8_cmesh_partition_copy_data (char *send_buffer, t8_cmesh_t cmesh, const t8_cmes ghost_att_size = t8_cmesh_trees_attribute_size (tree); } else { - attr_info = NULL; - first_attribute = NULL; + attr_info = nullptr; + first_attribute = nullptr; ghost_att_size = 0; } /* copy face_neighbor entries, since the ones on the tree are local and @@ -1005,7 +1005,7 @@ t8_cmesh_partition_sendloop (t8_cmesh_t cmesh, t8_cmesh_t cmesh_from, int *num_r offset_from = t8_shmem_array_get_gloidx_array (cmesh_from->tree_offsets); } else { - offset_from = NULL; + offset_from = nullptr; range_start = t8_offset_first (cmesh_from->mpirank, offset_to); } @@ -1105,8 +1105,8 @@ t8_cmesh_partition_sendloop (t8_cmesh_t cmesh, t8_cmesh_t cmesh_from, int *num_r *my_buffer_bytes = total_alloc; } else { - my_buffer = NULL; - buffer = NULL; + my_buffer = nullptr; + buffer = nullptr; } T8_ASSERT (num_trees + num_ghost_send == 0 || (!cmesh_from->set_partition && iproc == cmesh_from->mpirank) || t8_offset_sendsto (cmesh->mpirank, iproc, offset_from, offset_to)); @@ -1145,7 +1145,7 @@ t8_cmesh_partition_sendloop (t8_cmesh_t cmesh, t8_cmesh_t cmesh_from, int *num_r } t8_debugf ("Set request %i to NULL\n", iproc - flag - *send_first); *(*requests + iproc - flag - *send_first) = sc_MPI_REQUEST_NULL; - (*send_buffer)[iproc - flag - *send_first] = NULL; + (*send_buffer)[iproc - flag - *send_first] = nullptr; iproc++; } if (iproc <= *send_last) { @@ -1234,7 +1234,7 @@ t8_cmesh_partition_receive_message (t8_cmesh_t cmesh, sc_MPI_Comm comm, const in recv_bytes, proc_recv, local_procid[proc_recv - recv_first]); /* If we are profiling, we count the number of trees and ghosts that * we received. */ - if (cmesh->profile != NULL && proc_recv != cmesh->mpirank) { + if (cmesh->profile != nullptr && proc_recv != cmesh->mpirank) { cmesh->profile->partition_ghosts_recv += recv_part->num_ghosts; cmesh->profile->partition_trees_recv += recv_part->num_trees; } @@ -1277,8 +1277,8 @@ t8_cmesh_partition_recvloop (t8_cmesh_t cmesh, const t8_cmesh *cmesh_from, const else { recv_first = cmesh->mpirank; recv_last = cmesh->mpirank; - num_parts = my_buffer != NULL ? 1 : 0; - from_offsets = NULL; + num_parts = my_buffer != nullptr ? 1 : 0; + from_offsets = nullptr; } /* Initialize trees structure with yet unknown number of ghosts */ t8_cmesh_trees_init (&cmesh->trees, num_parts, num_trees, 0); @@ -1325,7 +1325,7 @@ t8_cmesh_partition_recvloop (t8_cmesh_t cmesh, const t8_cmesh *cmesh_from, const } else { /* cmesh_from is replicated */ - myrank_part = my_buffer != NULL ? 0 : -1; + myrank_part = my_buffer != nullptr ? 0 : -1; } T8_ASSERT (my_buffer == NULL || myrank_part >= 0); @@ -1367,7 +1367,7 @@ t8_cmesh_partition_recvloop (t8_cmesh_t cmesh, const t8_cmesh *cmesh_from, const /**************************************************/ /* Got trees and ghosts from myself */ - if (my_buffer != NULL) { + if (my_buffer != nullptr) { T8_ASSERT (myrank_part >= 0); /* TODO: Get ghosts from myself! */ recv_part = t8_cmesh_trees_get_part (cmesh->trees, myrank_part); @@ -1385,7 +1385,7 @@ t8_cmesh_partition_recvloop (t8_cmesh_t cmesh, const t8_cmesh *cmesh_from, const * so we set everything to 0 there */ recv_part = t8_cmesh_trees_get_part (cmesh->trees, myrank_part); recv_part->num_ghosts = recv_part->num_trees = 0; - recv_part->first_tree = NULL; + recv_part->first_tree = nullptr; /* TODO: This case should not happen, eventually remove */ SC_ABORT_NOT_REACHED (); } @@ -1407,7 +1407,7 @@ t8_cmesh_partition_debug_listprocs (const t8_cmesh_t cmesh, const t8_cmesh_t cme from = t8_shmem_array_get_gloidx_array (cmesh_from->tree_offsets); } else { - from = NULL; + from = nullptr; } to = t8_shmem_array_get_gloidx_array (cmesh->tree_offsets); mpiret = sc_MPI_Comm_rank (comm, &mpirank); @@ -1452,13 +1452,13 @@ t8_cmesh_partition_given (const t8_cmesh_t cmesh, const t8_cmesh_t cmesh_from, c int send_first, send_last, num_request_alloc; /* ranks of the processor to which we will send */ int iproc, num_send_mpi, mpiret; size_t my_buffer_bytes = -1; - char **send_buffer = NULL, *my_buffer = NULL; + char **send_buffer = nullptr, *my_buffer = nullptr; int fs, ls; int fr = 0; int lr = 0; - sc_MPI_Request *requests = NULL; + sc_MPI_Request *requests = nullptr; t8_locidx_t num_ghosts, itree, num_trees; t8_part_tree_t recv_part; t8_ctree_t tree; @@ -1564,7 +1564,7 @@ t8_cmesh_partition (t8_cmesh_t cmesh, sc_MPI_Comm comm) t8_global_productionf ("Enter cmesh partition\n"); /* If profiling is enabled, we measure the runtime of this routine. */ - if (cmesh->profile != NULL) { + if (cmesh->profile != nullptr) { cmesh->profile->partition_runtime = sc_MPI_Wtime (); } cmesh_from = (t8_cmesh_t) cmesh->set_from; @@ -1580,7 +1580,7 @@ t8_cmesh_partition (t8_cmesh_t cmesh, sc_MPI_Comm comm) T8_ASSERT (cmesh->tree_offsets == NULL); T8_ASSERT (scheme != NULL); t8_cmesh_uniform_bounds_for_irregular_refinement (cmesh_from, cmesh->set_partition_level, scheme, - &cmesh->first_tree, NULL, &last_tree, NULL, + &cmesh->first_tree, nullptr, &last_tree, nullptr, &cmesh->first_tree_shared, comm); cmesh->num_local_trees = last_tree - cmesh->first_tree + 1; @@ -1601,7 +1601,7 @@ t8_cmesh_partition (t8_cmesh_t cmesh, sc_MPI_Comm comm) /* compute local num trees */ cmesh->num_local_trees = t8_offset_num_trees (cmesh->mpirank, tree_offsets); } - if (cmesh->set_from->set_partition && cmesh->set_from->tree_offsets == NULL) { + if (cmesh->set_from->set_partition && cmesh->set_from->tree_offsets == nullptr) { /* Create the partition table for cmesh_from */ t8_cmesh_gather_treecount (cmesh->set_from, comm); } @@ -1615,7 +1615,7 @@ t8_cmesh_partition (t8_cmesh_t cmesh, sc_MPI_Comm comm) t8_cmesh_partition_given (cmesh, cmesh->set_from, tree_offsets, comm); /* Deactivate the active tree. Tree related data (such as vertices) might have been moved by the new partition and * has to be loaded again if needed. */ - if (cmesh->geometry_handler != NULL) { + if (cmesh->geometry_handler != nullptr) { cmesh->geometry_handler->deactivate_tree (); } /* If profiling is enabled, we measure the runtime of this routine. */ @@ -1803,7 +1803,7 @@ t8_cmesh_offset_percent (const t8_cmesh_t cmesh, sc_MPI_Comm comm, const int per /* Get old partition table and check for existence. */ /* TODO: If it does not exists (NULL is returned), we could compute * the number of trees and first tree of the next smaller rank by hand. */ - if (cmesh->tree_offsets == NULL) { + if (cmesh->tree_offsets == nullptr) { /* We need to create the old partition array. */ t8_cmesh_gather_treecount (cmesh, comm); created = 1; diff --git a/src/t8_cmesh/t8_cmesh_internal/t8_cmesh_trees.cxx b/src/t8_cmesh/t8_cmesh_internal/t8_cmesh_trees.cxx index fdc9f653e8..7598f9fe68 100644 --- a/src/t8_cmesh/t8_cmesh_internal/t8_cmesh_trees.cxx +++ b/src/t8_cmesh/t8_cmesh_internal/t8_cmesh_trees.cxx @@ -80,12 +80,12 @@ t8_cmesh_trees_init (t8_cmesh_trees_t *ptrees, const int num_procs, const t8_loc trees = *ptrees = T8_ALLOC (t8_cmesh_trees_struct_t, 1); trees->from_proc = sc_array_new_size (sizeof (t8_part_tree_struct_t), num_procs); trees->tree_to_proc = T8_ALLOC_ZERO (int, num_trees); - trees->ghost_to_proc = num_ghosts > 0 ? T8_ALLOC_ZERO (int, num_ghosts) : NULL; + trees->ghost_to_proc = num_ghosts > 0 ? T8_ALLOC_ZERO (int, num_ghosts) : nullptr; /* Initialize the global_id mempool */ trees->global_local_mempool = sc_mempool_new (sizeof (t8_trees_glo_lo_hash_t)); /* Initialize the global_id hash table */ trees->ghost_globalid_to_local_id - = sc_hash_new (t8_cmesh_trees_glo_lo_hash_func, t8_cmesh_trees_glo_lo_hash_equal, NULL, NULL); + = sc_hash_new (t8_cmesh_trees_glo_lo_hash_func, t8_cmesh_trees_glo_lo_hash_equal, nullptr, nullptr); } void @@ -147,7 +147,7 @@ t8_cmesh_trees_add_ghost (const t8_cmesh_trees_t trees, const t8_locidx_t lghost #if T8_ENABLE_DEBUG ret = #endif - sc_hash_insert_unique (trees->ghost_globalid_to_local_id, hash_entry, NULL); + sc_hash_insert_unique (trees->ghost_globalid_to_local_id, hash_entry, nullptr); /* It mus not have existed before, thus true was returned */ T8_ASSERT (ret); } @@ -207,7 +207,7 @@ t8_cmesh_trees_start_part (const t8_cmesh_trees_t trees, const int proc, const t = T8_ALLOC_ZERO (char, num_trees * sizeof (t8_ctree_struct_t) + num_ghosts * sizeof (t8_cghost_struct_t)); } else { - part->first_tree = NULL; + part->first_tree = nullptr; } part->first_tree_id = lfirst_tree; part->first_ghost_id = lfirst_ghost; @@ -220,13 +220,13 @@ t8_cmesh_trees_start_part (const t8_cmesh_trees_t trees, const int proc, const t * Thus, we store both the part id and the number of attributes. * */ -typedef struct +using t8_part_ghost_id_and_num_atts = struct { t8_locidx_t part_ghost_id; /**< Local identifier for the partition ghost. */ t8_gloidx_t global_id; /**< Global identifier for the partition ghost. */ int num_attributes; /**< Number of attributes associated with the partition ghost. */ int attribute_offset; /**< Offset to the attributes associated with the partition ghost. */ -} t8_part_ghost_id_and_num_atts; +}; /** Compare function for t8_part_ghost_id_and_num_atts to compare by global id. * \param [in] id_A First t8_part_ghost_id_and_num_atts to compare. @@ -370,7 +370,7 @@ t8_cmesh_trees_finish_part (const t8_cmesh_trees_t trees, const int proc) size_t num_ghost_attributes = 0; /* total number of ghost attributes */ /* To get the offset of the first ghost attribute info, we have to add the bytes * of all tree attributes. */ - size_t first_ghost_offset = next_tree_offset + tree_attr_data_bytes; + size_t const first_ghost_offset = next_tree_offset + tree_attr_data_bytes; for (it = 0; it < part->num_ghosts; it++) { ghost = t8_part_tree_get_ghost (part, it + part->first_ghost_id); ghost_attr_data_bytes += ghost->att_offset; /* att_offset temporarily stored the total size of the attributes */ @@ -562,10 +562,10 @@ t8_cmesh_trees_get_tree_ext (const t8_cmesh_trees_t trees, const t8_locidx_t ltr int8_t **ttf) { const t8_ctree_t tree = t8_cmesh_trees_get_tree (trees, ltree_id); - if (face_neigh != NULL) { + if (face_neigh != nullptr) { *face_neigh = (t8_locidx_t *) T8_TREE_FACE (tree); } - if (ttf != NULL) { + if (ttf != nullptr) { *ttf = (int8_t *) T8_TREE_TTF (tree); } return tree; @@ -579,7 +579,7 @@ t8_cmesh_trees_get_face_neighbor_ext (const t8_ctree_t tree, const int face, int T8_ASSERT (tree != NULL); T8_ASSERT (0 <= face && face < t8_eclass_num_faces[tree->eclass]); - if (ttf != NULL) { + if (ttf != nullptr) { /* Get the ttf value */ *ttf = ((int8_t *) T8_TREE_TTF (tree))[face]; } @@ -593,7 +593,7 @@ t8_locidx_t t8_cmesh_trees_get_face_neighbor (const t8_ctree_t tree, const int face) { /* We just pass this through to get_face_neighbor_ext without the ttf argument */ - return t8_cmesh_trees_get_face_neighbor_ext (tree, face, NULL); + return t8_cmesh_trees_get_face_neighbor_ext (tree, face, nullptr); } t8_gloidx_t @@ -604,7 +604,7 @@ t8_cmesh_trees_get_ghost_face_neighbor_ext (const t8_cghost_t ghost, const int f T8_ASSERT (ghost != NULL); T8_ASSERT (0 <= face && face < t8_eclass_num_faces[ghost->eclass]); - if (ttf != NULL) { + if (ttf != nullptr) { /* Get the ttf value */ *ttf = ((int8_t *) T8_GHOST_TTF (ghost))[face]; } @@ -633,10 +633,10 @@ t8_cmesh_trees_get_ghost_ext (const t8_cmesh_trees_t trees, const t8_locidx_t lg t8_cghost_t ghost; ghost = t8_cmesh_trees_get_ghost (trees, lghost_id); - if (face_neigh != NULL) { + if (face_neigh != nullptr) { *face_neigh = (t8_gloidx_t *) T8_GHOST_FACE (ghost); } - if (ttf != NULL) { + if (ttf != nullptr) { *ttf = (int8_t *) T8_GHOST_TTF (ghost); } return ghost; @@ -669,7 +669,7 @@ t8_cmesh_trees_size (const t8_cmesh_trees_t trees) int ipart; T8_ASSERT (trees != NULL); - if (trees->from_proc == NULL) { + if (trees->from_proc == nullptr) { /* This tree struct is empty */ return 0; } @@ -849,7 +849,7 @@ t8_cmesh_trees_get_attribute (const t8_cmesh_trees_t trees, const t8_locidx_t lt if (!is_ghost) { /* Get a pointer to the tree */ tree = t8_part_tree_get_tree (t8_cmesh_trees_get_part (trees, proc), ltree_id); - ghost = NULL; + ghost = nullptr; /* number of attributes and pointer to first att_info struct */ num_attributes = tree->num_attributes; first_att_info = T8_TREE_FIRST_ATT_INFO (tree); @@ -857,7 +857,7 @@ t8_cmesh_trees_get_attribute (const t8_cmesh_trees_t trees, const t8_locidx_t lt else { /* Get a pointer to the ghost */ ghost = t8_part_tree_get_ghost (t8_cmesh_trees_get_part (trees, proc), ltree_id); - tree = NULL; + tree = nullptr; /* number of attributes and pointer to first att_info struct */ num_attributes = ghost->num_attributes; first_att_info = T8_GHOST_FIRST_ATT_INFO (ghost); @@ -867,21 +867,21 @@ t8_cmesh_trees_get_attribute (const t8_cmesh_trees_t trees, const t8_locidx_t lt key_id.package_id = package_id; if (num_attributes <= 0) { - return NULL; + return nullptr; } sc_array_init_data (&attr_array, first_att_info, sizeof (t8_attribute_info_struct_t), num_attributes); index = sc_array_bsearch (&attr_array, &key_id, t8_cmesh_trees_compare_keyattr); if (index < 0) { - return NULL; + return nullptr; } attr_info = (t8_attribute_info_struct_t *) sc_array_index (&attr_array, index); - if (size != NULL) { + if (size != nullptr) { *size = attr_info->attribute_size; } /* Get a pointer to the actual attribute */ - if (tree == NULL) { + if (tree == nullptr) { attribute = T8_GHOST_ATTR (ghost, attr_info); } else { @@ -980,8 +980,6 @@ t8_cmesh_trees_print ([[maybe_unused]] const t8_cmesh_t cmesh, [[maybe_unused]] } t8_debugf ("%s\n", buf); } -#else - return; #endif } @@ -1016,7 +1014,7 @@ t8_cmesh_trees_bcast (const t8_cmesh_t cmesh_in, const int root, const sc_MPI_Co { int num_parts, ipart; int mpirank, mpiret, mpisize; - t8_cmesh_trees_t trees = NULL; + t8_cmesh_trees_t trees = nullptr; t8_part_tree_t part; struct @@ -1196,7 +1194,7 @@ t8_cmesh_trees_is_equal (const t8_cmesh_t cmesh, const t8_cmesh_trees_t trees_a, /* also returns true if both are NULL */ return 1; } - if (trees_a == NULL || trees_b == NULL) { + if (trees_a == nullptr || trees_b == nullptr) { return 0; } num_trees = cmesh->num_local_trees; @@ -1295,5 +1293,5 @@ t8_cmesh_trees_destroy (t8_cmesh_trees_t *ptrees) sc_mempool_destroy (trees->global_local_mempool); T8_FREE (trees); - ptrees = NULL; + ptrees = nullptr; } diff --git a/src/t8_cmesh/t8_cmesh_io/t8_cmesh_readmshfile.cxx b/src/t8_cmesh/t8_cmesh_io/t8_cmesh_readmshfile.cxx index c1c1a877ff..87df91b09f 100644 --- a/src/t8_cmesh/t8_cmesh_io/t8_cmesh_readmshfile.cxx +++ b/src/t8_cmesh/t8_cmesh_io/t8_cmesh_readmshfile.cxx @@ -312,10 +312,10 @@ struct t8_msh_node_equal }; /** Hashtable to store msh file nodes. */ -typedef std::unordered_set t8_msh_node_table; +using t8_msh_node_table = std::unordered_set; /** Vector which stores the vertex indices of each tree in the t8code order. */ -typedef std::vector> t8_msh_tree_vertex_indices; +using t8_msh_tree_vertex_indices = std::vector>; /* Reads an open msh-file and checks whether the MeshFormat-Version is supported by t8code or not. */ static int @@ -438,7 +438,7 @@ t8_msh_file_2_read_nodes (FILE *fp) } /* Create the hash table */ - t8_msh_node_hasher hasher (lnum_nodes); + t8_msh_node_hasher const hasher (lnum_nodes); t8_msh_node_table node_table (lnum_nodes, hasher); /* read each node and add it to the hash table */ @@ -522,7 +522,7 @@ t8_msh_file_4_read_nodes (FILE *fp) } /* Create the hash table */ - t8_msh_node_hasher hasher (lnum_nodes); + t8_msh_node_hasher const hasher (lnum_nodes); t8_msh_node_table node_table (lnum_nodes, hasher); /* read each node and add it to the hash table */ @@ -638,7 +638,7 @@ t8_msh_file_4_read_nodes (FILE *fp) * \return */ static std::optional -t8_cmesh_msh_file_2_read_eles (t8_cmesh_t cmesh, FILE *fp, const t8_msh_node_table vertices, const int dim) +t8_cmesh_msh_file_2_read_eles (t8_cmesh_t cmesh, FILE *fp, const t8_msh_node_table &vertices, const int dim) { char *line = (char *) malloc (1024), *line_modify; char first_word[2048] = "\0"; @@ -1426,7 +1426,7 @@ t8_cmesh_process_tree_geometry (t8_cmesh_t cmesh, t8_eclass_t eclass, int dim, t * We cannot access this geometry over the cmesh interface since the cmesh * is not committed yet. */ static std::optional -t8_cmesh_msh_file_4_read_eles (t8_cmesh_t cmesh, FILE *fp, const t8_msh_node_table vertices, const int dim, +t8_cmesh_msh_file_4_read_eles (t8_cmesh_t cmesh, FILE *fp, const t8_msh_node_table &vertices, const int dim, const t8_geometry_c *linear_geometry_base, const int use_cad_geometry, [[maybe_unused]] const t8_geometry_c *cad_geometry_base, const bool store_node_data) { @@ -1633,13 +1633,13 @@ t8_cmesh_msh_file_4_read_eles (t8_cmesh_t cmesh, FILE *fp, const t8_msh_node_tab /** This struct stores all information associated to a tree's face. * We need it to find neighbor trees. */ -typedef struct +using t8_msh_file_face_t = struct { t8_locidx_t ltree_id; /**< The local id of the tree this face belongs to */ int8_t face_number; /**< The number of that face within the tree */ int num_vertices; /**< The number of vertices of this face. */ long *vertices; /**< The indices of these vertices. */ -} t8_msh_file_face_t; +}; /* Hash a face. The hash value is the sum of its vertex indices */ static unsigned @@ -1779,7 +1779,7 @@ t8_msh_file_face_orientation (const t8_msh_file_face_t *Face_a, const t8_msh_fil /* This routine does only find neighbors between local trees. * Use with care if cmesh is partitioned. */ static void -t8_cmesh_msh_file_find_neighbors (t8_cmesh_t cmesh, const t8_msh_tree_vertex_indices vertex_indices) +t8_cmesh_msh_file_find_neighbors (t8_cmesh_t cmesh, const t8_msh_tree_vertex_indices &vertex_indices) { sc_hash_t *faces; t8_msh_file_face_t *Face, **pNeighbor, *Neighbor; @@ -1792,7 +1792,7 @@ t8_cmesh_msh_file_find_neighbors (t8_cmesh_t cmesh, const t8_msh_tree_vertex_ind t8_stash_class_struct_t *class_entry; face_mempool = sc_mempool_new (sizeof (t8_msh_file_face_t)); - faces = sc_hash_new (t8_msh_file_face_hash, t8_msh_file_face_equal, cmesh, NULL); + faces = sc_hash_new (t8_msh_file_face_hash, t8_msh_file_face_equal, cmesh, nullptr); /* TODO: Does currently not work with partitioned cmesh */ T8_ASSERT (!cmesh->set_partition); @@ -1851,7 +1851,7 @@ t8_cmesh_msh_file_find_neighbors (t8_cmesh_t cmesh, const t8_msh_tree_vertex_ind T8_FREE (Face->vertices); sc_mempool_free (face_mempool, Face); /* We can free the neighbor here as well */ - sc_hash_remove (faces, Neighbor, NULL); + sc_hash_remove (faces, Neighbor, nullptr); T8_FREE (Neighbor->vertices); sc_mempool_free (face_mempool, Neighbor); } @@ -1888,7 +1888,7 @@ t8_cmesh_from_msh_file_register_geometries (t8_cmesh_t cmesh, const int use_cad_ #if T8_ENABLE_OCC *cad_geometry = t8_cmesh_register_geometry (cmesh, std::string (fileprefix)); #else /* !T8_ENABLE_OCC */ - *cad_geometry = NULL; + *cad_geometry = nullptr; return 0; #endif } @@ -1906,8 +1906,8 @@ t8_cmesh_from_msh_file (const char *fileprefix, const int partition, sc_MPI_Comm t8_gloidx_t num_trees, first_tree, last_tree = -1; int main_proc_read_successful = 0; int msh_version; - const t8_geometry_c *cad_geometry = NULL; - const t8_geometry_c *linear_geometry = NULL; + const t8_geometry_c *cad_geometry = nullptr; + const t8_geometry_c *linear_geometry = nullptr; mpiret = sc_MPI_Comm_size (comm, &mpisize); SC_CHECK_MPI (mpiret); @@ -1933,7 +1933,7 @@ t8_cmesh_from_msh_file (const char *fileprefix, const int partition, sc_MPI_Comm /* Registering failed */ t8_errorf ("OCC is not linked. Cannot use cad geometry.\n"); t8_cmesh_destroy (&cmesh); - return NULL; + return nullptr; } if (!partition || mpirank == main_proc) { @@ -1941,7 +1941,7 @@ t8_cmesh_from_msh_file (const char *fileprefix, const int partition, sc_MPI_Comm /* Open the file */ t8_debugf ("Opening file %s\n", current_file); file = fopen (current_file, "r"); - if (file == NULL) { + if (file == nullptr) { t8_global_errorf ("Could not open file %s\n", current_file); t8_cmesh_destroy (&cmesh); @@ -1950,7 +1950,7 @@ t8_cmesh_from_msh_file (const char *fileprefix, const int partition, sc_MPI_Comm main_proc_read_successful = 0; sc_MPI_Bcast (&main_proc_read_successful, 1, sc_MPI_INT, main_proc, comm); } - return NULL; + return nullptr; } /* Check if msh-file version is compatible. */ msh_version = t8_cmesh_check_version_of_msh_file (file); @@ -1965,7 +1965,7 @@ t8_cmesh_from_msh_file (const char *fileprefix, const int partition, sc_MPI_Comm main_proc_read_successful = 0; sc_MPI_Bcast (&main_proc_read_successful, 1, sc_MPI_INT, main_proc, comm); } - return NULL; + return nullptr; } /* read nodes from the file */ std::optional indices; @@ -1980,7 +1980,7 @@ t8_cmesh_from_msh_file (const char *fileprefix, const int partition, sc_MPI_Comm main_proc_read_successful = 0; sc_MPI_Bcast (&main_proc_read_successful, 1, sc_MPI_INT, main_proc, comm); } - return NULL; + return nullptr; } auto vertices_opt = t8_msh_file_2_read_nodes (file); if (!vertices_opt) { @@ -1991,7 +1991,7 @@ t8_cmesh_from_msh_file (const char *fileprefix, const int partition, sc_MPI_Comm main_proc_read_successful = 0; sc_MPI_Bcast (&main_proc_read_successful, 1, sc_MPI_INT, main_proc, comm); } - return NULL; + return nullptr; } indices = t8_cmesh_msh_file_2_read_eles (cmesh, file, *vertices_opt, dim); break; @@ -2007,7 +2007,7 @@ t8_cmesh_from_msh_file (const char *fileprefix, const int partition, sc_MPI_Comm main_proc_read_successful = 0; sc_MPI_Bcast (&main_proc_read_successful, 1, sc_MPI_INT, main_proc, comm); } - return NULL; + return nullptr; } indices = t8_cmesh_msh_file_4_read_eles (cmesh, file, *vertices_opt, dim, linear_geometry, use_cad_geometry, cad_geometry, true); @@ -2026,7 +2026,7 @@ t8_cmesh_from_msh_file (const char *fileprefix, const int partition, sc_MPI_Comm main_proc_read_successful = 0; sc_MPI_Bcast (&main_proc_read_successful, 1, sc_MPI_INT, main_proc, comm); } - return NULL; + return nullptr; } else t8_cmesh_msh_file_find_neighbors (cmesh, *indices); @@ -2042,7 +2042,7 @@ t8_cmesh_from_msh_file (const char *fileprefix, const int partition, sc_MPI_Comm if (!main_proc_read_successful) { t8_debugf ("Main process could not read cmesh successfully.\n"); t8_cmesh_destroy (&cmesh); - return NULL; + return nullptr; } /* The cmesh is not yet committed, since we set the partitioning before */ if (mpirank == main_proc) { @@ -2071,7 +2071,7 @@ t8_cmesh_from_msh_file (const char *fileprefix, const int partition, sc_MPI_Comm /* Commit the cmesh */ T8_ASSERT (cmesh != NULL); - if (cmesh != NULL) { + if (cmesh != nullptr) { t8_cmesh_commit (cmesh, comm); } return cmesh; diff --git a/src/t8_cmesh/t8_cmesh_io/t8_cmesh_save.cxx b/src/t8_cmesh/t8_cmesh_io/t8_cmesh_save.cxx index c173c22e66..aac5d27bb5 100644 --- a/src/t8_cmesh/t8_cmesh_io/t8_cmesh_save.cxx +++ b/src/t8_cmesh/t8_cmesh_io/t8_cmesh_save.cxx @@ -172,7 +172,7 @@ t8_cmesh_load_ghosts (const t8_cmesh_t cmesh, FILE *fp) static int t8_cmesh_load_tree_attributes (const t8_cmesh_t cmesh, FILE *fp) { - double *vertices = NULL; + double *vertices = nullptr; t8_locidx_t itree; long treeid, neighbor; t8_ctree_t tree; @@ -272,7 +272,7 @@ t8_cmesh_save_tree_attribute (const t8_cmesh_t cmesh, FILE *fp) num_vertices = t8_eclass_num_vertices[tree->eclass]; /* Write the attributes that are vertices */ vertices = (double *) t8_cmesh_trees_get_attribute (cmesh->trees, itree, t8_get_package_id (), 0, &att_size, 0); - if (vertices != NULL) { + if (vertices != nullptr) { /* We have an attribute that is stored with key 0, we treat it as tree vertices */ num_vertices = t8_eclass_num_vertices[tree->eclass]; /* additional check that the attribute has as many bytes as the @@ -545,7 +545,7 @@ t8_cmesh_save (const t8_cmesh_t cmesh, const char *fileprefix) /* Open the file in write mode */ fp = fopen (filename, "w"); - if (fp == NULL) { + if (fp == nullptr) { /* Could not open file */ t8_errorf ("Error when opening file %s.\n", filename); return 0; @@ -595,44 +595,44 @@ t8_cmesh_load (const char *filename, sc_MPI_Comm comm) /* Open the file in read mode */ fp = fopen (filename, "r"); - if (fp == NULL) { + if (fp == nullptr) { /* Could not open file */ t8_errorf ("Error when opening file %s.\n", filename); - return NULL; + return nullptr; } t8_cmesh_init (&cmesh); /* Read all metadata of the cmesh */ if (!t8_cmesh_load_header (cmesh, fp)) { t8_errorf ("Error when opening file %s.\n", filename); t8_cmesh_destroy (&cmesh); - return NULL; + return nullptr; } /* Read all metadata of the trees */ if (!t8_cmesh_load_trees (cmesh, fp)) { t8_errorf ("Error when opening file %s.\n", filename); t8_cmesh_destroy (&cmesh); - return NULL; + return nullptr; } if (cmesh->set_partition) { /* Write all ghost metadata */ if (!t8_cmesh_load_ghosts (cmesh, fp)) { t8_errorf ("Error when opening file %s.\n", filename); t8_cmesh_destroy (&cmesh); - return NULL; + return nullptr; } } t8_cmesh_trees_finish_part (cmesh->trees, 0); if (!t8_cmesh_load_tree_attributes (cmesh, fp)) { t8_errorf ("Error when opening file %s.\n", filename); t8_cmesh_destroy (&cmesh); - return NULL; + return nullptr; } if (cmesh->set_partition) { /* Write all ghost metadata */ if (!t8_cmesh_load_ghost_attributes (cmesh, fp)) { t8_errorf ("Error when opening file %s.\n", filename); t8_cmesh_destroy (&cmesh); - return NULL; + return nullptr; } } /* Close the file */ @@ -839,7 +839,7 @@ t8_cmesh_load_and_distribute (const char *fileprefix, const int num_files, sc_MP /* Use cmesh_bcast, if only one process loads the cmesh: */ if (num_files == 1) { - cmesh = NULL; + cmesh = nullptr; if (mpirank == 0) { snprintf (buffer, BUFSIZ, "%s_%04d.cmesh", fileprefix, 0); cmesh = t8_cmesh_load (buffer, comm); diff --git a/src/t8_cmesh/t8_cmesh_io/t8_cmesh_triangle.cxx b/src/t8_cmesh/t8_cmesh_io/t8_cmesh_triangle.cxx index ae82acf419..73ccca7231 100644 --- a/src/t8_cmesh/t8_cmesh_io/t8_cmesh_triangle.cxx +++ b/src/t8_cmesh/t8_cmesh_io/t8_cmesh_triangle.cxx @@ -95,7 +95,7 @@ t8_cmesh_triangle_read_nodes ([[maybe_unused]] t8_cmesh_t cmesh, char *filename, T8_ASSERT (filename != NULL); T8_ASSERT (dim == 2 || dim == 3); fp = fopen (filename, "r"); - if (fp == NULL) { + if (fp == nullptr) { t8_global_errorf ("Failed to open %s.\n", filename); goto die_node; } @@ -156,7 +156,7 @@ t8_cmesh_triangle_read_nodes ([[maybe_unused]] t8_cmesh_t cmesh, char *filename, die_node: /* Clean up on error. */ /* Close open file */ - if (fp != NULL) { + if (fp != nullptr) { fclose (fp); } free (line); @@ -196,7 +196,7 @@ t8_cmesh_triangle_read_eles (t8_cmesh_t cmesh, int corner_offset, char *filename T8_ASSERT (filename != NULL); T8_ASSERT (dim == 2 || dim == 3); fp = fopen (filename, "r"); - if (fp == NULL) { + if (fp == nullptr) { t8_global_errorf ("Failed to open %s.\n", filename); goto die_ele; } @@ -267,7 +267,7 @@ t8_cmesh_triangle_read_eles (t8_cmesh_t cmesh, int corner_offset, char *filename die_ele: /* Clean up on error. */ /* Close open file */ - if (fp != NULL) { + if (fp != nullptr) { fclose (fp); } T8_FREE (vertices); @@ -286,7 +286,7 @@ t8_cmesh_triangle_read_neigh (t8_cmesh_t cmesh, int element_offset, char *filena size_t linen = 1024; t8_locidx_t element; t8_locidx_t num_elems; - t8_locidx_t *tneighbors = NULL; + t8_locidx_t *tneighbors = nullptr; int retval; int temp; int num_read; @@ -296,7 +296,7 @@ t8_cmesh_triangle_read_neigh (t8_cmesh_t cmesh, int element_offset, char *filena T8_ASSERT (filename != NULL); T8_ASSERT (dim == 2 || dim == 3); fp = fopen (filename, "r"); - if (fp == NULL) { + if (fp == nullptr) { t8_global_errorf ("Failed to open %s.\n", filename); goto die_neigh; } @@ -343,7 +343,7 @@ t8_cmesh_triangle_read_neigh (t8_cmesh_t cmesh, int element_offset, char *filena } /* We are done reading the file. */ fclose (fp); - fp = NULL; + fp = nullptr; /* To compute the face neighbor orientations it is necessary to look up the * vertices of a given tree_id. This is only possible if the attribute array @@ -353,7 +353,7 @@ t8_cmesh_triangle_read_neigh (t8_cmesh_t cmesh, int element_offset, char *filena /* Find the neighboring faces */ for (t8_locidx_t tit = 0; tit < num_elems; tit++) { for (t8_locidx_t tneigh = 0; tneigh < num_faces; tneigh++) { - t8_locidx_t neighbor = tneighbors[num_faces * tit + tneigh] - element_offset; + t8_locidx_t const neighbor = tneighbors[num_faces * tit + tneigh] - element_offset; if (neighbor != -1 - element_offset && tit < neighbor) { /* Error tolerance for vertex coordinate equality. * We consider vertices to be equal if all their coordinates @@ -408,14 +408,14 @@ t8_cmesh_triangle_read_neigh (t8_cmesh_t cmesh, int element_offset, char *filena int orientation = -1; int found_orientation = 0; - int firstvertex = face1 == 0 ? 1 : 0; + int const firstvertex = face1 == 0 ? 1 : 0; for (int ivertex = 1; ivertex <= dim && !found_orientation; ivertex++) { /* The face with number k consists of the vertices with numbers * k+1, k+2, k+3 (mod 4) or k+1, k+2 (mod 3) in case of triangles. * In el_vertices are the coordinates of these vertices in order * v_0x v_0y v_0z v_1x v_1y ... */ - int el_vertex = (face2 + ivertex) % num_faces; + int const el_vertex = (face2 + ivertex) % num_faces; if (fabs (el_vertices1[3 * firstvertex] - el_vertices2[3 * el_vertex]) < tolerance && fabs (el_vertices1[3 * firstvertex + 1] - el_vertices2[3 * el_vertex + 1]) < tolerance && fabs (el_vertices1[3 * firstvertex + 2] - el_vertices2[3 * el_vertex + 2]) < tolerance) { @@ -488,7 +488,7 @@ t8_cmesh_triangle_read_neigh (t8_cmesh_t cmesh, int element_offset, char *filena /* Clean up on error. */ T8_FREE (tneighbors); /* Close open file */ - if (fp != NULL) { + if (fp != nullptr) { fclose (fp); } free (line); @@ -511,7 +511,7 @@ t8_cmesh_from_tetgen_or_triangle_file (char *fileprefix, int partition, sc_MPI_C mpiret = sc_MPI_Comm_rank (comm, &mpirank); SC_CHECK_MPI (mpiret); - cmesh = NULL; + cmesh = nullptr; { int retval, corner_offset = 0; char current_file[BUFSIZ]; @@ -525,7 +525,7 @@ t8_cmesh_from_tetgen_or_triangle_file (char *fileprefix, int partition, sc_MPI_C if (retval != 0 && retval != 1) { t8_global_errorf ("Error while parsing file %s.\n", current_file); t8_cmesh_unref (&cmesh); - return NULL; + return nullptr; } else { /* read .ele file */ @@ -540,7 +540,7 @@ t8_cmesh_from_tetgen_or_triangle_file (char *fileprefix, int partition, sc_MPI_C if (retval != 0 && retval != 1) { t8_global_errorf ("Error while parsing file %s.\n", current_file); t8_cmesh_unref (&cmesh); - return NULL; + return nullptr; } else { /* read .neigh file */ @@ -549,7 +549,7 @@ t8_cmesh_from_tetgen_or_triangle_file (char *fileprefix, int partition, sc_MPI_C if (retval != 0) { t8_global_errorf ("Error while parsing file %s.\n", current_file); t8_cmesh_unref (&cmesh); - return NULL; + return nullptr; } } } @@ -559,7 +559,7 @@ t8_cmesh_from_tetgen_or_triangle_file (char *fileprefix, int partition, sc_MPI_C * other processes if something went wrong. */ /* This broadcasts the NULL pointer if anything went wrong */ - if (cmesh != NULL) { + if (cmesh != nullptr) { if (partition) { first_tree = (mpirank * cmesh->num_trees) / mpisize; last_tree = ((mpirank + 1) * cmesh->num_trees) / mpisize - 1; @@ -593,7 +593,7 @@ t8_cmesh_from_tetgen_or_triangle_file_time (char *fileprefix, int partition, sc_ mpiret = sc_MPI_Comm_rank (comm, &mpirank); SC_CHECK_MPI (mpiret); - cmesh = NULL; + cmesh = nullptr; if (mpirank == 0 || partition) { int retval, corner_offset; char current_file[BUFSIZ]; @@ -605,7 +605,7 @@ t8_cmesh_from_tetgen_or_triangle_file_time (char *fileprefix, int partition, sc_ if (retval != 0 && retval != 1) { t8_global_errorf ("Error while parsing file %s.\n", current_file); t8_cmesh_unref (&cmesh); - return NULL; + return nullptr; } else { /* read .ele file */ @@ -620,7 +620,7 @@ t8_cmesh_from_tetgen_or_triangle_file_time (char *fileprefix, int partition, sc_ if (retval != 0 && retval != 1) { t8_global_errorf ("Error while parsing file %s.\n", current_file); t8_cmesh_unref (&cmesh); - return NULL; + return nullptr; } else { /* read .neigh file */ @@ -642,7 +642,7 @@ t8_cmesh_from_tetgen_or_triangle_file_time (char *fileprefix, int partition, sc_ cmesh = t8_cmesh_bcast (cmesh, 0, comm); } - if (cmesh != NULL) { + if (cmesh != nullptr) { /* Use linear geometry. * We need to set the geometry after the broadcast. */ t8_cmesh_register_geometry (cmesh); diff --git a/src/t8_cmesh/t8_cmesh_vertex_connectivity/t8_cmesh_vertex_conn_tree_to_vertex.cxx b/src/t8_cmesh/t8_cmesh_vertex_connectivity/t8_cmesh_vertex_conn_tree_to_vertex.cxx index 157f453f1c..c963f54083 100644 --- a/src/t8_cmesh/t8_cmesh_vertex_connectivity/t8_cmesh_vertex_conn_tree_to_vertex.cxx +++ b/src/t8_cmesh/t8_cmesh_vertex_connectivity/t8_cmesh_vertex_conn_tree_to_vertex.cxx @@ -56,7 +56,7 @@ t8_cmesh_vertex_conn_tree_to_vertex::t8_cmesh_vertex_conn_tree_to_vertex ( /* Iterate over all entries of the vertex list, * thus, each entry is a local tree id and vertex index. */ for (auto &[tree_index, vertex_index] : vertex_list) { - global_local_index_pair new_pair (global_vertex, vertex_index); + global_local_index_pair const new_pair (global_vertex, vertex_index); global_ids_per_tree[tree_index].push_back (new_pair); } } diff --git a/src/t8_cmesh/t8_cmesh_vertex_connectivity/t8_cmesh_vertex_conn_vertex_to_tree.cxx b/src/t8_cmesh/t8_cmesh_vertex_connectivity/t8_cmesh_vertex_conn_vertex_to_tree.cxx index 925649b1b2..e080fc904e 100644 --- a/src/t8_cmesh/t8_cmesh_vertex_connectivity/t8_cmesh_vertex_conn_vertex_to_tree.cxx +++ b/src/t8_cmesh/t8_cmesh_vertex_connectivity/t8_cmesh_vertex_conn_vertex_to_tree.cxx @@ -95,7 +95,7 @@ t8_cmesh_vertex_conn_vertex_to_tree::add_vertex_to_tree ([[maybe_unused]] const SC_ABORTF ("%s:%i: Trying to add vertex to committed vertex to tree structure.\n", __FILE__, __LINE__); } - tree_vertex_pair pair (ltreeid, tree_vertex); + tree_vertex_pair const pair (ltreeid, tree_vertex); tree_vertex_list& list_of_globalid = vertex_to_tree[global_vertex_id]; list_of_globalid.push_back (pair); @@ -189,7 +189,7 @@ t8_cmesh_vertex_conn_vertex_to_tree::contains_all_vertices (const t8_cmesh_t cme } /* Now all entries must be set to 0 */ - for (int& entry : vertex_counts) { + for (int const& entry : vertex_counts) { if (entry != 0) { return 0; } diff --git a/src/t8_data/t8_containers.cxx b/src/t8_data/t8_containers.cxx index e025c9ed6b..b9e9c09098 100644 --- a/src/t8_data/t8_containers.cxx +++ b/src/t8_data/t8_containers.cxx @@ -298,7 +298,7 @@ t8_element_array_get_data (const t8_element_array_t *element_array) return (t8_element_t *) t8_element_array_index_locidx (element_array, 0); } else { - return NULL; + return nullptr; } } diff --git a/src/t8_forest/t8_forest.cxx b/src/t8_forest/t8_forest.cxx index 004a313113..67fa76a6b3 100644 --- a/src/t8_forest/t8_forest.cxx +++ b/src/t8_forest/t8_forest.cxx @@ -428,7 +428,7 @@ t8_forest_element_from_ref_coords_ext (t8_forest_t forest, t8_locidx_t ltreeid, double *tree_ref_coords = T8_ALLOC (double, (tree_dim == 0 ? 1 : tree_dim) * num_coords); - if (stretch_factors != NULL) { + if (stretch_factors != nullptr) { #if T8_ENABLE_DEBUG const t8_geometry_type_t geom_type = t8_geometry_get_type (cmesh, gtreeid); T8_ASSERT (geom_type == T8_GEOMETRY_TYPE_LINEAR || geom_type == T8_GEOMETRY_TYPE_LINEAR_AXIS_ALIGNED); @@ -456,7 +456,7 @@ void t8_forest_element_from_ref_coords (t8_forest_t forest, t8_locidx_t ltreeid, const t8_element_t *element, const double *ref_coords, const size_t num_coords, double *coords_out) { - t8_forest_element_from_ref_coords_ext (forest, ltreeid, element, ref_coords, num_coords, coords_out, NULL); + t8_forest_element_from_ref_coords_ext (forest, ltreeid, element, ref_coords, num_coords, coords_out, nullptr); } /* Compute the diameter of an element. */ @@ -1112,8 +1112,8 @@ t8_forest_compute_desc (t8_forest_t forest) if (t8_forest_get_tree_leaf_element_count (itree) < 1) { /* if local tree is empty */ T8_ASSERT (forest->incomplete_trees); - itree->first_desc = NULL; - itree->last_desc = NULL; + itree->first_desc = nullptr; + itree->last_desc = nullptr; continue; } /* get the eclass associated to tree */ @@ -1159,12 +1159,12 @@ t8_forest_populate (t8_forest_t forest, const int irregular) if (irregular) { t8_cmesh_uniform_bounds_for_irregular_refinement ( forest->cmesh, forest->set_level, forest->scheme, &forest->first_local_tree, &child_in_tree_begin, - &forest->last_local_tree, &child_in_tree_end, NULL, forest->mpicomm); + &forest->last_local_tree, &child_in_tree_end, nullptr, forest->mpicomm); } else { t8_cmesh_uniform_bounds_equal_element_count (forest->cmesh, forest->set_level, forest->scheme, &forest->first_local_tree, &child_in_tree_begin, - &forest->last_local_tree, &child_in_tree_end, NULL); + &forest->last_local_tree, &child_in_tree_end, nullptr); } /* True if the forest has no elements */ is_empty = forest->first_local_tree > forest->last_local_tree @@ -1314,7 +1314,7 @@ t8_forest_tree_shared ([[maybe_unused]] t8_forest_t forest, [[maybe_unused]] int return global_neighbour_tree_idx == forest->first_local_tree && forest->last_local_tree != -1; } else { - if (forest->local_num_leaf_elements <= 0 || forest->trees == NULL + if (forest->local_num_leaf_elements <= 0 || forest->trees == nullptr || forest->first_local_tree > forest->last_local_tree) { /* This forest is empty and therefore the first tree is not shared */ return 0; @@ -1606,11 +1606,11 @@ t8_forest_element_half_face_neighbors (t8_forest_t forest, t8_locidx_t ltreeid, // Build the half face neighbors by constructing the children at the face. scheme->element_get_children_at_face (neigh_class, same_level_neighbor, same_level_dual_face, neighs, num_neighs, - NULL); + nullptr); // We now need to compute the dual faces of the children. // We do this with the scheme function - if (dual_faces != NULL) { + if (dual_faces != nullptr) { for (int iface_child = 0; iface_child < num_neighs; ++iface_child) { dual_faces[iface_child] = scheme->element_face_get_child_face (neigh_class, same_level_neighbor, same_level_dual_face, iface_child); @@ -1628,9 +1628,9 @@ t8_forest_leaf_face_orientation (t8_forest_t forest, const t8_locidx_t ltreeid, const t8_eclass_t tree_class = t8_forest_get_tree_class (forest, ltreeid); if (scheme->element_is_root_boundary (tree_class, leaf, face)) { t8_cmesh_t cmesh = t8_forest_get_cmesh (forest); - t8_locidx_t ltreeid_in_cmesh = t8_forest_ltreeid_to_cmesh_ltreeid (forest, ltreeid); - int iface_in_tree = scheme->element_get_tree_face (tree_class, leaf, face); - t8_cmesh_get_face_neighbor (cmesh, ltreeid_in_cmesh, iface_in_tree, NULL, &orientation); + t8_locidx_t const ltreeid_in_cmesh = t8_forest_ltreeid_to_cmesh_ltreeid (forest, ltreeid); + int const iface_in_tree = scheme->element_get_tree_face (tree_class, leaf, face); + t8_cmesh_get_face_neighbor (cmesh, ltreeid_in_cmesh, iface_in_tree, nullptr, &orientation); } return orientation; @@ -1658,7 +1658,7 @@ t8_forest_leaf_face_neighbors_ext (t8_forest_t forest, t8_locidx_t ltreeid, cons T8_ASSERT (!forest_is_balanced || t8_forest_is_balanced (forest)); SC_CHECK_ABORT (forest_is_balanced, "leaf face neighbors is not implemented " "for unbalanced forests.\n"); /* TODO: write version for unbalanced forests */ - SC_CHECK_ABORT (forest->mpisize == 1 || forest->ghosts != NULL, + SC_CHECK_ABORT (forest->mpisize == 1 || forest->ghosts != nullptr, "Ghost structure is needed for t8_forest_leaf_face_neighbors " "but was not found in forest.\n"); @@ -1703,10 +1703,10 @@ t8_forest_leaf_face_neighbors_ext (t8_forest_t forest, t8_locidx_t ltreeid, cons scheme->element_destroy (*pneigh_eclass, num_children_at_face, neighbor_leaves); T8_FREE (neighbor_leaves); T8_FREE (*dual_faces); - *dual_faces = NULL; + *dual_faces = nullptr; *num_neighbors = 0; - *pelement_indices = NULL; - *pneighbor_leaves = NULL; + *pelement_indices = nullptr; + *pneighbor_leaves = nullptr; return; } T8_ASSERT (gneigh_treeid >= 0 && gneigh_treeid < forest->global_num_trees); @@ -1882,7 +1882,7 @@ t8_forest_leaf_face_neighbors (t8_forest_t forest, t8_locidx_t ltreeid, const t8 t8_locidx_t **pelement_indices, t8_eclass_t *pneigh_eclass, int forest_is_balanced) { t8_forest_leaf_face_neighbors_ext (forest, ltreeid, leaf, pneighbor_leaves, face, dual_faces, num_neighbors, - pelement_indices, pneigh_eclass, forest_is_balanced, NULL, NULL); + pelement_indices, pneigh_eclass, forest_is_balanced, nullptr, nullptr); } void @@ -1899,15 +1899,15 @@ t8_forest_print_all_leaf_neighbors (t8_forest_t forest) int allocate_first_desc = 0, allocate_tree_offset = 0; int allocate_el_offset = 0; - if (forest->tree_offsets == NULL) { + if (forest->tree_offsets == nullptr) { allocate_tree_offset = 1; t8_forest_partition_create_tree_offsets (forest); } - if (forest->global_first_desc == NULL) { + if (forest->global_first_desc == nullptr) { allocate_first_desc = 1; t8_forest_partition_create_first_desc (forest); } - if (forest->element_offsets == NULL) { + if (forest->element_offsets == nullptr) { allocate_el_offset = 1; t8_forest_partition_create_offsets (forest); } @@ -2075,9 +2075,9 @@ static int t8_forest_element_find_owner_compare (const void *find_owner_data, const void *process) { const struct find_owner_data_t *data = (const struct find_owner_data_t *) find_owner_data; - t8_linearidx_t linear_id = data->linear_id; + t8_linearidx_t const linear_id = data->linear_id; t8_forest_t forest = data->forest; - int proc = *(int *) process; + int const proc = *(int *) process; t8_linearidx_t proc_first_desc_id; t8_linearidx_t next_proc_first_desc_id; @@ -2274,14 +2274,14 @@ t8_forest_element_find_owner_old (t8_forest_t forest, t8_gloidx_t gtreeid, t8_el ssize_t proc_index; struct find_owner_data_t find_owner_data; - if (forest->tree_offsets == NULL) { + if (forest->tree_offsets == nullptr) { /* If the offset of global tree ids is not created, create it now. * Once created, we do not delete it in this function, since we expect * multiple calls to find_owner in a row. */ t8_forest_partition_create_tree_offsets (forest); } - if (forest->global_first_desc == NULL) { + if (forest->global_first_desc == nullptr) { /* If the offset of first global ids is not created, create it now. * Once created, we do not delete it in this function, since we expect * multiple calls to find_owner in a row. @@ -2291,7 +2291,7 @@ t8_forest_element_find_owner_old (t8_forest_t forest, t8_gloidx_t gtreeid, t8_el /* In owners_of_tree we will store all processes that have elements of the * tree gtreeid. */ - if (all_owners_of_tree == NULL) { + if (all_owners_of_tree == nullptr) { owners_of_tree = sc_array_new (sizeof (int)); } else { @@ -2317,7 +2317,7 @@ t8_forest_element_find_owner_old (t8_forest_t forest, t8_gloidx_t gtreeid, t8_el if (owners_of_tree->elem_count == 1) { /* There is only this proc as possible owner. */ scheme->element_destroy (eclass, 1, &element_first_desc); - if (all_owners_of_tree == NULL) { + if (all_owners_of_tree == nullptr) { sc_array_destroy (owners_of_tree); } return proc; @@ -2329,7 +2329,7 @@ t8_forest_element_find_owner_old (t8_forest_t forest, t8_gloidx_t gtreeid, t8_el if (*(t8_linearidx_t *) t8_shmem_array_index (forest->global_first_desc, (size_t) proc_next) > element_desc_lin_id) { scheme->element_destroy (eclass, 1, &element_first_desc); - if (all_owners_of_tree == NULL) { + if (all_owners_of_tree == nullptr) { sc_array_destroy (owners_of_tree); } return proc; @@ -2353,7 +2353,7 @@ t8_forest_element_find_owner_old (t8_forest_t forest, t8_gloidx_t gtreeid, t8_el proc = *(int *) sc_array_index_ssize_t (&owners_of_tree_wo_first, proc_index); /* clean-up */ scheme->element_destroy (eclass, 1, &element_first_desc); - if (all_owners_of_tree == NULL) { + if (all_owners_of_tree == nullptr) { sc_array_destroy (owners_of_tree); } return proc; @@ -2379,14 +2379,14 @@ t8_forest_element_owners_at_face_recursion (t8_forest_t forest, t8_gloidx_t gtre T8_ASSERT (element != NULL); /* Create first and last descendants at face */ - if (first_desc == NULL) { + if (first_desc == nullptr) { scheme->element_new (eclass, 1, &first_face_desc); scheme->element_get_first_descendant_face (eclass, element, face, first_face_desc, forest->maxlevel); } else { first_face_desc = first_desc; } - if (last_desc == NULL) { + if (last_desc == nullptr) { scheme->element_new (eclass, 1, &last_face_desc); scheme->element_get_last_descendant_face (eclass, element, face, last_face_desc, forest->maxlevel); } @@ -2448,15 +2448,15 @@ t8_forest_element_owners_at_face_recursion (t8_forest_t forest, t8_gloidx_t gtre face_children = T8_ALLOC (t8_element_t *, num_children); scheme->element_new (eclass, num_children, face_children); /* construct the children of element that touch face */ - scheme->element_get_children_at_face (eclass, element, face, face_children, num_children, NULL); + scheme->element_get_children_at_face (eclass, element, face, face_children, num_children, nullptr); for (ichild = 0; ichild < num_children; ichild++) { /* the face number of the child may not be the same as face */ child_face = scheme->element_face_get_child_face (eclass, element, face, ichild); /* find owners of this child */ /* For the first child, we reuse the first descendant */ - first_desc = (ichild == 0 ? first_face_desc : NULL); + first_desc = (ichild == 0 ? first_face_desc : nullptr); /* For the last child, we reuse the last descendant */ - last_desc = (ichild == num_children - 1 ? last_face_desc : NULL); + last_desc = (ichild == num_children - 1 ? last_face_desc : nullptr); t8_forest_element_owners_at_face_recursion (forest, gtreeid, face_children[ichild], eclass, child_face, owners, lower_bound, upper_bound, first_desc, last_desc); } @@ -2493,7 +2493,7 @@ t8_forest_element_owners_at_face (t8_forest_t forest, t8_gloidx_t gtreeid, const } /* call the recursion */ t8_forest_element_owners_at_face_recursion (forest, gtreeid, element, eclass, face, owners, lower_bound, upper_bound, - NULL, NULL); + nullptr, nullptr); } void @@ -2650,7 +2650,7 @@ t8_forest_element_has_leaf_desc (t8_forest_t forest, t8_gloidx_t gtreeid, const } } } - if (forest->ghosts != NULL) { + if (forest->ghosts != nullptr) { /* Check if the tree is a ghost tree and if so, check its elements as well */ ghost_treeid = t8_forest_ghost_get_ghost_treeid (forest, gtreeid); if (ghost_treeid >= 0) { @@ -2709,13 +2709,13 @@ t8_forest_init (t8_forest_t *pforest) int t8_forest_is_initialized (t8_forest_t forest) { - return forest != NULL && t8_refcount_is_active (&forest->rc) && !forest->committed; + return forest != nullptr && t8_refcount_is_active (&forest->rc) && !forest->committed; } int t8_forest_is_committed (const t8_forest_t forest) { - return forest != NULL && t8_refcount_is_active (&forest->rc) && forest->committed; + return forest != nullptr && t8_refcount_is_active (&forest->rc) && forest->committed; } static void @@ -2746,10 +2746,10 @@ t8_forest_set_cmesh (t8_forest_t forest, t8_cmesh_t cmesh, sc_MPI_Comm comm) T8_ASSERT (cmesh != NULL); - if (forest->cmesh != NULL) { + if (forest->cmesh != nullptr) { t8_cmesh_unref (&forest->cmesh); } - if (cmesh != NULL) { + if (cmesh != nullptr) { T8_ASSERT (t8_cmesh_comm_is_valid (cmesh, comm)); } forest->cmesh = cmesh; @@ -2801,7 +2801,7 @@ t8_forest_set_copy (t8_forest_t forest, const t8_forest_t set_from) forest->from_method = T8_FOREST_FROM_COPY; /* Overwrite any previous setting */ - forest->set_adapt_fn = NULL; + forest->set_adapt_fn = nullptr; forest->set_adapt_recursive = -1; forest->set_balance = -1; forest->set_for_coarsening = -1; @@ -2819,7 +2819,7 @@ t8_forest_set_partition (t8_forest_t forest, const t8_forest_t set_from, int set forest->set_for_coarsening = set_for_coarsening; - if (set_from != NULL) { + if (set_from != nullptr) { /* If set_from = NULL, we assume a previous forest_from was set */ forest->set_from = set_from; } @@ -2847,7 +2847,7 @@ t8_forest_set_balance (t8_forest_t forest, const t8_forest_t set_from, int no_re forest->set_balance = T8_FOREST_BALANCE_REPART; } - if (set_from != NULL) { + if (set_from != nullptr) { /* If set_from = NULL, we assume a previous forest_from was set */ forest->set_from = set_from; } @@ -2906,7 +2906,7 @@ t8_forest_set_adapt (t8_forest_t forest, const t8_forest_t set_from, t8_forest_a forest->set_adapt_fn = adapt_fn; forest->set_adapt_recursive = recursive != 0; - if (set_from != NULL) { + if (set_from != nullptr) { /* If set_from = NULL, we assume a previous forest_from was set */ forest->set_from = set_from; } @@ -3024,12 +3024,12 @@ t8_forest_commit (t8_forest_t forest) T8_ASSERT (forest != NULL); T8_ASSERT (forest->rc.refcount > 0); T8_ASSERT (!forest->committed); - if (forest->profile != NULL) { + if (forest->profile != nullptr) { /* If profiling is enabled, we measure the runtime of commit */ forest->profile->commit_runtime = sc_MPI_Wtime (); } - if (forest->set_from == NULL) { + if (forest->set_from == nullptr) { /* This forest is constructed solely from its cmesh as a uniform * forest */ T8_ASSERT (forest->mpicomm != sc_MPI_COMM_NULL); @@ -3105,14 +3105,14 @@ t8_forest_commit (t8_forest_t forest) /* Compute the maximum allowed refinement level */ t8_forest_compute_maxlevel (forest); if (forest->from_method == T8_FOREST_FROM_COPY) { - SC_CHECK_ABORT (forest->set_from != NULL, "No forest to copy from was specified."); + SC_CHECK_ABORT (forest->set_from != nullptr, "No forest to copy from was specified."); t8_forest_copy_trees (forest, forest->set_from, 1); } /* TODO: currently we can only handle copy, adapt, partition, and balance */ /* T8_ASSERT (forest->from_method == T8_FOREST_FROM_COPY); */ if (forest->from_method & T8_FOREST_FROM_ADAPT) { - SC_CHECK_ABORT (forest->set_adapt_fn != NULL, "No adapt function specified"); + SC_CHECK_ABORT (forest->set_adapt_fn != nullptr, "No adapt function specified"); forest->from_method -= T8_FOREST_FROM_ADAPT; if (forest->from_method > 0) { /* The forest should also be partitioned/balanced. @@ -3127,14 +3127,14 @@ t8_forest_commit (t8_forest_t forest) /* Construct an intermediate, adapted forest */ t8_forest_set_adapt (forest_adapt, forest->set_from, forest->set_adapt_fn, forest->set_adapt_recursive); /* Set profiling if enabled */ - t8_forest_set_profiling (forest_adapt, forest->profile != NULL); + t8_forest_set_profiling (forest_adapt, forest->profile != nullptr); t8_forest_commit (forest_adapt); /* The new forest will be partitioned/balanced from forest_adapt */ forest->set_from = forest_adapt; /* Set the user data of forest_from to forest_adapt */ t8_forest_set_user_data (forest_adapt, t8_forest_get_user_data (forest_from)); /* If profiling is enabled copy the runtime of adapt. */ - if (forest->profile != NULL) { + if (forest->profile != nullptr) { forest->profile->adapt_runtime = forest_adapt->profile->adapt_runtime; } } @@ -3160,11 +3160,11 @@ t8_forest_commit (t8_forest_t forest) } t8_forest_set_partition (forest_partition, forest->set_from, forest->set_for_coarsening); /* activate profiling, if this forest has profiling */ - t8_forest_set_profiling (forest_partition, forest->profile != NULL); + t8_forest_set_profiling (forest_partition, forest->profile != nullptr); /* Commit the partitioned forest */ t8_forest_commit (forest_partition); forest->set_from = forest_partition; - if (forest->profile != NULL) { + if (forest->profile != nullptr) { forest->profile->partition_bytes_sent = forest_partition->profile->partition_bytes_sent; forest->profile->partition_elements_recv = forest_partition->profile->partition_elements_recv; forest->profile->partition_elements_shipped = forest_partition->profile->partition_elements_shipped; @@ -3219,27 +3219,27 @@ t8_forest_commit (t8_forest_t forest) /* we do not need the set parameters anymore */ forest->set_level = 0; forest->set_for_coarsening = 0; - forest->set_from = NULL; + forest->set_from = nullptr; forest->committed = 1; t8_debugf ("Committed forest with %li local elements and %lli " "global elements.\n\tTree range is from %lli to %lli.\n", (long) forest->local_num_leaf_elements, (long long) forest->global_num_leaf_elements, (long long) forest->first_local_tree, (long long) forest->last_local_tree); - if (forest->tree_offsets == NULL) { + if (forest->tree_offsets == nullptr) { /* Compute the tree offset array */ t8_forest_partition_create_tree_offsets (forest); } - if (forest->element_offsets == NULL) { + if (forest->element_offsets == nullptr) { /* Compute element offsets */ t8_forest_partition_create_offsets (forest); } - if (forest->global_first_desc == NULL) { + if (forest->global_first_desc == nullptr) { /* Compute global first desc array */ t8_forest_partition_create_first_desc (forest); } - if (forest->profile != NULL) { + if (forest->profile != nullptr) { /* If profiling is enabled, we measure the runtime of commit */ forest->profile->commit_runtime = sc_MPI_Wtime () - forest->profile->commit_runtime; } @@ -3248,7 +3248,7 @@ t8_forest_commit (t8_forest_t forest) /* re-partition the cmesh */ if (forest->cmesh->set_partition && partitioned) { - t8_forest_partition_cmesh (forest, forest->mpicomm, forest->profile != NULL); + t8_forest_partition_cmesh (forest, forest->mpicomm, forest->profile != nullptr); } if (forest->mpisize > 1) { @@ -3299,7 +3299,7 @@ t8_forest_get_num_ghosts (const t8_forest_t forest) T8_ASSERT (t8_forest_is_committed (forest)); /* Return the number of ghost elements, or 0 if no ghost structure exists. */ - if (forest->ghosts == NULL) { + if (forest->ghosts == nullptr) { return 0; } return forest->ghosts->num_ghosts_elements; @@ -3315,7 +3315,7 @@ t8_forest_compute_cmesh_offset (t8_forest_t forest, sc_MPI_Comm comm) { t8_shmem_array_t offset; - if (forest->tree_offsets == NULL) { + if (forest->tree_offsets == nullptr) { /* Create the tree offsets if necessary */ t8_forest_partition_create_tree_offsets (forest); } @@ -3339,7 +3339,7 @@ t8_forest_partition_cmesh (t8_forest_t forest, sc_MPI_Comm comm, int set_profili t8_cmesh_init (&cmesh_partition); t8_cmesh_set_derive (cmesh_partition, forest->cmesh); /* set partition range of new cmesh according to forest trees */ - if (forest->tree_offsets == NULL) { + if (forest->tree_offsets == nullptr) { t8_forest_partition_create_tree_offsets (forest); } offsets = t8_forest_compute_cmesh_offset (forest, comm); @@ -3372,7 +3372,7 @@ t8_forest_get_first_local_tree_id (const t8_forest_t forest) t8_locidx_t t8_forest_get_num_ghost_trees (const t8_forest_t forest) { - if (forest->ghosts != NULL) { + if (forest->ghosts != nullptr) { return t8_forest_ghost_num_trees (forest); } else { @@ -3463,7 +3463,7 @@ t8_forest_get_cmesh (const t8_forest_t forest) static int t8_forest_compare_elem_tree (const void *lelement_id, const void *ltree) { - t8_locidx_t leid = *(const t8_locidx_t *) lelement_id; + t8_locidx_t const leid = *(const t8_locidx_t *) lelement_id; const t8_tree_t tree = (t8_tree_t) ltree; if (tree->elements_offset > leid) { @@ -3492,7 +3492,7 @@ t8_forest_get_leaf_element (t8_forest_t forest, t8_locidx_t lelement_id, t8_loci T8_ASSERT (t8_forest_is_committed (forest)); T8_ASSERT (lelement_id >= 0); if (lelement_id >= t8_forest_get_local_num_leaf_elements (forest)) { - return NULL; + return nullptr; } /* We optimized the binary search out by using sc_bsearch, * but keep it in for debugging. We check whether the hand-written @@ -3523,7 +3523,7 @@ t8_forest_get_leaf_element (t8_forest_t forest, t8_locidx_t lelement_id, t8_loci #endif ltree = sc_array_bsearch (forest->trees, &lelement_id, t8_forest_compare_elem_tree); T8_ASSERT (ltreedebug == ltree); - if (ltreeid != NULL) { + if (ltreeid != nullptr) { *ltreeid = ltree; } @@ -3537,7 +3537,7 @@ t8_forest_get_leaf_element (t8_forest_t forest, t8_locidx_t lelement_id, t8_loci /* The element was not found. * This case is covered by the first if and should therefore never happen. */ SC_ABORT_NOT_REACHED (); - return NULL; + return nullptr; } const t8_element_t * @@ -3585,7 +3585,7 @@ t8_forest_get_tree_num_leaf_elements (t8_forest_t forest, t8_locidx_t ltreeid) t8_eclass_t t8_forest_get_tree_class (const t8_forest_t forest, const t8_locidx_t ltreeid) { - t8_locidx_t num_local_trees = t8_forest_get_num_local_trees (forest); + t8_locidx_t const num_local_trees = t8_forest_get_num_local_trees (forest); T8_ASSERT (0 <= ltreeid && ltreeid < num_local_trees + t8_forest_get_num_ghost_trees (forest)); if (ltreeid < num_local_trees) { /* The id belongs to a local tree */ @@ -3603,7 +3603,7 @@ t8_forest_get_first_local_leaf_element_id (t8_forest_t forest) { T8_ASSERT (t8_forest_is_committed (forest)); - if (forest->element_offsets != NULL) { + if (forest->element_offsets != nullptr) { return t8_shmem_array_get_gloidx (forest->element_offsets, forest->mpirank); } return -1; @@ -3672,7 +3672,7 @@ t8_forest_get_local_or_ghost_id (const t8_forest_t forest, const t8_gloidx_t gtr return ltreeid; } else { - t8_locidx_t ghost_id = t8_forest_ghost_get_ghost_treeid (forest, gtreeid); + t8_locidx_t const ghost_id = t8_forest_ghost_get_ghost_treeid (forest, gtreeid); if (ghost_id >= 0) return t8_forest_get_num_local_trees (forest) + ghost_id; return -1; @@ -3745,7 +3745,7 @@ t8_forest_get_coarse_tree_ext (t8_forest_t forest, t8_locidx_t ltreeid, t8_locid t8_ctree_t t8_forest_get_coarse_tree (t8_forest_t forest, t8_locidx_t ltreeid) { - return t8_forest_get_coarse_tree_ext (forest, ltreeid, NULL, NULL); + return t8_forest_get_coarse_tree_ext (forest, ltreeid, nullptr, nullptr); } void @@ -3754,14 +3754,14 @@ t8_forest_set_profiling (t8_forest_t forest, int set_profiling) T8_ASSERT (t8_forest_is_initialized (forest)); if (set_profiling) { - if (forest->profile == NULL) { + if (forest->profile == nullptr) { /* Only do something if profiling is not enabled already */ forest->profile = T8_ALLOC_ZERO (t8_profile_struct_t, 1); } } else { /* Free any profile that is already set */ - if (forest->profile != NULL) { + if (forest->profile != nullptr) { T8_FREE (forest->profile); } } @@ -3771,7 +3771,7 @@ void t8_forest_compute_profile (t8_forest_t forest) { T8_ASSERT (t8_forest_is_committed (forest)); - if (forest->profile != NULL) { + if (forest->profile != nullptr) { /* Only print something if profiling is enabled */ t8_profile_t *profile = forest->profile; @@ -3804,7 +3804,7 @@ void t8_forest_print_profile (t8_forest_t forest) { T8_ASSERT (t8_forest_is_committed (forest)); - if (forest->profile != NULL) { + if (forest->profile != nullptr) { /* Compute the stats if not already computed. */ if (!forest->stats_computed) { t8_forest_compute_profile (forest); @@ -3873,7 +3873,7 @@ double t8_forest_profile_get_adapt_time (t8_forest_t forest) { T8_ASSERT (t8_forest_is_committed (forest)); - if (forest->profile != NULL) { + if (forest->profile != nullptr) { return forest->profile->adapt_runtime; } return 0; @@ -3883,7 +3883,7 @@ double t8_forest_profile_get_partition_time (t8_forest_t forest, int *procs_sent) { T8_ASSERT (t8_forest_is_committed (forest)); - if (forest->profile != NULL) { + if (forest->profile != nullptr) { *procs_sent = forest->profile->partition_procs_sent; return forest->profile->partition_runtime; } @@ -3894,7 +3894,7 @@ double t8_forest_profile_get_balance_time (t8_forest_t forest, int *balance_rounds) { T8_ASSERT (t8_forest_is_committed (forest)); - if (forest->profile != NULL) { + if (forest->profile != nullptr) { *balance_rounds = forest->profile->balance_rounds; return forest->profile->balance_runtime; } @@ -3905,7 +3905,7 @@ double t8_forest_profile_get_ghost_time (t8_forest_t forest, t8_locidx_t *ghosts_sent) { T8_ASSERT (t8_forest_is_committed (forest)); - if (forest->profile != NULL) { + if (forest->profile != nullptr) { *ghosts_sent = forest->profile->ghosts_shipped; return forest->profile->ghost_runtime; } @@ -3918,7 +3918,7 @@ t8_forest_profile_get_ghostexchange_waittime (t8_forest_t forest) { T8_ASSERT (t8_forest_is_committed (forest)); - if (forest->profile != NULL) { + if (forest->profile != nullptr) { return forest->profile->ghost_waittime; } return 0; @@ -3928,7 +3928,7 @@ double t8_forest_profile_get_cmesh_offsets_runtime (t8_forest_t forest) { T8_ASSERT (t8_forest_is_committed (forest)); - if (forest->profile != NULL) { + if (forest->profile != nullptr) { return forest->profile->cmesh_offsets_runtime; } return 0; @@ -3938,7 +3938,7 @@ double t8_forest_profile_get_forest_offsets_runtime (t8_forest_t forest) { T8_ASSERT (t8_forest_is_committed (forest)); - if (forest->profile != NULL) { + if (forest->profile != nullptr) { return forest->profile->forest_offsets_runtime; } return 0; @@ -3948,7 +3948,7 @@ double t8_forest_profile_get_first_descendant_runtime (t8_forest_t forest) { T8_ASSERT (t8_forest_is_committed (forest)); - if (forest->profile != NULL) { + if (forest->profile != nullptr) { return forest->profile->first_descendant_runtime; } return 0; @@ -4016,7 +4016,7 @@ t8_forest_write_vtk_ext (t8_forest_t forest, const char *fileprefix, const int w int t8_forest_write_vtk (t8_forest_t forest, const char *fileprefix) { - return t8_forest_write_vtk_ext (forest, fileprefix, 1, 1, 1, 1, 0, 0, 0, 0, NULL); + return t8_forest_write_vtk_ext (forest, fileprefix, 1, 1, 1, 1, 0, 0, 0, 0, nullptr); } t8_forest_t @@ -4066,7 +4066,7 @@ t8_forest_new_adapt (t8_forest_t forest_from, t8_forest_adapt_t adapt_fn, int re t8_forest_init (&forest); t8_forest_set_adapt (forest, forest_from, adapt_fn, recursive); t8_forest_set_ghost (forest, do_face_ghost, T8_GHOST_FACES); - if (user_data != NULL) { + if (user_data != nullptr) { t8_forest_set_user_data (forest, user_data); } t8_forest_commit (forest); @@ -4118,7 +4118,7 @@ t8_forest_reset (t8_forest_t *pforest) T8_ASSERT (forest->rc.refcount == 0); if (!forest->committed) { - if (forest->set_from != NULL) { + if (forest->set_from != nullptr) { /* in this case we have taken ownership and not released it yet */ t8_forest_unref (&forest->set_from); } @@ -4137,34 +4137,34 @@ t8_forest_reset (t8_forest_t *pforest) } /* Destroy the ghost layer if it exists */ - if (forest->ghosts != NULL) { + if (forest->ghosts != nullptr) { t8_forest_ghost_unref (&forest->ghosts); } /* we have taken ownership on calling t8_forest_set_* */ - if (forest->scheme != NULL) { + if (forest->scheme != nullptr) { forest->scheme->unref (); } - if (forest->cmesh != NULL) { + if (forest->cmesh != nullptr) { t8_cmesh_unref (&forest->cmesh); } /* free the memory of the offset array */ - if (forest->element_offsets != NULL) { + if (forest->element_offsets != nullptr) { t8_shmem_array_destroy (&forest->element_offsets); } /* free the memory of the global_first_desc array */ - if (forest->global_first_desc != NULL) { + if (forest->global_first_desc != nullptr) { t8_shmem_array_destroy (&forest->global_first_desc); } /* free the memory of the tree_offsets array */ - if (forest->tree_offsets != NULL) { + if (forest->tree_offsets != nullptr) { t8_shmem_array_destroy (&forest->tree_offsets); } - if (forest->profile != NULL) { + if (forest->profile != nullptr) { T8_FREE (forest->profile); } T8_FREE (forest); - *pforest = NULL; + *pforest = nullptr; } void diff --git a/src/t8_forest/t8_forest_adapt.cxx b/src/t8_forest/t8_forest_adapt.cxx index b6f6486e77..1c8e00d382 100644 --- a/src/t8_forest/t8_forest_adapt.cxx +++ b/src/t8_forest/t8_forest_adapt.cxx @@ -395,7 +395,7 @@ t8_forest_adapt (t8_forest_t forest) t8_locidx_t el_offset; t8_tree_t tree; t8_tree_t tree_from; - sc_list_t *refine_list = NULL; /* This is only needed when we adapt recursively */ + sc_list_t *refine_list = nullptr; /* This is only needed when we adapt recursively */ int num_children; int num_siblings; int curr_size_elements_from; @@ -411,7 +411,7 @@ t8_forest_adapt (t8_forest_t forest) T8_ASSERT (forest->set_adapt_recursive != -1); /* if profiling is enabled, measure runtime */ - if (forest->profile != NULL) { + if (forest->profile != nullptr) { forest->profile->adapt_runtime = -sc_MPI_Wtime (); /* DO NOT DELETE THE FOLLOWING line. * even if you do not want this output. It fixes a bug that occurred on JUQUEEN, where the @@ -431,7 +431,7 @@ t8_forest_adapt (t8_forest_t forest) T8_ASSERT (forest->trees->elem_count == forest_from->trees->elem_count); if (forest->set_adapt_recursive) { - refine_list = sc_list_new (NULL); + refine_list = sc_list_new (nullptr); } forest->local_num_leaf_elements = 0; el_offset = 0; @@ -665,7 +665,8 @@ t8_forest_adapt (t8_forest_t forest) if (!forest_from->incomplete_trees) { T8_ASSERT (element_removed == 1 || element_removed == 0); int incomplete_trees; - int mpiret = sc_MPI_Allreduce (&element_removed, &incomplete_trees, 1, sc_MPI_INT, sc_MPI_MAX, forest->mpicomm); + int const mpiret + = sc_MPI_Allreduce (&element_removed, &incomplete_trees, 1, sc_MPI_INT, sc_MPI_MAX, forest->mpicomm); SC_CHECK_MPI (mpiret); T8_ASSERT (incomplete_trees == 1 || incomplete_trees == 0); forest->incomplete_trees = incomplete_trees; @@ -679,7 +680,7 @@ t8_forest_adapt (t8_forest_t forest) (long long) forest->global_num_leaf_elements); /* if profiling is enabled, measure runtime */ - if (forest->profile != NULL) { + if (forest->profile != nullptr) { forest->profile->adapt_runtime += sc_MPI_Wtime (); /* DO NOT DELETE THE FOLLOWING line. * even if you do not want this output. It fixes a bug that occurred on JUQUEEN, where the diff --git a/src/t8_forest/t8_forest_balance.cxx b/src/t8_forest/t8_forest_balance.cxx index ae67e5dc21..ffa80f002b 100644 --- a/src/t8_forest/t8_forest_balance.cxx +++ b/src/t8_forest/t8_forest_balance.cxx @@ -92,7 +92,7 @@ t8_forest_balance_adapt (t8_forest_t forest, t8_forest_t forest_from, const t8_l scheme->element_new (neigh_class, num_half_neighbors, half_neighbors); /* Compute the half face neighbors of element at this face */ neighbor_tree = t8_forest_element_half_face_neighbors (forest_from, ltree_id, element, half_neighbors, - neigh_class, iface, num_half_neighbors, NULL); + neigh_class, iface, num_half_neighbors, nullptr); if (neighbor_tree >= 0) { /* The face neighbors do exist, check for each one, whether it has * local or ghost leaf descendants in the forest. @@ -166,9 +166,9 @@ t8_forest_balance (t8_forest_t forest, int repartition) t8_log_indent_push (); /* Set default value to prevent compiler warning */ - adap_stats = ghost_stats = partition_stats = NULL; + adap_stats = ghost_stats = partition_stats = nullptr; - if (forest->profile != NULL) { + if (forest->profile != nullptr) { /* Profiling is enable, so we measure the runtime of balance */ forest->profile->balance_runtime = -sc_MPI_Wtime (); /* We store the individual adapt, ghost, and partition runtimes */ @@ -192,7 +192,7 @@ t8_forest_balance (t8_forest_t forest, int repartition) /* This function is reference neutral regarding forest_from */ t8_forest_ref (forest_from); - if (forest->set_from->ghosts == NULL) { + if (forest->set_from->ghosts == nullptr) { forest->set_from->ghost_type = T8_GHOST_FACES; t8_forest_ghost_create_topdown (forest->set_from); } @@ -212,14 +212,14 @@ t8_forest_balance (t8_forest_t forest, int repartition) } forest_temp->t8code_data = &done; /* If profiling is enabled, measure ghost/adapt runtimes */ - if (forest->profile != NULL) { + if (forest->profile != nullptr) { t8_forest_set_profiling (forest_temp, 1); } - t8_global_productionf ("Profiling: %i\n", forest->profile != NULL); + t8_global_productionf ("Profiling: %i\n", forest->profile != nullptr); /* Adapt the forest */ t8_forest_commit (forest_temp); /* Store the runtimes of adapt and ghost */ - if (forest->profile != NULL) { + if (forest->profile != nullptr) { if (count_rounds > num_stats_allocated - 2) { T8_ASSERT (count_adapt_stats <= count_rounds); T8_ASSERT (count_ghost_stats <= count_rounds); @@ -253,13 +253,13 @@ t8_forest_balance (t8_forest_t forest, int repartition) t8_forest_set_partition (forest_partition, forest_temp, 0); t8_forest_set_ghost (forest_partition, 1, T8_GHOST_FACES); /* If profiling is enabled, measure partition runtimes */ - if (forest->profile != NULL) { + if (forest->profile != nullptr) { t8_forest_set_profiling (forest_partition, 1); } t8_forest_commit (forest_partition); /* Store the runtimes of partition */ - if (forest->profile != NULL) { + if (forest->profile != nullptr) { sc_stats_set1 (&partition_stats[count_partition_stats], forest_partition->profile->partition_runtime, "forest balance: Partition time"); count_partition_stats++; @@ -269,7 +269,7 @@ t8_forest_balance (t8_forest_t forest, int repartition) } forest_temp = forest_partition; - forest_partition = NULL; + forest_partition = nullptr; } /* Adapt forest_temp in the next round */ forest_from = forest_temp; @@ -288,7 +288,7 @@ t8_forest_balance (t8_forest_t forest, int repartition) /* clean-up */ t8_forest_unref (&forest_temp); - if (forest->profile != NULL) { + if (forest->profile != nullptr) { /* Profiling is enabled, so we measure the runtime of balance. */ forest->profile->balance_runtime += sc_MPI_Wtime (); forest->profile->balance_rounds = count_rounds; diff --git a/src/t8_forest/t8_forest_ghost.cxx b/src/t8_forest/t8_forest_ghost.cxx index 5e600bf746..878b8384c6 100644 --- a/src/t8_forest/t8_forest_ghost.cxx +++ b/src/t8_forest/t8_forest_ghost.cxx @@ -41,68 +41,68 @@ T8_EXTERN_C_BEGIN (); /** * The information for a remote process, what data we have to send to them. */ -typedef struct +using t8_ghost_mpi_send_info_t = struct { int recv_rank; /**< The rank to which we send. */ size_t num_bytes; /**< The number of bytes that we send. */ sc_MPI_Request *request; /**< Communication request, not owned by this struct. */ char *buffer; /**< The send buffer. */ -} t8_ghost_mpi_send_info_t; +}; /** * The information stored for the ghost trees */ -typedef struct +using t8_ghost_tree_t = struct { t8_gloidx_t global_id; /**< Global id of the tree */ t8_locidx_t element_offset; /**< The count of all ghost elements in all smaller ghost trees */ t8_element_array_t elements; /**< The ghost elements of that tree */ t8_eclass_t eclass; /**< The trees element class */ -} t8_ghost_tree_t; +}; /** * The data structure stored in the global_tree_to_ghost_tree hash table. */ -typedef struct +using t8_ghost_gtree_hash_t = struct { t8_gloidx_t global_id; /**< global tree id */ size_t index; /**< the index of that global tree in the ghost_trees array. */ -} t8_ghost_gtree_hash_t; +}; /** * The data structure stored in the process_offsets array. */ -typedef struct +using t8_ghost_process_hash_t = struct { int mpirank; /**< rank of the process */ t8_locidx_t ghost_offset; /**< The number of ghost elements for all previous ranks */ size_t tree_index; /**< index of first ghost tree of this process in ghost_trees */ size_t first_element; /**< the index of the first element in the elements array of the ghost tree. */ -} t8_ghost_process_hash_t; +}; /** * The information stored for the remote trees. * Each remote process stores an array of these */ -typedef struct +using t8_ghost_remote_tree_t = struct { t8_gloidx_t global_id; /**< global id of the tree */ int mpirank; /**< The mpirank of the remote process */ t8_element_array_t elements; /**< The remote elements of that tree */ sc_array_t element_indices; /**< The (tree) local indices of the ghost elements. */ t8_eclass_t eclass; /**< The trees element class */ -} t8_ghost_remote_tree_t; +}; /** * This struct stores information about the data that the current process needs from a specific remote_process * as ghost data, such as the number of remote elements and the remote trees. */ -typedef struct +using t8_ghost_remote_t = struct { int remote_rank; /**< The rank of the remote process */ t8_locidx_t num_elements; /**< The number of remote elements for this process */ sc_array_t remote_trees; /**< Array of the remote trees of this process */ -} t8_ghost_remote_t; +}; /** * The hash function for the global tree hash. @@ -219,13 +219,13 @@ t8_ghost_remote_equal_function (const void *remote_dataa, const void *remote_dat * Since we use asynchronous communication, we store the * send buffers and mpi requests until we end the communication. */ -typedef struct +using t8_ghost_data_exchange_t = struct { int num_remotes; /**< The number of processes, we send to. */ char **send_buffers; /**< For each remote the send buffer. */ sc_MPI_Request *send_requests; /**< For each process we send to, the MPI request used. */ sc_MPI_Request *recv_requests; /**< For each process we receive from, the MPI request used. */ -} t8_ghost_data_exchange_t; +}; void t8_forest_ghost_init (t8_forest_ghost_t *pghost, t8_ghost_type_t ghost_type) @@ -248,14 +248,15 @@ t8_forest_ghost_init (t8_forest_ghost_t *pghost, t8_ghost_type_t ghost_type) /* initialize the global_tree_to_ghost_tree hash table */ ghost->glo_tree_mempool = sc_mempool_new (sizeof (t8_ghost_gtree_hash_t)); ghost->global_tree_to_ghost_tree - = sc_hash_new (t8_ghost_gtree_hash_function, t8_ghost_gtree_equal_function, NULL, NULL); + = sc_hash_new (t8_ghost_gtree_hash_function, t8_ghost_gtree_equal_function, nullptr, nullptr); /* initialize the process_offset hash table */ ghost->proc_offset_mempool = sc_mempool_new (sizeof (t8_ghost_process_hash_t)); - ghost->process_offsets = sc_hash_new (t8_ghost_process_hash_function, t8_ghost_process_equal_function, NULL, NULL); + ghost->process_offsets + = sc_hash_new (t8_ghost_process_hash_function, t8_ghost_process_equal_function, nullptr, nullptr); /* initialize the remote ghosts hash table */ ghost->remote_ghosts = sc_hash_array_new (sizeof (t8_ghost_remote_t), t8_ghost_remote_hash_function, - t8_ghost_remote_equal_function, NULL); + t8_ghost_remote_equal_function, nullptr); /* initialize the remote processes array */ ghost->remote_processes = sc_array_new (sizeof (int)); } @@ -325,7 +326,7 @@ t8_forest_ghost_get_proc_info (t8_forest_t forest, int remote) t8_locidx_t t8_forest_ghost_num_trees (const t8_forest_t forest) { - if (forest->ghosts == NULL) { + if (forest->ghosts == nullptr) { return 0; } T8_ASSERT (forest->ghosts != NULL); @@ -511,7 +512,7 @@ t8_ghost_add_remote (t8_forest_t forest, t8_forest_ghost_t ghost, int remote_ran remote_entry = (t8_ghost_remote_t *) sc_hash_array_insert_unique (ghost->remote_ghosts, (void *) &remote_entry_lookup, &index); /* clang-format on */ - if (remote_entry != NULL) { + if (remote_entry != nullptr) { /* The remote rank was not in the array and was inserted now */ remote_entry->remote_rank = remote_rank; remote_entry->num_elements = 0; @@ -557,7 +558,7 @@ t8_ghost_add_remote (t8_forest_t forest, t8_forest_ghost_t ghost, int remote_ran } } #endif - elem_copy = NULL; + elem_copy = nullptr; level = scheme->element_get_level (tree_class, elem); element_count = t8_element_array_get_count (&remote_tree->elements); if (element_count > 0) { @@ -567,7 +568,7 @@ t8_ghost_add_remote (t8_forest_t forest, t8_forest_ghost_t ghost, int remote_ran /* Check if the element was not contained in the array. * If so, we add a copy of elem to the array. * Otherwise, we do nothing. */ - if (elem_copy == NULL || level != copy_level + if (elem_copy == nullptr || level != copy_level || scheme->element_get_linear_id (tree_class, elem_copy, copy_level) != scheme->element_get_linear_id (tree_class, elem, level)) { /* Add the element */ @@ -582,7 +583,7 @@ t8_ghost_add_remote (t8_forest_t forest, t8_forest_ghost_t ghost, int remote_ran /** * This struct stores the ghost boundary data of a forest. */ -typedef struct +using t8_forest_ghost_boundary_data_t = struct { sc_array_t bounds_per_level; /**< For each level from the nca to the parent of the current element @@ -603,7 +604,7 @@ typedef struct #if T8_ENABLE_DEBUG t8_locidx_t left_out; /**< Count the elements for which we skip the search */ #endif -} t8_forest_ghost_boundary_data_t; +}; /** * This function is used as callback search function within \ref t8_forest_search to check whether the neighbors of @@ -756,13 +757,13 @@ static void t8_forest_ghost_fill_remote_v3 (t8_forest_t forest) { t8_forest_ghost_boundary_data_t data; - void *store_user_data = NULL; + void *store_user_data = nullptr; /* Start with invalid entries in the user data. * These are set in t8_forest_ghost_search_boundary each time a new tree is entered */ data.eclass = T8_ECLASS_COUNT; data.gtreeid = -1; - data.scheme = NULL; + data.scheme = nullptr; #if T8_ENABLE_DEBUG data.left_out = 0; #endif @@ -775,7 +776,7 @@ t8_forest_ghost_fill_remote_v3 (t8_forest_t forest) /* Set the user data for the search routine */ t8_forest_set_user_data (forest, &data); /* Loop over the trees of the forest */ - t8_forest_search (forest, t8_forest_ghost_search_boundary, NULL, NULL); + t8_forest_search (forest, t8_forest_ghost_search_boundary, nullptr, nullptr); /* Reset the user data from before search */ t8_forest_set_user_data (forest, store_user_data); @@ -804,7 +805,7 @@ t8_forest_ghost_fill_remote_v3 (t8_forest_t forest) static void t8_forest_ghost_fill_remote (t8_forest_t forest, t8_forest_ghost_t ghost, int ghost_method) { - t8_element_t **half_neighbors = NULL; + t8_element_t **half_neighbors = nullptr; t8_locidx_t num_local_trees, num_tree_elems; t8_locidx_t itree, ielem; t8_tree_t tree; @@ -870,7 +871,7 @@ t8_forest_ghost_fill_remote (t8_forest_t forest, t8_forest_ghost_t ghost, int gh if (!is_atom) { /* Construct each half size neighbor */ neighbor_tree = t8_forest_element_half_face_neighbors (forest, itree, elem, half_neighbors, neigh_class, - iface, num_face_children, NULL); + iface, num_face_children, nullptr); } else { int dummy_neigh_face; @@ -914,7 +915,7 @@ t8_forest_ghost_fill_remote (t8_forest_t forest, t8_forest_ghost_t ghost, int gh } /* end element loop */ } /* end tree loop */ - if (forest->profile != NULL) { + if (forest->profile != nullptr) { /* If profiling is enabled, we count the number of remote processes. */ forest->profile->ghosts_remotes = ghost->remote_processes->elem_count; } @@ -946,7 +947,7 @@ t8_forest_ghost_send_start (t8_forest_t forest, t8_forest_ghost_t ghost, sc_MPI_ size_t remote_index; t8_ghost_remote_t *remote_entry; sc_array_t *remote_trees; - t8_ghost_remote_tree_t *remote_tree = NULL; + t8_ghost_remote_tree_t *remote_tree = nullptr; t8_ghost_mpi_send_info_t *send_info, *current_send_info; char *current_buffer; size_t bytes_written, element_bytes, element_count, element_size; @@ -1274,7 +1275,7 @@ t8_forest_ghost_parse_received_message (t8_forest_t forest, t8_forest_ghost_t gh #else (void) #endif - sc_hash_insert_unique (ghost->process_offsets, process_hash, NULL); + sc_hash_insert_unique (ghost->process_offsets, process_hash, nullptr); T8_ASSERT (added_process); } @@ -1283,11 +1284,11 @@ t8_forest_ghost_parse_received_message (t8_forest_t forest, t8_forest_ghost_t gh * of a process in the ghost->remote_processes array, given the rank of a process. * We implement this via a hash table with the following struct as entry. */ -typedef struct t8_recv_list_entry_struct +using t8_recv_list_entry_t = struct t8_recv_list_entry_struct { int rank; /**< The rank of this process */ int pos_in_remote_processes; /**< The position of this process in the remote_processes array */ -} t8_recv_list_entry_t; +}; /** We hash these entries by their rank. */ unsigned @@ -1382,7 +1383,7 @@ t8_forest_ghost_receive (t8_forest_t forest, t8_forest_ghost_t ghost) #ifdef T8_POLLING /* polling */ receivers = sc_list_new (NULL); #else - recv_list_entries_hash = sc_hash_new (t8_recv_list_entry_hash, t8_recv_list_entry_equal, NULL, NULL); + recv_list_entries_hash = sc_hash_new (t8_recv_list_entry_hash, t8_recv_list_entry_equal, nullptr, nullptr); #endif for (proc_pos = 0; proc_pos < num_remotes; proc_pos++) { recv_list_entries[proc_pos].rank = *(int *) sc_array_index_int (ghost->remote_processes, proc_pos); @@ -1393,7 +1394,7 @@ t8_forest_ghost_receive (t8_forest_t forest, t8_forest_ghost_t ghost) #else (void) #endif - sc_hash_insert_unique (recv_list_entries_hash, recv_list_entries + proc_pos, NULL); + sc_hash_insert_unique (recv_list_entries_hash, recv_list_entries + proc_pos, nullptr); T8_ASSERT (ret == 1); #else /* polling */ sc_list_append (receivers, recv_list_entries + proc_pos); @@ -1535,7 +1536,7 @@ t8_forest_ghost_receive (t8_forest_t forest, t8_forest_ghost_t ghost) void t8_forest_ghost_create_ext (t8_forest_t forest, int unbalanced_version) { - t8_forest_ghost_t ghost = NULL; + t8_forest_ghost_t ghost = nullptr; t8_ghost_mpi_send_info_t *send_info; sc_MPI_Request *requests; int create_tree_array = 0, create_gfirst_desc_array = 0; @@ -1553,7 +1554,7 @@ t8_forest_ghost_create_ext (t8_forest_t forest, int unbalanced_version) !forest->incomplete_trees || forest->mpisize == 1, "ERROR: Cannot compute ghost layer for forest with deleted elements (incomplete trees/holes in the mesh).\n"); - if (forest->profile != NULL) { + if (forest->profile != nullptr) { /* If profiling is enabled, we measure the runtime of ghost_create */ forest->profile->ghost_runtime = -sc_MPI_Wtime (); /* DO NOT DELETE THE FOLLOWING line. @@ -1563,17 +1564,17 @@ t8_forest_ghost_create_ext (t8_forest_t forest, int unbalanced_version) t8_global_productionf ("Start ghost at %f %f\n", sc_MPI_Wtime (), forest->profile->ghost_runtime); } - if (forest->element_offsets == NULL) { + if (forest->element_offsets == nullptr) { /* create element offset array if not done already */ create_element_array = 1; t8_forest_partition_create_offsets (forest); } - if (forest->tree_offsets == NULL) { + if (forest->tree_offsets == nullptr) { /* Create tree offset array if not done already */ create_tree_array = 1; t8_forest_partition_create_tree_offsets (forest); } - if (forest->global_first_desc == NULL) { + if (forest->global_first_desc == nullptr) { /* Create global first desc array if not done already */ create_gfirst_desc_array = 1; t8_forest_partition_create_first_desc (forest); @@ -1610,11 +1611,11 @@ t8_forest_ghost_create_ext (t8_forest_t forest, int unbalanced_version) t8_forest_ghost_send_end (forest, ghost, send_info, requests); } - if (forest->profile != NULL) { + if (forest->profile != nullptr) { /* If profiling is enabled, we measure the runtime of ghost_create */ forest->profile->ghost_runtime += sc_MPI_Wtime (); /* We also store the number of ghosts and remotes */ - if (ghost != NULL) { + if (ghost != nullptr) { forest->profile->ghosts_received = ghost->num_ghosts_elements; forest->profile->ghosts_shipped = ghost->num_remote_elements; } @@ -1685,9 +1686,9 @@ int * t8_forest_ghost_get_remotes (t8_forest_t forest, int *num_remotes) { T8_ASSERT (t8_forest_is_committed (forest)); - if (forest->ghosts == NULL) { + if (forest->ghosts == nullptr) { *num_remotes = 0; - return NULL; + return nullptr; } T8_ASSERT (forest->ghosts != NULL); @@ -1943,7 +1944,7 @@ t8_forest_ghost_exchange_data (t8_forest_t forest, sc_array_t *element_data) t8_debugf ("Entering ghost_exchange_data\n"); T8_ASSERT (t8_forest_is_committed (forest)); - if (forest->ghosts == NULL) { + if (forest->ghosts == nullptr) { /* This process has no ghosts */ return; } @@ -1954,12 +1955,12 @@ t8_forest_ghost_exchange_data (t8_forest_t forest, sc_array_t *element_data) == t8_forest_get_local_num_leaf_elements (forest) + t8_forest_get_num_ghosts (forest)); data_exchange = t8_forest_ghost_exchange_begin (forest, element_data); - if (forest->profile != NULL) { + if (forest->profile != nullptr) { /* Measure the time for ghost_exchange_end */ forest->profile->ghost_waittime = -sc_MPI_Wtime (); } t8_forest_ghost_exchange_end (data_exchange); - if (forest->profile != NULL) { + if (forest->profile != nullptr) { /* Measure the time for ghost_exchange_end */ forest->profile->ghost_waittime += sc_MPI_Wtime (); } @@ -1982,7 +1983,7 @@ t8_forest_ghost_print (t8_forest_t forest) char remote_buffer[BUFSIZ] = ""; char buffer[BUFSIZ] = ""; - if (forest->ghosts == NULL) { + if (forest->ghosts == nullptr) { return; } T8_ASSERT (forest->ghosts != NULL); @@ -2075,7 +2076,7 @@ t8_forest_ghost_reset (t8_forest_ghost_t *pghost) /* Free the ghost */ T8_FREE (ghost); - pghost = NULL; + pghost = nullptr; } void diff --git a/src/t8_forest/t8_forest_iterate.cxx b/src/t8_forest/t8_forest_iterate.cxx index bf90cc9fbf..e11500680b 100644 --- a/src/t8_forest/t8_forest_iterate.cxx +++ b/src/t8_forest/t8_forest_iterate.cxx @@ -35,13 +35,13 @@ T8_EXTERN_C_BEGIN (); /** * This struct stores query data about the elements within the forest. */ -typedef struct +using t8_forest_child_type_query_t = struct { const t8_scheme *scheme; /**< The scheme. */ t8_eclass_t tree_class; /**< The tree class. */ int level; /**< The refinement level. */ int num_children; /**< The number of children. */ -} t8_forest_child_type_query_t; +}; /** * This is the function that we call in sc_split_array to determine for an @@ -219,8 +219,8 @@ t8_forest_search_recursion (t8_forest_t forest, const t8_locidx_t ltreeid, t8_el /* There are no leaves left, so we have nothing to do */ return; } - const size_t num_active = queries == NULL ? 0 : active_queries->elem_count; - if (queries != NULL && num_active == 0) { + const size_t num_active = queries == nullptr ? 0 : active_queries->elem_count; + if (queries != nullptr && num_active == 0) { /* There are no queries left. We stop the recursion */ return; } @@ -250,7 +250,7 @@ t8_forest_search_recursion (t8_forest_t forest, const t8_locidx_t ltreeid, t8_el /* Check the queries. * If the current element is not a leaf, we store the queries that * return true in order to pass them on to the children of the element. */ - sc_array_t *new_active_queries = NULL; + sc_array_t *new_active_queries = nullptr; if (num_active > 0) { if (!is_leaf) { /* Initialize the new active query array */ @@ -263,7 +263,7 @@ t8_forest_search_recursion (t8_forest_t forest, const t8_locidx_t ltreeid, t8_el for (size_t iactive = 0; iactive < num_active; iactive++) { if (!is_leaf && active_queries_matches[iactive]) { - size_t query_index = *(size_t *) sc_array_index (active_queries, iactive); + size_t const query_index = *(size_t *) sc_array_index (active_queries, iactive); *(size_t *) sc_array_push (new_active_queries) = query_index; } } @@ -357,8 +357,8 @@ t8_forest_search (t8_forest_t forest, t8_forest_search_fn search_fn, t8_forest_q { /* If we have queries build a list of all active queries, * thus all queries in the array */ - sc_array_t *active_queries = NULL; - if (queries != NULL) { + sc_array_t *active_queries = nullptr; + if (queries != nullptr) { const size_t num_queries = queries->elem_count; /* build an array and write 0, 1, 2, 3,... into it */ active_queries = sc_array_new_count (sizeof (size_t), num_queries); @@ -372,7 +372,7 @@ t8_forest_search (t8_forest_t forest, t8_forest_search_fn search_fn, t8_forest_q t8_forest_search_tree (forest, itree, search_fn, query_fn, queries, active_queries); } - if (active_queries != NULL) { + if (active_queries != nullptr) { sc_array_destroy (active_queries); } } @@ -396,7 +396,7 @@ t8_forest_iterate_replace (t8_forest_t forest_new, t8_forest_t forest_old, t8_fo const t8_locidx_t elems_per_tree_new = t8_forest_get_tree_num_leaf_elements (forest_new, itree); const t8_locidx_t elems_per_tree_old = t8_forest_get_tree_num_leaf_elements (forest_old, itree); /* Get the eclass of the tree */ - t8_eclass_t tree_class = t8_forest_get_tree_class (forest_new, itree); + t8_eclass_t const tree_class = t8_forest_get_tree_class (forest_new, itree); T8_ASSERT (tree_class == t8_forest_get_tree_class (forest_old, itree)); t8_locidx_t ielem_new = 0; t8_locidx_t ielem_old = 0; diff --git a/src/t8_forest/t8_forest_partition.cxx b/src/t8_forest/t8_forest_partition.cxx index 06ee9aa8ef..9a93bb0ccb 100644 --- a/src/t8_forest/t8_forest_partition.cxx +++ b/src/t8_forest/t8_forest_partition.cxx @@ -39,12 +39,12 @@ T8_EXTERN_C_BEGIN (); * For each tree that we send elements from to other processes, * we send the information stored in this struct to the other process */ -typedef struct +using t8_forest_partition_tree_info_t = struct { t8_gloidx_t gtree_id; /**< The global id of that tree. TODO: we could optimize this out */ t8_eclass_t eclass; /**< The element class of that tree. */ t8_locidx_t num_elements; /**< The number of elements from this tree that were sent. */ -} t8_forest_partition_tree_info_t; +}; /* Given the element offset array and a rank, return the first local element id of this rank */ static t8_gloidx_t @@ -132,7 +132,7 @@ t8_forest_set_partition_offset (t8_forest_t forest, const t8_gloidx_t first_glob void t8_forest_partition_create_offsets (t8_forest_t forest) { - if (forest->profile != NULL) { + if (forest->profile != nullptr) { /* If profiling is enabled, we measure the runtime of partition */ forest->profile->forest_offsets_runtime = -sc_MPI_Wtime (); } @@ -160,7 +160,7 @@ t8_forest_partition_create_offsets (t8_forest_t forest) t8_shmem_array_set_gloidx (forest->element_offsets, forest->mpisize, forest->global_num_leaf_elements); } t8_shmem_array_end_writing (forest->element_offsets); - if (forest->profile != NULL) { + if (forest->profile != nullptr) { /* If profiling is enabled, we measure the runtime of partition */ forest->profile->forest_offsets_runtime += sc_MPI_Wtime (); } @@ -306,13 +306,13 @@ t8_forest_partition_test_boundary_element ([[maybe_unused]] const t8_forest_t fo void t8_forest_partition_create_first_desc (t8_forest_t forest) { - if (forest->profile != NULL) { + if (forest->profile != nullptr) { /* If profiling is enabled, we measure the runtime of partition */ forest->profile->first_descendant_runtime = -sc_MPI_Wtime (); } sc_MPI_Comm comm; t8_linearidx_t local_first_desc; - t8_element_t *first_desc = NULL; + t8_element_t *first_desc = nullptr; T8_ASSERT (t8_forest_is_committed (forest)); @@ -320,7 +320,7 @@ t8_forest_partition_create_first_desc (t8_forest_t forest) t8_debugf ("Building global first descendants for forest %p\n", (void *) forest); comm = forest->mpicomm; - if (forest->global_first_desc == NULL) { + if (forest->global_first_desc == nullptr) { /* Set the shmem array type of comm */ t8_shmem_init (comm); t8_shmem_set_type (comm, T8_SHMEM_BEST_TYPE); @@ -337,7 +337,7 @@ t8_forest_partition_create_first_desc (t8_forest_t forest) local_first_desc = 0; } else { - const t8_element_t *first_element = NULL; + const t8_element_t *first_element = nullptr; /* Get a pointer to the first local element. */ if (forest->incomplete_trees) { for (t8_locidx_t itree = 0; itree < t8_forest_get_num_local_trees (forest); itree++) { @@ -351,7 +351,7 @@ t8_forest_partition_create_first_desc (t8_forest_t forest) first_element = t8_forest_get_leaf_element_in_tree (forest, 0, 0); } /* This process is not empty, the element was found, so we compute its first descendant. */ - if (first_element != NULL) { + if (first_element != nullptr) { /* Get the eclass_scheme of the element. */ const t8_scheme *scheme = t8_forest_get_scheme (forest); const t8_eclass_t tree_class = t8_forest_get_tree_class (forest, 0); @@ -388,7 +388,7 @@ t8_forest_partition_create_first_desc (t8_forest_t forest) } t8_forest_partition_test_desc (forest); #endif - if (forest->profile != NULL) { + if (forest->profile != nullptr) { /* If profiling is enabled, we measure the runtime of partition */ forest->profile->first_descendant_runtime += sc_MPI_Wtime (); } @@ -398,7 +398,7 @@ void t8_forest_partition_create_tree_offsets (t8_forest_t forest) { - if (forest->profile != NULL) { + if (forest->profile != nullptr) { /* If profiling is enabled, we measure the runtime of partition */ forest->profile->cmesh_offsets_runtime = -sc_MPI_Wtime (); } @@ -423,7 +423,7 @@ t8_forest_partition_create_tree_offsets (t8_forest_t forest) is_empty = 0; } - if (forest->tree_offsets == NULL) { + if (forest->tree_offsets == nullptr) { /* Set the shmem array type of comm */ t8_shmem_init (comm); t8_shmem_set_type (comm, T8_SHMEM_BEST_TYPE); @@ -466,7 +466,7 @@ t8_forest_partition_create_tree_offsets (t8_forest_t forest) /* Communicate the new tree offsets */ t8_shmem_array_allgather (&tree_offset, 1, T8_MPI_GLOIDX, forest->tree_offsets, 1, T8_MPI_GLOIDX); } - if (forest->profile != NULL) { + if (forest->profile != nullptr) { /* If profiling is enabled, we measure the runtime of partition */ forest->profile->cmesh_offsets_runtime += sc_MPI_Wtime (); } @@ -907,7 +907,7 @@ t8_forest_partition_sendloop (t8_forest_t forest, const int send_first, const in *byte_to_self = buffer_alloc; *(*requests + iproc - send_first) = sc_MPI_REQUEST_NULL; } - if (!send_data && forest->profile != NULL) { + if (!send_data && forest->profile != nullptr) { if (iproc != forest->mpirank) { /* If profiling is enabled we count the number of elements sent to other processes */ forest->profile->partition_elements_shipped += num_elements_send; @@ -1130,7 +1130,7 @@ t8_forest_partition_recv_message (t8_forest_t forest, sc_MPI_Comm comm, int proc if (proc != forest->mpirank) { T8_FREE (recv_buffer); } - if (forest->profile != NULL) { + if (forest->profile != nullptr) { if (proc != forest->mpirank) { /* If profiling is enabled we count the number of elements received from other processes */ forest->profile->partition_elements_recv += num_elements_recv; @@ -1202,7 +1202,7 @@ static void t8_forest_partition_given (t8_forest_t forest, const int send_data, const sc_array_t *data_in, sc_array_t *data_out) { int send_first, send_last, recv_first, recv_last; - sc_MPI_Request *requests = NULL; + sc_MPI_Request *requests = nullptr; int num_request_alloc; /* The count of elements in the request array */ char **send_buffer, *sent_to_self; int mpiret, i, to_self; @@ -1227,7 +1227,7 @@ t8_forest_partition_given (t8_forest_t forest, const int send_data, const sc_arr sent_to_self = *(send_buffer + forest->mpirank - send_first); } else { - sent_to_self = NULL; + sent_to_self = nullptr; } /* Compute the number of new elements on this forest */ @@ -1280,7 +1280,7 @@ t8_forest_partition (t8_forest_t forest) forest_from = forest->set_from; T8_ASSERT (t8_forest_is_committed (forest_from)); - if (forest->profile != NULL) { + if (forest->profile != nullptr) { /* If profiling is enabled, we measure the runtime of partition */ forest->profile->partition_runtime = sc_MPI_Wtime (); @@ -1291,7 +1291,7 @@ t8_forest_partition (t8_forest_t forest) t8_global_productionf ("Start partition %f %f\n", sc_MPI_Wtime (), forest->profile->partition_runtime); } - if (forest_from->element_offsets == NULL) { + if (forest_from->element_offsets == nullptr) { /* We create the partition table of forest_from */ create_offset_from = 1; t8_forest_partition_create_offsets (forest_from); @@ -1300,7 +1300,7 @@ t8_forest_partition (t8_forest_t forest) /* We now calculate the new element offsets */ t8_forest_partition_compute_new_offset (forest); - t8_forest_partition_given (forest, 0, NULL, NULL); + t8_forest_partition_given (forest, 0, nullptr, nullptr); T8_ASSERT ((size_t) t8_forest_get_num_local_trees (forest_from) == forest_from->trees->elem_count); T8_ASSERT ((size_t) t8_forest_get_num_local_trees (forest) == forest->trees->elem_count); @@ -1310,7 +1310,7 @@ t8_forest_partition (t8_forest_t forest) t8_shmem_array_destroy (&forest_from->element_offsets); } - if (forest->profile != NULL) { + if (forest->profile != nullptr) { /* If profiling is enabled, we measure the runtime of partition */ forest->profile->partition_runtime = sc_MPI_Wtime () - forest->profile->partition_runtime; @@ -1346,12 +1346,12 @@ t8_forest_partition_data (t8_forest_t forest_from, t8_forest_t forest_to, const T8_ASSERT (data_out->elem_count == (size_t) forest_to->local_num_leaf_elements); /* Create partition tables if not existent yet */ - if (forest_from->element_offsets == NULL) { + if (forest_from->element_offsets == nullptr) { /* We create the partition table of forest_from */ t8_forest_partition_create_offsets (forest_from); } - if (forest_to->element_offsets == NULL) { + if (forest_to->element_offsets == nullptr) { /* We create the partition table of forest_to */ t8_forest_partition_create_offsets (forest_to); } diff --git a/src/t8_forest/t8_forest_search/t8_forest_search.cxx b/src/t8_forest/t8_forest_search/t8_forest_search.cxx index 63d5b85b03..2a10108cba 100644 --- a/src/t8_forest/t8_forest_search/t8_forest_search.cxx +++ b/src/t8_forest/t8_forest_search/t8_forest_search.cxx @@ -196,7 +196,7 @@ t8_forest_search_destroy (t8_forest_search_c_wrapper search) { T8_ASSERT (search != NULL); delete search->cpp_search; - search->cpp_search = NULL; + search->cpp_search = nullptr; } /** @@ -267,7 +267,7 @@ t8_forest_search_with_queries_destroy (t8_forest_search_with_queries_c_wrapper s { T8_ASSERT (search != NULL); delete search->cpp_search; - search->cpp_search = NULL; + search->cpp_search = nullptr; } /** @@ -296,7 +296,7 @@ struct t8_forest_search_with_batched_queries const bool is_leaf, const t8_element_array_t *leaf_elements, const t8_locidx_t tree_leaf_index, const std::vector &queries, const std::vector &active_query_indices, std::vector &query_matches, - void *user_data) + void *user_data) const { std::vector query_matches_int (query_matches.size ()); queries_callback (forest, ltreeid, element, is_leaf, leaf_elements, tree_leaf_index, queries.data (), @@ -367,7 +367,7 @@ t8_forest_search_with_batched_queries_destroy (t8_forest_search_with_batched_que { T8_ASSERT (search != NULL); delete search->cpp_search; - search->cpp_search = NULL; + search->cpp_search = nullptr; } void diff --git a/src/t8_geometry/t8_geometry.cxx b/src/t8_geometry/t8_geometry.cxx index 595755260b..b2a3109c3c 100644 --- a/src/t8_geometry/t8_geometry.cxx +++ b/src/t8_geometry/t8_geometry.cxx @@ -32,20 +32,20 @@ t8_geometry_evaluate (t8_cmesh_t cmesh, t8_gloidx_t gtreeid, const double *ref_c /* The geometries do not expect the in- and output vector to be the same */ T8_ASSERT (ref_coords != out_coords); - if (cmesh->profile != NULL) { + if (cmesh->profile != nullptr) { /* Measure the runtime of geometry evaluation. * We accumulate the runtime over all calls. */ start_wtime = sc_MPI_Wtime (); } - if (cmesh->geometry_handler == NULL) { + if (cmesh->geometry_handler == nullptr) { SC_ABORT ("Error: Trying to evaluate non-existing geometry.\n"); } /* Evaluate the geometry. */ cmesh->geometry_handler->evaluate_tree_geometry (cmesh, gtreeid, ref_coords, num_coords, out_coords); - if (cmesh->profile != NULL) { + if (cmesh->profile != nullptr) { /* If profiling is enabled, add the runtime to the profiling * variable. */ cmesh->profile->geometry_evaluate_runtime += sc_MPI_Wtime () - start_wtime; diff --git a/src/t8_geometry/t8_geometry_implementations/t8_geometry_analytic.cxx b/src/t8_geometry/t8_geometry_implementations/t8_geometry_analytic.cxx index eca52eb353..cced315979 100644 --- a/src/t8_geometry/t8_geometry_implementations/t8_geometry_analytic.cxx +++ b/src/t8_geometry/t8_geometry_implementations/t8_geometry_analytic.cxx @@ -21,13 +21,14 @@ */ #include +#include t8_geometry_analytic::t8_geometry_analytic (std::string name, t8_geom_analytic_fn analytical, t8_geom_analytic_jacobian_fn jacobian_in, t8_geom_load_tree_data_fn load_tree_data_in, t8_geom_tree_negative_volume_fn tree_negative_volume_in, t8_geom_tree_compatible_fn tree_compatible_in, const void *user_data_in) - : t8_geometry (name) + : t8_geometry (std::move (name)) { analytical_function = analytical; jacobian = jacobian_in; @@ -37,14 +38,14 @@ t8_geometry_analytic::t8_geometry_analytic (std::string name, t8_geom_analytic_f user_data = user_data_in; } -t8_geometry_analytic::t8_geometry_analytic (std::string name): t8_geometry (name) +t8_geometry_analytic::t8_geometry_analytic (std::string name): t8_geometry (std::move (name)) { - analytical_function = NULL; - jacobian = NULL; - load_tree_data = NULL; - tree_negative_volume = NULL; - tree_compatible = NULL; - user_data = NULL; + analytical_function = nullptr; + jacobian = nullptr; + load_tree_data = nullptr; + tree_negative_volume = nullptr; + tree_compatible = nullptr; + user_data = nullptr; } void @@ -66,20 +67,20 @@ t8_geometry_analytic::t8_geom_evaluate_jacobian (t8_cmesh_t cmesh, t8_gloidx_t g void t8_geometry_analytic::t8_geom_load_tree_data (t8_cmesh_t cmesh, t8_gloidx_t gtreeid) { - if (load_tree_data != NULL) { + if (load_tree_data != nullptr) { /* Load tree data if a loading function was provided. */ load_tree_data (cmesh, gtreeid, &tree_data); } else { /* Otherwise it is NULL. */ - tree_data = NULL; + tree_data = nullptr; } } bool t8_geometry_analytic::t8_geom_tree_negative_volume () const { - if (tree_negative_volume != NULL) { + if (tree_negative_volume != nullptr) { /* Tree negative volume if a loading function was provided. */ return tree_negative_volume (); } @@ -91,7 +92,7 @@ t8_geometry_analytic::t8_geom_tree_negative_volume () const bool t8_geometry_analytic::t8_geom_check_tree_compatibility () const { - if (tree_compatible != NULL) { + if (tree_compatible != nullptr) { /* tree_compatible if a loading function was provided. */ return tree_compatible (); } @@ -108,7 +109,7 @@ t8_geometry_analytic_destroy (t8_geometry_c **geom) T8_ASSERT (geom != NULL); delete *geom; - *geom = NULL; + *geom = nullptr; } t8_geometry_c * @@ -126,7 +127,7 @@ void t8_geom_load_tree_data_vertices (t8_cmesh_t cmesh, t8_gloidx_t gtreeid, const void **user_data) { T8_ASSERT (t8_cmesh_is_committed (cmesh)); - t8_locidx_t ltreeid = t8_cmesh_get_local_id (cmesh, gtreeid); + t8_locidx_t const ltreeid = t8_cmesh_get_local_id (cmesh, gtreeid); *user_data = t8_cmesh_get_tree_vertices (cmesh, ltreeid); } diff --git a/src/t8_geometry/t8_geometry_implementations/t8_geometry_examples.cxx b/src/t8_geometry/t8_geometry_implementations/t8_geometry_examples.cxx index cde983544f..b1a72edbf6 100644 --- a/src/t8_geometry/t8_geometry_implementations/t8_geometry_examples.cxx +++ b/src/t8_geometry/t8_geometry_implementations/t8_geometry_examples.cxx @@ -348,7 +348,7 @@ t8_geometry_destroy (t8_geometry_c **geom) T8_ASSERT (geom != NULL); delete *geom; - *geom = NULL; + *geom = nullptr; } /* Satisfy the C interface from t8_geometry_linear.h. */ diff --git a/src/t8_geometry/t8_geometry_implementations/t8_geometry_lagrange.cxx b/src/t8_geometry/t8_geometry_implementations/t8_geometry_lagrange.cxx index d0a73b547e..40a304c4ae 100644 --- a/src/t8_geometry/t8_geometry_implementations/t8_geometry_lagrange.cxx +++ b/src/t8_geometry/t8_geometry_implementations/t8_geometry_lagrange.cxx @@ -21,7 +21,7 @@ */ /** \file t8_geometry_lagrange.cxx - * Implements functions declared in \ref t8_geometry_lagrange.hxx + * Implements functions declared in \ref t8_geometry_lagrange.hxx * or the C interface \ref t8_geometry_lagrange.h. */ @@ -323,8 +323,6 @@ t8_lagrange_element::t8_lagrange_element (t8_eclass_t eclass, uint32_t degree, s t8_cmesh_commit (cmesh, sc_MPI_COMM_WORLD); } -const uint32_t t8_lagrange_element::lagrange_nodes[T8_ECLASS_COUNT][2]; - t8_eclass_t t8_lagrange_element::get_type () const { @@ -424,10 +422,10 @@ std::vector> t8_lagrange_element::get_node_coords (std::vector &nodes) const { const double *v = t8_cmesh_get_tree_vertices (cmesh, 0); - size_t n_node = nodes.size (); + size_t const n_node = nodes.size (); std::vector> node_coords (n_node); for (size_t i = 0; i < n_node; ++i) { - uint32_t i_node = nodes[i]; + uint32_t const i_node = nodes[i]; node_coords[i] = std::vector (v + 3 * i_node, v + 3 * i_node + 3); } return node_coords; @@ -479,8 +477,8 @@ t8_lagrange_element::map_on_face (t8_eclass map_onto, const int face_id, /* Actual mapping, case by case */ std::array mapped_coord; - double xi = coord[0]; - double eta = coord[1]; + double const xi = coord[0]; + double const eta = coord[1]; switch (eclass) { case T8_ECLASS_LINE: if (map_onto == T8_ECLASS_TRIANGLE) { @@ -560,7 +558,7 @@ t8_geometry_lagrange_destroy (t8_geometry_c **geom) T8_ASSERT ((*geom)->t8_geom_get_type () == T8_GEOMETRY_TYPE_LAGRANGE); delete *geom; - *geom = NULL; + *geom = nullptr; } T8_EXTERN_C_END (); diff --git a/src/t8_geometry/t8_geometry_implementations/t8_geometry_linear.cxx b/src/t8_geometry/t8_geometry_implementations/t8_geometry_linear.cxx index 4b2f2dd161..dcdc83f2cd 100644 --- a/src/t8_geometry/t8_geometry_implementations/t8_geometry_linear.cxx +++ b/src/t8_geometry/t8_geometry_implementations/t8_geometry_linear.cxx @@ -292,7 +292,7 @@ t8_geometry_linear_destroy (t8_geometry_c **geom) T8_ASSERT ((*geom)->t8_geom_get_type () == T8_GEOMETRY_TYPE_LINEAR); delete *geom; - *geom = NULL; + *geom = nullptr; } T8_EXTERN_C_END (); diff --git a/src/t8_geometry/t8_geometry_implementations/t8_geometry_linear_axis_aligned.cxx b/src/t8_geometry/t8_geometry_implementations/t8_geometry_linear_axis_aligned.cxx index 58445afc1b..758c9ef6dd 100644 --- a/src/t8_geometry/t8_geometry_implementations/t8_geometry_linear_axis_aligned.cxx +++ b/src/t8_geometry/t8_geometry_implementations/t8_geometry_linear_axis_aligned.cxx @@ -21,7 +21,7 @@ */ /** \file t8_geometry_linear_axis_aligned.cxx - * Implements functions declared in \ref t8_geometry_linear_axis_aligned.hxx + * Implements functions declared in \ref t8_geometry_linear_axis_aligned.hxx * or the C interface \ref t8_geometry_linear_axis_aligned.h. */ @@ -33,7 +33,7 @@ /** * Check that the two points of the geometry are ordered correctly, that is * p1_x <= p2_x, p1_y <= p2_y and p1_z <= p2_z - * + * * \param[in] tree_vertices The vertices of a tree * \return true if the points are ordered correctly * \return false ow @@ -108,7 +108,6 @@ t8_geometry_linear_axis_aligned::t8_geom_point_batch_inside_element (t8_forest_t && v_min[1] - tolerance <= points[ipoint * 3 + 1] && points[ipoint * 3 + 1] <= v_max[1] + tolerance && v_min[2] - tolerance <= points[ipoint * 3 + 2] && points[ipoint * 3 + 2] <= v_max[2] + tolerance; } - return; } bool @@ -136,7 +135,7 @@ t8_geometry_linear_axis_aligned_destroy (t8_geometry_c **geom) T8_ASSERT ((*geom)->t8_geom_get_type () == T8_GEOMETRY_TYPE_LINEAR_AXIS_ALIGNED); delete *geom; - *geom = NULL; + *geom = nullptr; } T8_EXTERN_C_END (); diff --git a/src/t8_geometry/t8_geometry_implementations/t8_geometry_zero.cxx b/src/t8_geometry/t8_geometry_implementations/t8_geometry_zero.cxx index fd4937bcd1..0c40d274d3 100644 --- a/src/t8_geometry/t8_geometry_implementations/t8_geometry_zero.cxx +++ b/src/t8_geometry/t8_geometry_implementations/t8_geometry_zero.cxx @@ -81,7 +81,7 @@ t8_geometry_zero_destroy (t8_geometry_c **geom) T8_ASSERT ((*geom)->t8_geom_get_type () == T8_GEOMETRY_TYPE_ZERO); delete *geom; - *geom = NULL; + *geom = nullptr; } T8_EXTERN_C_END (); diff --git a/src/t8_geometry/t8_geometry_with_vertices.cxx b/src/t8_geometry/t8_geometry_with_vertices.cxx index 894fae0c0c..3d7b953370 100644 --- a/src/t8_geometry/t8_geometry_with_vertices.cxx +++ b/src/t8_geometry/t8_geometry_with_vertices.cxx @@ -92,7 +92,7 @@ t8_geometry_with_vertices::t8_geom_tree_negative_volume () const /* compute cross = v_1 x v_2 */ t8_cross_3D (v_1, v_2, cross); /* Compute sc_prod = */ - double sc_prod = t8_dot (v_j, cross); + double const sc_prod = t8_dot (v_j, cross); T8_ASSERT (sc_prod != 0); return active_tree_class == T8_ECLASS_TET ? sc_prod > 0 : sc_prod < 0; diff --git a/src/t8_schemes/t8_default/t8_default_hex/t8_default_hex.cxx b/src/t8_schemes/t8_default/t8_default_hex/t8_default_hex.cxx index 8f2af4711b..7c3c6fff8a 100644 --- a/src/t8_schemes/t8_default/t8_default_hex/t8_default_hex.cxx +++ b/src/t8_schemes/t8_default/t8_default_hex/t8_default_hex.cxx @@ -243,7 +243,7 @@ t8_default_scheme_hex::element_get_children_at_face (const t8_element_t *elem, c T8_ASSERT (0 <= face && face < P8EST_FACES); T8_ASSERT (num_children == element_get_num_face_children (elem, face)); - if (child_indices != NULL) { + if (child_indices != nullptr) { child_ids = child_indices; } else { diff --git a/src/t8_schemes/t8_default/t8_default_line/t8_default_line.cxx b/src/t8_schemes/t8_default/t8_default_line/t8_default_line.cxx index 1dff80d5e4..39a9121d41 100644 --- a/src/t8_schemes/t8_default/t8_default_line/t8_default_line.cxx +++ b/src/t8_schemes/t8_default/t8_default_line/t8_default_line.cxx @@ -26,7 +26,7 @@ #include #include -typedef t8_dline_t t8_default_line_t; +using t8_default_line_t = t8_dline_t; T8_EXTERN_C_BEGIN (); @@ -121,7 +121,7 @@ t8_default_scheme_line::element_get_children_at_face (const t8_element_t *elem, /* We have exactly one child at a face and this is child 0 if face = 0 * and child 1 if face = 1 */ - if (child_indices != NULL) { + if (child_indices != nullptr) { *child_indices = face; } t8_dline_child ((const t8_dline_t *) elem, face, (t8_dline_t *) children[0]); diff --git a/src/t8_schemes/t8_default/t8_default_prism/t8_default_prism.cxx b/src/t8_schemes/t8_default/t8_default_prism/t8_default_prism.cxx index ee9c1c6451..a8ff759cfe 100644 --- a/src/t8_schemes/t8_default/t8_default_prism/t8_default_prism.cxx +++ b/src/t8_schemes/t8_default/t8_default_prism/t8_default_prism.cxx @@ -26,7 +26,7 @@ #include #include -typedef t8_dprism_t t8_default_prism_t; +using t8_default_prism_t = t8_dprism_t; T8_EXTERN_C_BEGIN (); diff --git a/src/t8_schemes/t8_default/t8_default_pyramid/t8_default_pyramid.cxx b/src/t8_schemes/t8_default/t8_default_pyramid/t8_default_pyramid.cxx index 5d0d5bf89d..323090b303 100644 --- a/src/t8_schemes/t8_default/t8_default_pyramid/t8_default_pyramid.cxx +++ b/src/t8_schemes/t8_default/t8_default_pyramid/t8_default_pyramid.cxx @@ -28,7 +28,7 @@ #include #include -typedef t8_dpyramid_t t8_default_pyramid_t; +using t8_default_pyramid_t = t8_dpyramid_t; T8_EXTERN_C_BEGIN (); diff --git a/src/t8_schemes/t8_default/t8_default_quad/t8_default_quad.cxx b/src/t8_schemes/t8_default/t8_default_quad/t8_default_quad.cxx index 816ea20614..071b6acdd0 100644 --- a/src/t8_schemes/t8_default/t8_default_quad/t8_default_quad.cxx +++ b/src/t8_schemes/t8_default/t8_default_quad/t8_default_quad.cxx @@ -377,7 +377,7 @@ t8_default_scheme_quad::element_get_children_at_face (const t8_element_t *elem, */ this->element_get_child (elem, second_child, children[1]); this->element_get_child (elem, first_child, children[0]); - if (child_indices != NULL) { + if (child_indices != nullptr) { child_indices[0] = first_child; child_indices[1] = second_child; } @@ -417,7 +417,7 @@ t8_default_scheme_quad::element_transform_face (const t8_element_t *elem1, t8_el const p4est_quadrant_t *qin = (const p4est_quadrant_t *) elem1; const p4est_quadrant_t *q; p4est_quadrant_t *p = (p4est_quadrant_t *) elem2; - p4est_qcoord_t h = P4EST_QUADRANT_LEN (qin->level); + p4est_qcoord_t const h = P4EST_QUADRANT_LEN (qin->level); p4est_qcoord_t x = qin->x; /* temp storage for x coordinate in case elem1 = elem 2 */ T8_ASSERT (element_is_valid (elem1)); diff --git a/src/t8_schemes/t8_default/t8_default_tet/t8_default_tet.cxx b/src/t8_schemes/t8_default/t8_default_tet/t8_default_tet.cxx index 977c7a4fce..0a239e09ec 100644 --- a/src/t8_schemes/t8_default/t8_default_tet/t8_default_tet.cxx +++ b/src/t8_schemes/t8_default/t8_default_tet/t8_default_tet.cxx @@ -30,7 +30,7 @@ /* We want to export the whole implementation to be callable from "C" */ T8_EXTERN_C_BEGIN (); -typedef t8_dtet_t t8_default_tet_t; +using t8_default_tet_t = t8_dtet_t; size_t t8_default_scheme_tet::get_element_size (void) const diff --git a/src/t8_schemes/t8_scheme.cxx b/src/t8_schemes/t8_scheme.cxx index 6f909ff635..c6d897e701 100644 --- a/src/t8_schemes/t8_scheme.cxx +++ b/src/t8_schemes/t8_scheme.cxx @@ -43,7 +43,7 @@ t8_scheme_unref (t8_scheme_c **pscheme) T8_ASSERT (pscheme != NULL); if ((*pscheme)->unref () < 1) { - *pscheme = NULL; + *pscheme = nullptr; } } diff --git a/src/t8_vtk/t8_vtk_write_ASCII.cxx b/src/t8_vtk/t8_vtk_write_ASCII.cxx index 484a5bac9d..2dc17240ca 100644 --- a/src/t8_vtk/t8_vtk_write_ASCII.cxx +++ b/src/t8_vtk/t8_vtk_write_ASCII.cxx @@ -46,7 +46,7 @@ */ /* TODO: As soon as we have element iterators we should restructure this concept * appropriately. */ -typedef enum { T8_VTK_KERNEL_INIT, T8_VTK_KERNEL_EXECUTE, T8_VTK_KERNEL_CLEANUP } T8_VTK_KERNEL_MODUS; +using T8_VTK_KERNEL_MODUS = enum { T8_VTK_KERNEL_INIT, T8_VTK_KERNEL_EXECUTE, T8_VTK_KERNEL_CLEANUP }; /** Callback function prototype for writing cell data. * The function is executed for each element. @@ -74,10 +74,9 @@ typedef enum { T8_VTK_KERNEL_INIT, T8_VTK_KERNEL_EXECUTE, T8_VTK_KERNEL_CLEANUP * \param [in] modus The modus in which the callback is called. See above. * \return True if successful, false if not (i.e. file i/o error). */ -typedef int (*t8_forest_vtk_cell_data_kernel) (t8_forest_t forest, const t8_locidx_t ltree_id, const t8_tree_t tree, - const t8_locidx_t element_index, const t8_element_t *element, - const t8_eclass_t tree_class, const int is_ghost, FILE *vtufile, - int *columns, void **data, T8_VTK_KERNEL_MODUS modus); +using t8_forest_vtk_cell_data_kernel + = int (*) (t8_forest_t, const t8_locidx_t, const t8_tree_t, const t8_locidx_t, const t8_element_t *, + const t8_eclass_t, const int, FILE *, int *, void **, T8_VTK_KERNEL_MODUS); static t8_locidx_t t8_forest_num_points (t8_forest_t forest, const int count_ghosts) @@ -460,7 +459,7 @@ t8_forest_vtk_write_cell_data (t8_forest_t forest, FILE *vtufile, const char *da t8_locidx_t element_index, elems_in_tree; t8_locidx_t num_local_trees, num_ghost_trees; t8_element_t *element; - void *data = NULL; + void *data = nullptr; /* Write the connectivity information. * Thus for each tree we write the indices of its corner vertices. */ @@ -474,13 +473,13 @@ t8_forest_vtk_write_cell_data (t8_forest_t forest, FILE *vtufile, const char *da /* if udata != NULL, use it as the data pointer, in this case, the kernel * should not modify it */ - if (udata != NULL) { + if (udata != nullptr) { data = udata; } /* Call the kernel in initialization modus to possibly initialize the * data pointer */ - kernel (NULL, 0, NULL, 0, NULL, T8_ECLASS_COUNT, 0, NULL, NULL, &data, T8_VTK_KERNEL_INIT); + kernel (nullptr, 0, nullptr, 0, nullptr, T8_ECLASS_COUNT, 0, nullptr, nullptr, &data, T8_VTK_KERNEL_INIT); /* We iterate over the trees and count each trees vertices, * we add this to the already counted vertices and write it to the file */ /* TODO: replace with an element iterator */ @@ -493,13 +492,13 @@ t8_forest_vtk_write_cell_data (t8_forest_t forest, FILE *vtufile, const char *da elems_in_tree = (t8_locidx_t) t8_element_array_get_count (&tree->leaf_elements); for (element_index = 0; element_index < elems_in_tree; element_index++) { /* Get a pointer to the element */ - element = t8_forest_get_leaf_element (forest, tree->elements_offset + element_index, NULL); + element = t8_forest_get_leaf_element (forest, tree->elements_offset + element_index, nullptr); T8_ASSERT (element != NULL); /* Execute the given callback on each element */ if (!kernel (forest, itree, tree, element_index, element, tree_class, 0, vtufile, &countcols, &data, T8_VTK_KERNEL_EXECUTE)) { /* call the kernel in clean-up modus */ - kernel (NULL, 0, NULL, 0, NULL, T8_ECLASS_COUNT, 0, NULL, NULL, &data, T8_VTK_KERNEL_CLEANUP); + kernel (nullptr, 0, nullptr, 0, nullptr, T8_ECLASS_COUNT, 0, nullptr, nullptr, &data, T8_VTK_KERNEL_CLEANUP); return 0; } /* After max_columns we break the line */ @@ -507,14 +506,14 @@ t8_forest_vtk_write_cell_data (t8_forest_t forest, FILE *vtufile, const char *da freturn = fprintf (vtufile, "\n "); if (freturn <= 0) { /* call the kernel in clean-up modus */ - kernel (NULL, 0, NULL, 0, NULL, T8_ECLASS_COUNT, 0, NULL, NULL, &data, T8_VTK_KERNEL_CLEANUP); + kernel (nullptr, 0, nullptr, 0, nullptr, T8_ECLASS_COUNT, 0, nullptr, nullptr, &data, T8_VTK_KERNEL_CLEANUP); return 0; } } } /* element loop ends here */ if (freturn <= 0) { /* call the kernel in clean-up modus */ - kernel (NULL, 0, NULL, 0, NULL, T8_ECLASS_INVALID, 0, NULL, NULL, &data, T8_VTK_KERNEL_CLEANUP); + kernel (nullptr, 0, nullptr, 0, nullptr, T8_ECLASS_INVALID, 0, nullptr, nullptr, &data, T8_VTK_KERNEL_CLEANUP); return 0; } } /* tree loop ends here */ @@ -533,10 +532,11 @@ t8_forest_vtk_write_cell_data (t8_forest_t forest, FILE *vtufile, const char *da /* Get a pointer to the element */ element = t8_forest_ghost_get_leaf_element (forest, ighost, element_index); /* Execute the given callback on each element */ - if (!kernel (forest, ighost + num_local_trees, NULL, element_index, element, ghost_eclass, 1, vtufile, + if (!kernel (forest, ighost + num_local_trees, nullptr, element_index, element, ghost_eclass, 1, vtufile, &countcols, &data, T8_VTK_KERNEL_EXECUTE)) { /* call the kernel in clean-up modus */ - kernel (NULL, 0, NULL, 0, NULL, T8_ECLASS_INVALID, 1, NULL, NULL, &data, T8_VTK_KERNEL_CLEANUP); + kernel (nullptr, 0, nullptr, 0, nullptr, T8_ECLASS_INVALID, 1, nullptr, nullptr, &data, + T8_VTK_KERNEL_CLEANUP); return 0; } /* After max_columns we break the line */ @@ -544,20 +544,21 @@ t8_forest_vtk_write_cell_data (t8_forest_t forest, FILE *vtufile, const char *da freturn = fprintf (vtufile, "\n "); if (freturn <= 0) { /* call the kernel in clean-up modus */ - kernel (NULL, 0, NULL, 0, NULL, T8_ECLASS_INVALID, 1, NULL, NULL, &data, T8_VTK_KERNEL_CLEANUP); + kernel (nullptr, 0, nullptr, 0, nullptr, T8_ECLASS_INVALID, 1, nullptr, nullptr, &data, + T8_VTK_KERNEL_CLEANUP); return 0; } } } /* element loop ends here */ if (freturn <= 0) { /* call the kernel in clean-up modus */ - kernel (NULL, 0, NULL, 0, NULL, T8_ECLASS_INVALID, 1, NULL, NULL, &data, T8_VTK_KERNEL_CLEANUP); + kernel (nullptr, 0, nullptr, 0, nullptr, T8_ECLASS_INVALID, 1, nullptr, nullptr, &data, T8_VTK_KERNEL_CLEANUP); return 0; } } /* ghost loop ends here */ } /* write_ghosts ends here */ /* call the kernel in clean-up modus */ - kernel (NULL, 0, NULL, 0, NULL, T8_ECLASS_INVALID, 0, NULL, NULL, &data, T8_VTK_KERNEL_CLEANUP); + kernel (nullptr, 0, nullptr, 0, nullptr, T8_ECLASS_INVALID, 0, nullptr, nullptr, &data, T8_VTK_KERNEL_CLEANUP); freturn = fprintf (vtufile, "\n \n"); if (freturn <= 0) { return 0; @@ -589,7 +590,7 @@ t8_forest_vtk_write_cells (t8_forest_t forest, FILE *vtufile, const int write_tr /* Write the connectivity information. * Thus for each tree we write the indices of its corner vertices. */ freturn = t8_forest_vtk_write_cell_data (forest, vtufile, "connectivity", T8_VTK_LOCIDX, "", 8, - t8_forest_vtk_cells_connectivity_kernel, write_ghosts, NULL); + t8_forest_vtk_cells_connectivity_kernel, write_ghosts, nullptr); if (!freturn) { goto t8_forest_vtk_cell_failure; } @@ -602,7 +603,7 @@ t8_forest_vtk_write_cells (t8_forest_t forest, FILE *vtufile, const int write_tr * be 4 and 7, since indices 0,1,2,3 refer to the vertices of the square * and indices 4,5,6 to the indices of the triangle. */ freturn = t8_forest_vtk_write_cell_data (forest, vtufile, "offsets", T8_VTK_LOCIDX, "", 8, - t8_forest_vtk_cells_offset_kernel, write_ghosts, NULL); + t8_forest_vtk_cells_offset_kernel, write_ghosts, nullptr); if (!freturn) { goto t8_forest_vtk_cell_failure; } @@ -612,7 +613,7 @@ t8_forest_vtk_write_cells (t8_forest_t forest, FILE *vtufile, const int write_tr * square/triangle/tet etc. */ freturn = t8_forest_vtk_write_cell_data (forest, vtufile, "types", "Int32", "", 8, t8_forest_vtk_cells_type_kernel, - write_ghosts, NULL); + write_ghosts, nullptr); if (!freturn) { goto t8_forest_vtk_cell_failure; @@ -634,7 +635,7 @@ t8_forest_vtk_write_cells (t8_forest_t forest, FILE *vtufile, const int write_tr /* Write the tree ids. */ freturn = t8_forest_vtk_write_cell_data (forest, vtufile, "treeid", T8_VTK_GLOIDX, "", 8, - t8_forest_vtk_cells_treeid_kernel, write_ghosts, NULL); + t8_forest_vtk_cells_treeid_kernel, write_ghosts, nullptr); if (!freturn) { goto t8_forest_vtk_cell_failure; } @@ -644,7 +645,7 @@ t8_forest_vtk_write_cells (t8_forest_t forest, FILE *vtufile, const int write_tr /* Write the mpiranks. */ freturn = t8_forest_vtk_write_cell_data (forest, vtufile, "mpirank", "Int32", "", 8, - t8_forest_vtk_cells_rank_kernel, write_ghosts, NULL); + t8_forest_vtk_cells_rank_kernel, write_ghosts, nullptr); if (!freturn) { goto t8_forest_vtk_cell_failure; } @@ -654,7 +655,7 @@ t8_forest_vtk_write_cells (t8_forest_t forest, FILE *vtufile, const int write_tr /* Write the element refinement levels. */ freturn = t8_forest_vtk_write_cell_data (forest, vtufile, "level", "Int32", "", 8, t8_forest_vtk_cells_level_kernel, - write_ghosts, NULL); + write_ghosts, nullptr); if (!freturn) { goto t8_forest_vtk_cell_failure; } @@ -668,7 +669,7 @@ t8_forest_vtk_write_cells (t8_forest_t forest, FILE *vtufile, const int write_tr /* Use 32 bit ints if the global element count fits, 64 bit otherwise. */ datatype = forest->global_num_leaf_elements > T8_LOCIDX_MAX ? T8_VTK_GLOIDX : T8_VTK_LOCIDX; freturn = t8_forest_vtk_write_cell_data (forest, vtufile, "element_id", datatype, "", 8, - t8_forest_vtk_cells_elementid_kernel, write_ghosts, NULL); + t8_forest_vtk_cells_elementid_kernel, write_ghosts, nullptr); if (!freturn) { goto t8_forest_vtk_cell_failure; } @@ -730,7 +731,7 @@ t8_forest_vtk_write_points (t8_forest_t forest, FILE *vtufile, const int write_g goto t8_forest_vtk_cell_failure; } freturn = t8_forest_vtk_write_cell_data (forest, vtufile, "Position", T8_VTK_FLOAT_NAME, "NumberOfComponents=\"3\"", - 8, t8_forest_vtk_cells_vertices_kernel, write_ghosts, NULL); + 8, t8_forest_vtk_cells_vertices_kernel, write_ghosts, nullptr); if (!freturn) { goto t8_forest_vtk_cell_failure; } @@ -792,7 +793,7 @@ t8_forest_vtk_write_ASCII (t8_forest_t forest, const char *fileprefix, const int const int write_level, const int write_element_id, int write_ghosts, const int num_data, t8_vtk_data_field_t *data) { - FILE *vtufile = NULL; + FILE *vtufile = nullptr; t8_locidx_t num_elements, num_points; char vtufilename[BUFSIZ]; int freturn; @@ -800,7 +801,7 @@ t8_forest_vtk_write_ASCII (t8_forest_t forest, const char *fileprefix, const int T8_ASSERT (forest != NULL); T8_ASSERT (t8_forest_is_committed (forest)); T8_ASSERT (fileprefix != NULL); - if (forest->ghosts == NULL || forest->ghosts->num_ghosts_elements == 0) { + if (forest->ghosts == nullptr || forest->ghosts->num_ghosts_elements == 0) { /* Never write ghost elements if there aren't any */ write_ghosts = 0; } @@ -832,7 +833,7 @@ t8_forest_vtk_write_ASCII (t8_forest_t forest, const char *fileprefix, const int /* Open the vtufile to write to */ vtufile = fopen (vtufilename, "w"); - if (vtufile == NULL) { + if (vtufile == nullptr) { t8_errorf ("Error when opening file %s\n", vtufilename); goto t8_forest_vtk_failure; } @@ -885,7 +886,7 @@ t8_forest_vtk_write_ASCII (t8_forest_t forest, const char *fileprefix, const int freturn = fclose (vtufile); /* We set it not NULL, even if fclose was not successful, since then any * following call to fclose would result in undefined behaviour. */ - vtufile = NULL; + vtufile = nullptr; if (freturn != 0) { /* Closing failed, this usually means that the final write operation could * not be completed. */ @@ -895,7 +896,7 @@ t8_forest_vtk_write_ASCII (t8_forest_t forest, const char *fileprefix, const int /* Writing was successful */ return 1; t8_forest_vtk_failure: - if (vtufile != NULL) { + if (vtufile != nullptr) { fclose (vtufile); } t8_errorf ("Error when writing vtk file.\n"); @@ -946,8 +947,8 @@ t8_cmesh_vtk_write_file_ext (const t8_cmesh_t cmesh, const char *fileprefix, con if (cmesh->mpirank == 0) { /* Write the pvtu header file. */ - int num_ranks_that_write = cmesh->set_partition ? cmesh->mpisize : 1; - if (t8_write_pvtu (fileprefix, num_ranks_that_write, 1, 1, 0, 0, 0, NULL)) { + int const num_ranks_that_write = cmesh->set_partition ? cmesh->mpisize : 1; + if (t8_write_pvtu (fileprefix, num_ranks_that_write, 1, 1, 0, 0, 0, nullptr)) { SC_ABORTF ("Error when writing file %s.pvtu\n", fileprefix); } } @@ -977,7 +978,7 @@ t8_cmesh_vtk_write_file_ext (const t8_cmesh_t cmesh, const char *fileprefix, con snprintf (vtufilename, BUFSIZ, "%s_%04d.vtu", fileprefix, cmesh->mpirank); vtufile = fopen (vtufilename, "wb"); - if (vtufile == NULL) { + if (vtufile == nullptr) { t8_global_errorf ("Could not open file %s for output.\n", vtufilename); return write_failure; } @@ -999,7 +1000,7 @@ t8_cmesh_vtk_write_file_ext (const t8_cmesh_t cmesh, const char *fileprefix, con " NumberOfComponents=\"3\" format=\"%s\">\n", T8_VTK_FLOAT_NAME, T8_VTK_FORMAT_STRING); - for (tree = t8_cmesh_get_first_tree (cmesh); tree != NULL; tree = t8_cmesh_get_next_tree (cmesh, tree)) { + for (tree = t8_cmesh_get_first_tree (cmesh); tree != nullptr; tree = t8_cmesh_get_next_tree (cmesh, tree)) { /* TODO: Use new geometry here. Need cmesh_get_reference coords function. */ vertices = t8_cmesh_get_tree_vertices (cmesh, tree->treeid); if (vertices == nullptr) { @@ -1061,7 +1062,7 @@ t8_cmesh_vtk_write_file_ext (const t8_cmesh_t cmesh, const char *fileprefix, con " \n", T8_VTK_LOCIDX, T8_VTK_FORMAT_STRING); - for (tree = t8_cmesh_get_first_tree (cmesh), count_vertices = 0; tree != NULL; + for (tree = t8_cmesh_get_first_tree (cmesh), count_vertices = 0; tree != nullptr; tree = t8_cmesh_get_next_tree (cmesh, tree)) { fprintf (vtufile, " "); for (k = 0; k < t8_eclass_num_vertices[tree->eclass]; ++k, count_vertices++) { @@ -1088,7 +1089,7 @@ t8_cmesh_vtk_write_file_ext (const t8_cmesh_t cmesh, const char *fileprefix, con " format=\"%s\">\n", T8_VTK_LOCIDX, T8_VTK_FORMAT_STRING); fprintf (vtufile, " "); - for (tree = t8_cmesh_get_first_tree (cmesh), sk = 1, offset = 0; tree != NULL; + for (tree = t8_cmesh_get_first_tree (cmesh), sk = 1, offset = 0; tree != nullptr; tree = t8_cmesh_get_next_tree (cmesh, tree), ++sk) { offset += t8_eclass_num_vertices[tree->eclass]; fprintf (vtufile, " %lld", offset); @@ -1113,7 +1114,7 @@ t8_cmesh_vtk_write_file_ext (const t8_cmesh_t cmesh, const char *fileprefix, con " format=\"%s\">\n", T8_VTK_FORMAT_STRING); fprintf (vtufile, " "); - for (tree = t8_cmesh_get_first_tree (cmesh), sk = 1; tree != NULL; + for (tree = t8_cmesh_get_first_tree (cmesh), sk = 1; tree != nullptr; tree = t8_cmesh_get_next_tree (cmesh, tree), ++sk) { fprintf (vtufile, " %d", t8_eclass_vtk_type[tree->eclass]); if (!(sk % 20) && tree->treeid != (cmesh->num_local_trees - 1)) @@ -1138,7 +1139,7 @@ t8_cmesh_vtk_write_file_ext (const t8_cmesh_t cmesh, const char *fileprefix, con " format=\"%s\">\n", T8_VTK_GLOIDX, T8_VTK_FORMAT_STRING); fprintf (vtufile, " "); - for (tree = t8_cmesh_get_first_tree (cmesh), sk = 1, offset = 0; tree != NULL; + for (tree = t8_cmesh_get_first_tree (cmesh), sk = 1, offset = 0; tree != nullptr; tree = t8_cmesh_get_next_tree (cmesh, tree), ++sk) { /* Since tree_id is actually 64 Bit but we store it as 32, we have to check * that we do not get into conversion errors */ @@ -1172,7 +1173,7 @@ t8_cmesh_vtk_write_file_ext (const t8_cmesh_t cmesh, const char *fileprefix, con " format=\"%s\">\n", "Int32", T8_VTK_FORMAT_STRING); fprintf (vtufile, " "); - for (tree = t8_cmesh_get_first_tree (cmesh), sk = 1, offset = 0; tree != NULL; + for (tree = t8_cmesh_get_first_tree (cmesh), sk = 1, offset = 0; tree != nullptr; tree = t8_cmesh_get_next_tree (cmesh, tree), ++sk) { fprintf (vtufile, " %i", cmesh->mpirank); if (!(sk % 8))