Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions src/t8_forest/t8_forest.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -1462,6 +1462,11 @@ t8_gloidx_t
t8_forest_element_face_neighbor (t8_forest_t forest, t8_locidx_t ltreeid, const t8_element_t *elem, t8_element_t *neigh,
const t8_eclass_t neigh_eclass, int face, int *neigh_face)
{
int dummy = 0;
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

I was first uncertain about this dummy. After looking through the code it is clear the variable is required locally. It is still an output, and if a user does not actually need it, it seems ok to just discard it.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

This is the simplest and least intrusive change to allow for nullptr to be passed to this function. Conceptually, it boils down to moving inside of the function the call site boilerplate that callers are doing right now if they don't care about neigh_face. Reading your comment it is not 100% clear to me if you agree with this implementation or if you want me to change something however.

if (neigh_face == nullptr) {
neigh_face = &dummy;
}

/* Get a pointer to the tree to read its element class */
const t8_eclass_t eclass = t8_forest_get_tree_class (forest, ltreeid);
const t8_scheme *scheme = t8_forest_get_scheme (forest);
Expand Down
1 change: 1 addition & 0 deletions src/t8_forest/t8_forest_general.h
Original file line number Diff line number Diff line change
Expand Up @@ -894,6 +894,7 @@ t8_forest_element_neighbor_eclass (const t8_forest_t forest, const t8_locidx_t l
* \param [in] neigh_eclass The eclass of \a neigh.
* \param [in] face The number of the face along which the neighbor should be constructed.
* \param [out] neigh_face The number of the face viewed from perspective of \a neigh.
* Can be nullptr, in which case the output is discarded.
* \return The global tree-id of the tree in which \a neigh is in.
* -1 if there exists no neighbor across that face. Domain boundary.
* -2 if the neighbor is not in a local tree or ghost tree. Process/Ghost boundary.
Expand Down