@@ -87,8 +87,15 @@ typedef struct
8787 sc_array_t remote_trees; /* Array of the remote trees of this process */
8888} t8_ghost_remote_t ;
8989
90- /* The hash function for the global tree hash.
91- * As hash value we just return the global tree id. */
90+ /* *
91+ * The hash function for the global tree hash.
92+ * As hash value we just return the global tree id.
93+ *
94+ * \param[in] ghost_gtree_hash Global tree hash.
95+ * \param[in] data Unused dummy Argument to allow passing this function to sc_hash_new.
96+ *
97+ * \return The global tree id.
98+ */
9299static unsigned
93100t8_ghost_gtree_hash_function (const void *ghost_gtree_hash, [[maybe_unused]] const void *data)
94101{
@@ -97,8 +104,15 @@ t8_ghost_gtree_hash_function (const void *ghost_gtree_hash, [[maybe_unused]] con
97104 return (unsigned ) object->global_id ;
98105}
99106
100- /* The equal function for two global tree hash objects.
101- * Two t8_ghost_gtree_hash_t are considered equal if theit global tree ids are the same.
107+ /* *
108+ * The equal function for two global tree hash objects.
109+ * Two t8_ghost_gtree_hash_t are considered equal if their global tree ids are the same.
110+ *
111+ * \param[in] ghost_gtreea Global tree hash object A
112+ * \param[in] ghost_gtreeb Global tree hash object B
113+ * \param[in] user Unused dummy Argument to allow passing this function to sc_hash_new.
114+ *
115+ * \return 1 if equal, 0 otherwise.
102116 */
103117static int
104118t8_ghost_gtree_equal_function (const void *ghost_gtreea, const void *ghost_gtreeb, [[maybe_unused]] const void *user)
@@ -110,7 +124,15 @@ t8_ghost_gtree_equal_function (const void *ghost_gtreea, const void *ghost_gtree
110124 return objecta->global_id == objectb->global_id ;
111125}
112126
113- /* The hash value for an entry of the process_offsets hash is the processes mpirank. */
127+ /* *
128+ * The hash value for an entry of the process_offsets hash is the processes mpirank.
129+ *
130+ * \param[in] process_data Process data as void pointer.
131+ * \param[in] user_data Unused dummy Argument to allow passing this function to sc_hash_new.
132+ *
133+ * \return The process' MPI rank.
134+ *
135+ */
114136static unsigned
115137t8_ghost_process_hash_function (const void *process_data, [[maybe_unused]] const void *user_data)
116138{
@@ -119,8 +141,16 @@ t8_ghost_process_hash_function (const void *process_data, [[maybe_unused]] const
119141 return process->mpirank ;
120142}
121143
122- /* The equal function for the process_offsets array.
123- * Two entries are the same if their mpiranks are equal. */
144+ /* *
145+ * The equal function for the process_offsets array.
146+ * Two entries are the same if their mpiranks are equal.
147+ *
148+ * \param[in] process_dataa Process offset array A
149+ * \param[in] process_datab Process offset array B
150+ * \param[in] user Unused dummy Argument to allow passing this function to sc_hash_new.
151+ *
152+ * \return 1 if equal, 0 if not.
153+ */
124154static int
125155t8_ghost_process_equal_function (const void *process_dataa, const void *process_datab,
126156 [[maybe_unused]] const void *user)
@@ -131,8 +161,15 @@ t8_ghost_process_equal_function (const void *process_dataa, const void *process_
131161 return processa->mpirank == processb->mpirank ;
132162}
133163
134- /* The hash function for the remote_ghosts hash table.
135- * The hash value for an mpirank is just the rank */
164+ /* *
165+ * The hash function for the remote_ghosts hash table.
166+ * The hash value for an mpirank is just the rank.
167+ *
168+ * \param[in] remote_data The remote ghost data as void pointer.
169+ * \param[in] user_data Unused dummy Argument to allow passing this function to sc_hash_new.
170+ *
171+ * \return The mpi rank.
172+ */
136173static unsigned
137174t8_ghost_remote_hash_function (const void *remote_data, [[maybe_unused]] const void *user_data)
138175{
@@ -141,8 +178,16 @@ t8_ghost_remote_hash_function (const void *remote_data, [[maybe_unused]] const v
141178 return remote->remote_rank ;
142179}
143180
144- /* The equal function for the remote hash table.
145- * Two entries are the same if they have the same rank. */
181+ /* *
182+ * The equal function for the remote hash table.
183+ * Two entries are the same if they have the same rank.
184+ *
185+ * \param[in] remote_dataa Remote hash table A.
186+ * \param[in] remote_datab Remote hash table B.
187+ * \param[in] user Unused dummy Argument to allow passing this function to sc_hash_new.
188+ *
189+ * \return 1 if the two have the same rank, 0 if not.
190+ */
146191static int
147192t8_ghost_remote_equal_function (const void *remote_dataa, const void *remote_datab, [[maybe_unused]] const void *user)
148193{
@@ -201,7 +246,14 @@ t8_forest_ghost_init (t8_forest_ghost_t *pghost, t8_ghost_type_t ghost_type)
201246 ghost->remote_processes = sc_array_new (sizeof (int ));
202247}
203248
204- /* Return the remote struct of a given remote rank */
249+ /* *
250+ * Return the remote struct of a given remote rank
251+ *
252+ * \param[in] forest A committed forest.
253+ * \param[in] remote The rank of the remote process.
254+ *
255+ * \return The remote struct of the rank as \see t8_ghost_remote_t pointer.
256+ */
205257static t8_ghost_remote_t *
206258t8_forest_ghost_get_remote (t8_forest_t forest, int remote)
207259{
@@ -389,7 +441,15 @@ t8_ghost_init_remote_tree (t8_forest_t forest, t8_gloidx_t gtreeid, int remote_r
389441
390442/* Add a new element to the remote hash table (if not already in it).
391443 * Must be called for elements in linear order
392- * element_index is the tree local index of this element */
444+ * element_index is the tree local index of this element.
445+ *
446+ * \param[in] forest The forest.
447+ * \param[in] ghost The ghost structure.
448+ * \param[in] remote_rank The remote rank.
449+ * \param[in] ltreeid Local id of the tree within the forest.
450+ * \param[in] elem The element to be added.
451+ * \param[in] element_index The element's tree-local id.
452+ */
393453static void
394454t8_ghost_add_remote (t8_forest_t forest, t8_forest_ghost_t ghost, int remote_rank, t8_locidx_t ltreeid,
395455 const t8_element_t *elem, t8_locidx_t element_index)
@@ -502,6 +562,19 @@ typedef struct
502562#endif
503563} t8_forest_ghost_boundary_data_t ;
504564
565+ /* *
566+ * This function is used as callback search function within \ref t8_forest_search to check whether the neighbors of
567+ * the current element are on another rank. If so, add the element to the ghost structures.
568+ *
569+ * \param[in] forest The forest.
570+ * \param[in] ltreeid Local ID of the ghost tree.
571+ * \param[in] element The current element.
572+ * \param[in] is_leaf Switch indicating whether \a element is a leaf.
573+ * \param[in] leaves The array of leaves (used for debug purposes only).
574+ * \param[in] tree_leaf_index If the element is a leaf, its tree-local id.
575+ *
576+ * \return 0 if the element and its face neighbors are completely owned by the current rank; 1 otherwise.
577+ */
505578static int
506579t8_forest_ghost_search_boundary (t8_forest_t forest, t8_locidx_t ltreeid, const t8_element_t *element,
507580 const int is_leaf, [[maybe_unused]] const t8_element_array_t *leaves,
@@ -676,6 +749,10 @@ t8_forest_ghost_fill_remote_v3 (t8_forest_t forest)
676749 * If ghost_method is 0, then we assume a balanced forest and
677750 * construct the remote processes by looking at the half neighbors of an element.
678751 * Otherwise, we use the owners_at_face method.
752+ *
753+ * \param[in] forest The forest.
754+ * \param[in] ghost The forest's ghost.
755+ * \param[in] ghost_method Switch indicating the ghost type.
679756 */
680757static void
681758t8_forest_ghost_fill_remote (t8_forest_t forest, t8_forest_ghost_t ghost, int ghost_method)
@@ -806,7 +883,12 @@ t8_forest_ghost_fill_remote (t8_forest_t forest, t8_forest_ghost_t ghost, int gh
806883 * Afterwards,
807884 * t8_forest_ghost_send_end
808885 * must be called to end the communication.
809- * Returns an array of mpi_send_info_t, one for each remote rank.
886+ *
887+ * \param[in] forest The forest.
888+ * \param[in] ghost The forest's ghost.
889+ * \param[out] requests The send requests as an array of pointers to sc_MPI_Requests.
890+ *
891+ * \return An array of mpi_send_info_t, holding one entry for each remote rank.
810892 */
811893static t8_ghost_mpi_send_info_t *
812894t8_forest_ghost_send_start (t8_forest_t forest, t8_forest_ghost_t ghost, sc_MPI_Request **requests)
@@ -957,8 +1039,16 @@ t8_forest_ghost_send_end ([[maybe_unused]] t8_forest_t forest, t8_forest_ghost_t
9571039 T8_FREE (requests);
9581040}
9591041
960- /* Receive a single message from a remote process, after the message was successfully probed.
961- * Returns the allocated receive buffer and the number of bytes received */
1042+ /* *
1043+ * Receive a single message from a remote process, after the message was successfully probed.
1044+ *
1045+ * \param[in] recv_rank The receiving rank.
1046+ * \param[in] comm The MPI communicator.
1047+ * \param[in] status The sc_MPI_Status.
1048+ * \param[in] recv_bytes The number of bytes to be received.
1049+ *
1050+ * \return The allocated receive buffer and the number of bytes received.
1051+ */
9621052static char *
9631053t8_forest_ghost_receive_message (int recv_rank, sc_MPI_Comm comm, sc_MPI_Status status, int *recv_bytes)
9641054{
@@ -992,6 +1082,15 @@ t8_forest_ghost_receive_message (int recv_rank, sc_MPI_Comm comm, sc_MPI_Status
9921082 * current_element_offset is updated in each step to store the element offset
9931083 * of the next ghost tree to be inserted.
9941084 * When called with the first message, current_element_offset must be set to 0.
1085+ *
1086+ * Currently we expect that the messages arrive in order of the sender's rank.
1087+ *
1088+ * \param[in] forest The forest.
1089+ * \param[in] ghost The forest's ghost.
1090+ * \param[in, out] current_element_offset The current element offset. Has to be zero on input and is updated in each step.
1091+ * \param[in] recv_rank The receiving rank.
1092+ * \param[in] recv_buffer The receive buffer.
1093+ * \param[in] recv_bytes The number of bytes received.
9951094 */
9961095/* Currently we expect that the messages arrive in order of the sender's rank. */
9971096static void
@@ -1151,7 +1250,11 @@ t8_recv_list_entry_equal (const void *v1, const void *v2, [[maybe_unused]] const
11511250
11521251/* Probe for all incoming messages from the remote ranks and receive them.
11531252 * We receive the message in the order in which they arrive. To achieve this,
1154- * we have to use polling. */
1253+ * we have to use polling.
1254+ *
1255+ * \param[in] forest The forest.
1256+ * \param[in] ghost The forest's ghost.
1257+ */
11551258static void
11561259t8_forest_ghost_receive (t8_forest_t forest, t8_forest_ghost_t ghost)
11571260{
@@ -1568,8 +1671,16 @@ t8_forest_ghost_remote_first_elem (t8_forest_t forest, int remote)
15681671 return proc_entry->ghost_offset ;
15691672}
15701673
1571- /* Fill the send buffer for a ghost data exchange for on remote rank.
1572- * returns the number of bytes in the buffer. */
1674+ /* *
1675+ * Fill the send buffer for a ghost data exchange for on remote rank.
1676+ *
1677+ * \param[in] forest The forest.
1678+ * \param[in] remote The remote rank to send to.
1679+ * \param[out] pbuffer The send buffer, allocated within this function.
1680+ * \param[in] element_data The element data.
1681+ *
1682+ * \return The number of bytes in the buffer.
1683+ */
15731684static size_t
15741685t8_forest_ghost_exchange_fill_send_buffer (t8_forest_t forest, int remote, char **pbuffer, sc_array_t *element_data)
15751686{
@@ -1633,6 +1744,14 @@ t8_forest_ghost_exchange_fill_send_buffer (t8_forest_t forest, int remote, char
16331744 return byte_count;
16341745}
16351746
1747+ /* *
1748+ * Begin the ghost data exchange communication.
1749+ *
1750+ * \param[in] forest A committed forest.
1751+ * \param[in] element_data The element data array.
1752+ *
1753+ * \return The ghost data exchange type, as pointer to \see t8_ghost_data_exchange_t.
1754+ */
16361755static t8_ghost_data_exchange_t *
16371756t8_forest_ghost_exchange_begin (t8_forest_t forest, sc_array_t *element_data)
16381757{
@@ -1725,6 +1844,14 @@ t8_forest_ghost_exchange_begin (t8_forest_t forest, sc_array_t *element_data)
17251844 return data_exchange;
17261845}
17271846
1847+ /* *
1848+ * Free the memory of the ghost data exchange.
1849+ *
1850+ * After all associated communication has terminated, this function is used to free the
1851+ * allocated memory of the send and receive buffers.
1852+ *
1853+ * \param[in] data_exchange The ghost data exchange type to free memory for.
1854+ */
17281855static void
17291856t8_forest_ghost_exchange_end (t8_ghost_data_exchange_t *data_exchange)
17301857{
@@ -1837,7 +1964,11 @@ t8_forest_ghost_print (t8_forest_t forest)
18371964 t8_debugf (" Ghost structure:\n %s\n %s\n " , remote_buffer, buffer);
18381965}
18391966
1840- /* Completely destroy a ghost structure */
1967+ /* *
1968+ * Completely destroy a ghost structure
1969+ *
1970+ * \param[in,out] pghost The ghost structure to be destroyed.
1971+ */
18411972static void
18421973t8_forest_ghost_reset (t8_forest_ghost_t *pghost)
18431974{
0 commit comments