Skip to content

Commit

Permalink
Merge pull request #808 from DLR-AMR/more_const_params
Browse files Browse the repository at this point in the history
More const params
  • Loading branch information
sandro-elsweijer authored Nov 2, 2023
2 parents 2cb056f + 144d744 commit 71ba9b1
Show file tree
Hide file tree
Showing 7 changed files with 53 additions and 53 deletions.
2 changes: 1 addition & 1 deletion src/t8.c
Original file line number Diff line number Diff line change
Expand Up @@ -159,7 +159,7 @@ t8_init (int log_threshold)
}

void *
t8_sc_array_index_locidx (sc_array_t *array, t8_locidx_t it)
t8_sc_array_index_locidx (const sc_array_t *array, const t8_locidx_t it)
{
T8_ASSERT (it >= 0 && (size_t) it < array->elem_count);

Expand Down
2 changes: 1 addition & 1 deletion src/t8.h
Original file line number Diff line number Diff line change
Expand Up @@ -264,7 +264,7 @@ t8_init (int log_threshold);
* \return A void * pointing to entry \a it in \a array.
*/
void *
t8_sc_array_index_locidx (sc_array_t *array, t8_locidx_t it);
t8_sc_array_index_locidx (const sc_array_t *array, const t8_locidx_t it);

/* call this at the end of a header file to match T8_EXTERN_C_BEGIN (). */
T8_EXTERN_C_END ();
Expand Down
40 changes: 20 additions & 20 deletions src/t8_forest/t8_forest.c
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ t8_forest_is_initialized (t8_forest_t forest)
}

int
t8_forest_is_committed (t8_forest_t forest)
t8_forest_is_committed (const t8_forest_t forest)
{
if (!(forest != NULL && t8_refcount_is_active (&forest->rc) && forest->committed)) {
return 0;
Expand Down Expand Up @@ -306,7 +306,7 @@ t8_forest_set_user_data (t8_forest_t forest, void *data)
}

void *
t8_forest_get_user_data (t8_forest_t forest)
t8_forest_get_user_data (const t8_forest_t forest)
{
return forest->user_data;
}
Expand Down Expand Up @@ -695,23 +695,23 @@ t8_forest_commit (t8_forest_t forest)
}

t8_locidx_t
t8_forest_get_local_num_elements (t8_forest_t forest)
t8_forest_get_local_num_elements (const t8_forest_t forest)
{
T8_ASSERT (t8_forest_is_committed (forest));

return forest->local_num_elements;
}

t8_gloidx_t
t8_forest_get_global_num_elements (t8_forest_t forest)
t8_forest_get_global_num_elements (const t8_forest_t forest)
{
T8_ASSERT (t8_forest_is_committed (forest));

return forest->global_num_elements;
}

t8_locidx_t
t8_forest_get_num_ghosts (t8_forest_t forest)
t8_forest_get_num_ghosts (const t8_forest_t forest)
{
T8_ASSERT (t8_forest_is_committed (forest));

Expand Down Expand Up @@ -772,22 +772,22 @@ t8_forest_partition_cmesh (t8_forest_t forest, sc_MPI_Comm comm, int set_profili
}

sc_MPI_Comm
t8_forest_get_mpicomm (t8_forest_t forest)
t8_forest_get_mpicomm (const t8_forest_t forest)
{
T8_ASSERT (t8_forest_is_committed (forest));
return forest->mpicomm;
}

t8_gloidx_t
t8_forest_get_first_local_tree_id (t8_forest_t forest)
t8_forest_get_first_local_tree_id (const t8_forest_t forest)
{
T8_ASSERT (t8_forest_is_committed (forest));

return forest->first_local_tree;
}

t8_locidx_t
t8_forest_get_num_ghost_trees (t8_forest_t forest)
t8_forest_get_num_ghost_trees (const t8_forest_t forest)
{
if (forest->ghosts != NULL) {
return t8_forest_ghost_num_trees (forest);
Expand All @@ -798,7 +798,7 @@ t8_forest_get_num_ghost_trees (t8_forest_t forest)
}

t8_locidx_t
t8_forest_get_num_local_trees (t8_forest_t forest)
t8_forest_get_num_local_trees (const t8_forest_t forest)
{
t8_locidx_t num_trees;

Expand All @@ -813,15 +813,15 @@ t8_forest_get_num_local_trees (t8_forest_t forest)
}

t8_gloidx_t
t8_forest_get_num_global_trees (t8_forest_t forest)
t8_forest_get_num_global_trees (const t8_forest_t forest)
{
T8_ASSERT (t8_forest_is_committed (forest));

return forest->global_num_trees;
}

t8_gloidx_t
t8_forest_global_tree_id (t8_forest_t forest, t8_locidx_t ltreeid)
t8_forest_global_tree_id (const t8_forest_t forest, const t8_locidx_t ltreeid)
{
t8_locidx_t num_local_trees;
T8_ASSERT (t8_forest_is_committed (forest));
Expand All @@ -843,7 +843,7 @@ t8_forest_global_tree_id (t8_forest_t forest, t8_locidx_t ltreeid)
* forest is only partially committed. Thus, we cannot check whether the
* forest is committed here. */
t8_tree_t
t8_forest_get_tree (t8_forest_t forest, t8_locidx_t ltree_id)
t8_forest_get_tree (const t8_forest_t forest, const t8_locidx_t ltree_id)
{
T8_ASSERT (forest->trees != NULL);
T8_ASSERT (0 <= ltree_id && ltree_id < t8_forest_get_num_local_trees (forest));
Expand All @@ -857,7 +857,7 @@ t8_forest_get_tree_vertices (t8_forest_t forest, t8_locidx_t ltreeid)
}

t8_element_array_t *
t8_forest_tree_get_leafs (t8_forest_t forest, t8_locidx_t ltree_id)
t8_forest_tree_get_leafs (const t8_forest_t forest, const t8_locidx_t ltree_id)
{
T8_ASSERT (t8_forest_is_committed (forest));
T8_ASSERT (0 <= ltree_id && ltree_id < t8_forest_get_num_local_trees (forest));
Expand All @@ -866,7 +866,7 @@ t8_forest_tree_get_leafs (t8_forest_t forest, t8_locidx_t ltree_id)
}

t8_cmesh_t
t8_forest_get_cmesh (t8_forest_t forest)
t8_forest_get_cmesh (const t8_forest_t forest)
{
return forest->cmesh;
}
Expand Down Expand Up @@ -969,7 +969,7 @@ t8_forest_get_element_in_tree (t8_forest_t forest, t8_locidx_t ltreeid, t8_locid
}

t8_locidx_t
t8_forest_get_tree_element_offset (t8_forest_t forest, t8_locidx_t ltreeid)
t8_forest_get_tree_element_offset (const t8_forest_t forest, const t8_locidx_t ltreeid)
{
T8_ASSERT (t8_forest_is_committed (forest));

Expand Down Expand Up @@ -998,7 +998,7 @@ t8_forest_get_tree_num_elements (t8_forest_t forest, t8_locidx_t ltreeid)
}

t8_eclass_t
t8_forest_get_tree_class (t8_forest_t forest, t8_locidx_t ltreeid)
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);

Expand Down Expand Up @@ -1026,7 +1026,7 @@ t8_forest_get_first_local_element_id (t8_forest_t forest)
}

t8_scheme_cxx_t *
t8_forest_get_scheme (t8_forest_t forest)
t8_forest_get_scheme (const t8_forest_t forest)
{
T8_ASSERT (t8_forest_is_committed (forest));
T8_ASSERT (forest->scheme_cxx != NULL);
Expand All @@ -1035,7 +1035,7 @@ t8_forest_get_scheme (t8_forest_t forest)
}

t8_eclass_scheme_c *
t8_forest_get_eclass_scheme (t8_forest_t forest, t8_eclass_t eclass)
t8_forest_get_eclass_scheme (const t8_forest_t forest, const t8_eclass_t eclass)
{
T8_ASSERT (t8_forest_is_committed (forest));
T8_ASSERT (forest->scheme_cxx != NULL);
Expand All @@ -1055,14 +1055,14 @@ t8_forest_get_eclass_scheme_before_commit (t8_forest_t forest, t8_eclass_t eclas
}

t8_eclass_t
t8_forest_get_eclass (t8_forest_t forest, t8_locidx_t ltreeid)
t8_forest_get_eclass (const t8_forest_t forest, const t8_locidx_t ltreeid)
{
T8_ASSERT (t8_forest_is_committed (forest));
return t8_forest_get_tree (forest, ltreeid)->eclass;
}

t8_locidx_t
t8_forest_get_local_id (t8_forest_t forest, t8_gloidx_t gtreeid)
t8_forest_get_local_id (const t8_forest_t forest, const t8_gloidx_t gtreeid)
{
t8_gloidx_t ltreeid;
T8_ASSERT (t8_forest_is_committed (forest));
Expand Down
2 changes: 1 addition & 1 deletion src/t8_forest/t8_forest_cxx.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -197,7 +197,7 @@ t8_forest_compute_maxlevel (t8_forest_t forest)

/* Return the maximum level of a forest */
int
t8_forest_get_maxlevel (t8_forest_t forest)
t8_forest_get_maxlevel (const t8_forest_t forest)
{
T8_ASSERT (t8_forest_is_committed (forest));
T8_ASSERT (forest->maxlevel >= 0);
Expand Down
40 changes: 20 additions & 20 deletions src/t8_forest/t8_forest_general.h
Original file line number Diff line number Diff line change
Expand Up @@ -272,7 +272,7 @@ t8_forest_set_user_data (t8_forest_t forest, void *data);
* \see t8_forest_set_user_data
*/
void *
t8_forest_get_user_data (t8_forest_t forest);
t8_forest_get_user_data (const t8_forest_t forest);

/** Set the user function pointer of a forest. This can i.e. be used to pass user defined
* functions to the adapt routine.
Expand All @@ -285,7 +285,7 @@ t8_forest_get_user_data (t8_forest_t forest);
* \see t8_forest_get_user_function
*/
void
t8_forest_set_user_function (t8_forest_t forest, t8_generic_function_pointer functrion);
t8_forest_set_user_function (t8_forest_t forest, t8_generic_function_pointer function);

/** Return the user function pointer associated with a forest.
* \param [in] forest The forest.
Expand All @@ -294,7 +294,7 @@ t8_forest_set_user_function (t8_forest_t forest, t8_generic_function_pointer fun
* \see t8_forest_set_user_function
*/
t8_generic_function_pointer
t8_forest_get_user_function (t8_forest_t forest);
t8_forest_get_user_function (const t8_forest_t forest);

/** Set a source forest to be partitioned during commit.
* The partitioning is done according to the SFC and each rank is assigned
Expand Down Expand Up @@ -399,23 +399,23 @@ t8_forest_commit (t8_forest_t forest);
* the minimum of all maxlevels of the element classes in this forest.
*/
int
t8_forest_get_maxlevel (t8_forest_t forest);
t8_forest_get_maxlevel (const t8_forest_t forest);

/** Return the number of process local elements in the forest.
* \param [in] forest A forest.
* \return The number of elements on this process in \a forest.
* \a forest must be committed before calling this function.
*/
t8_locidx_t
t8_forest_get_local_num_elements (t8_forest_t forest);
t8_forest_get_local_num_elements (const t8_forest_t forest);

/** Return the number of global elements in the forest.
* \param [in] forest A forest.
* \return The number of elements (summed over all processes) in \a forest.
* \a forest must be committed before calling this function.
*/
t8_gloidx_t
t8_forest_get_global_num_elements (t8_forest_t forest);
t8_forest_get_global_num_elements (const t8_forest_t forest);

/** Return the number of ghost elements of a forest.
* \param [in] forest The forest.
Expand All @@ -425,7 +425,7 @@ t8_forest_get_global_num_elements (t8_forest_t forest);
* \a forest must be committed before calling this function.
*/
t8_locidx_t
t8_forest_get_num_ghosts (t8_forest_t forest);
t8_forest_get_num_ghosts (const t8_forest_t forest);

/** Return the element class of a forest local tree.
* \param [in] forest The forest.
Expand All @@ -434,7 +434,7 @@ t8_forest_get_num_ghosts (t8_forest_t forest);
* \a forest must be committed before calling this function.
*/
t8_eclass_t
t8_forest_get_eclass (t8_forest_t forest, t8_locidx_t ltreeid);
t8_forest_get_eclass (const t8_forest_t forest, const t8_locidx_t ltreeid);

/** Given a global tree id compute the forest local id of this tree.
* If the tree is a local tree, then the local id is between 0 and the number
Expand All @@ -446,7 +446,7 @@ t8_forest_get_eclass (t8_forest_t forest, t8_locidx_t ltreeid);
* \see https://github.com/DLR-AMR/t8code/wiki/Tree-indexing for more details about tree indexing.
*/
t8_locidx_t
t8_forest_get_local_id (t8_forest_t forest, t8_gloidx_t gtreeid);
t8_forest_get_local_id (const t8_forest_t forest, const t8_gloidx_t gtreeid);

/** Given the local id of a tree in a forest, compute the tree's local id in the associated cmesh.
* \param [in] forest The forest.
Expand Down Expand Up @@ -544,35 +544,35 @@ t8_forest_partition_cmesh (t8_forest_t forest, sc_MPI_Comm comm, int set_profili
* \a forest must be committed before calling this function.
*/
sc_MPI_Comm
t8_forest_get_mpicomm (t8_forest_t forest);
t8_forest_get_mpicomm (const t8_forest_t forest);

/** Return the global id of the first local tree of a forest.
* \param [in] forest The forest.
* \return The global id of the first local tree in \a forest.
*/
t8_gloidx_t
t8_forest_get_first_local_tree_id (t8_forest_t forest);
t8_forest_get_first_local_tree_id (const t8_forest_t forest);

/** Return the number of local trees of a given forest.
* \param [in] forest The forest.
* \return The number of local trees of that forest.
*/
t8_locidx_t
t8_forest_get_num_local_trees (t8_forest_t forest);
t8_forest_get_num_local_trees (const t8_forest_t forest);

/** Return the number of ghost trees of a given forest.
* \param [in] forest The forest.
* \return The number of ghost trees of that forest.
*/
t8_locidx_t
t8_forest_get_num_ghost_trees (t8_forest_t forest);
t8_forest_get_num_ghost_trees (const t8_forest_t forest);

/** Return the number of global trees of a given forest.
* \param [in] forest The forest.
* \return The number of global trees of that forest.
*/
t8_gloidx_t
t8_forest_get_num_global_trees (t8_forest_t forest);
t8_forest_get_num_global_trees (const t8_forest_t forest);

/** Return the global id of a local tree or a ghost tree.
* \param [in] forest The forest.
Expand All @@ -583,7 +583,7 @@ t8_forest_get_num_global_trees (t8_forest_t forest);
* \see https://github.com/DLR-AMR/t8code/wiki/Tree-indexing for more details about tree indexing.
*/
t8_gloidx_t
t8_forest_global_tree_id (t8_forest_t forest, t8_locidx_t ltreeid);
t8_forest_global_tree_id (const t8_forest_t forest, const t8_locidx_t ltreeid);

/** Return a pointer to a tree in a forest.
* \param [in] forest The forest.
Expand All @@ -592,7 +592,7 @@ t8_forest_global_tree_id (t8_forest_t forest, t8_locidx_t ltreeid);
* \a forest must be committed before calling this function.
*/
t8_tree_t
t8_forest_get_tree (t8_forest_t forest, t8_locidx_t ltree_id);
t8_forest_get_tree (const t8_forest_t forest, const t8_locidx_t ltree_id);

/** Return a pointer to the vertex coordinates of a tree.
* \param [in] forest The forest.
Expand All @@ -610,7 +610,7 @@ t8_forest_get_tree_vertices (t8_forest_t forest, t8_locidx_t ltreeid);
* of this tree.
*/
t8_element_array_t *
t8_forest_tree_get_leafs (t8_forest_t forest, t8_locidx_t ltree_id);
t8_forest_tree_get_leafs (const t8_forest_t forest, const t8_locidx_t ltree_id);

/** Return a cmesh associated to a forest.
* \param [in] forest The forest.
Expand Down Expand Up @@ -659,7 +659,7 @@ t8_forest_get_tree_num_elements (t8_forest_t forest, t8_locidx_t ltreeid);
* \note \a forest must be committed before calling this function.
*/
t8_locidx_t
t8_forest_get_tree_element_offset (t8_forest_t forest, t8_locidx_t ltreeid);
t8_forest_get_tree_element_offset (const t8_forest_t forest, const t8_locidx_t ltreeid);

/** Return the number of elements of a tree.
* \param [in] tree A tree in a forest.
Expand All @@ -674,7 +674,7 @@ t8_forest_get_tree_element_count (t8_tree_t tree);
* \return The element class of the tree with local id \a ltreeid.
*/
t8_eclass_t
t8_forest_get_tree_class (t8_forest_t forest, t8_locidx_t ltreeid);
t8_forest_get_tree_class (const t8_forest_t forest, const t8_locidx_t ltreeid);

/** Compute the global index of the first local element of a forest.
* This function is collective.
Expand All @@ -692,7 +692,7 @@ t8_forest_get_first_local_element_id (t8_forest_t forest);
* \see t8_forest_set_scheme
*/
t8_scheme_cxx_t *
t8_forest_get_scheme (t8_forest_t forest);
t8_forest_get_scheme (const t8_forest_t forest);

/** Return the eclass scheme of a given element class associated to a forest.
* \param [in] forest. A committed forest.
Expand Down
Loading

0 comments on commit 71ba9b1

Please sign in to comment.