Skip to content

Commit f7c6eb9

Browse files
authored
Merge pull request #1868 from DLR-AMR/doc_t8_forest_further
Documentation: Add doxygen documentation to remaining static functions in folder src/t8_forest/
2 parents b9633d6 + 24b793e commit f7c6eb9

File tree

3 files changed

+183
-27
lines changed

3 files changed

+183
-27
lines changed

src/t8_forest/t8_forest_balance.cxx

Lines changed: 22 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -32,14 +32,27 @@
3232
/* We want to export the whole implementation to be callable from "C" */
3333
T8_EXTERN_C_BEGIN ();
3434

35-
/* This is the adapt function called during one round of balance.
35+
/** This is the adapt function called during one round of balance.
3636
* We refine an element if it has any face neighbor with a level larger
3737
* than the element's level + 1.
38-
*/
39-
/* TODO: We currently do not adapt recursively since some functions such
38+
*
39+
* TODO: We currently do not adapt recursively since some functions such
4040
* as half neighbor computation require the forest to be committed. Thus,
4141
* we pass forest_from as a parameter. But doing so is not valid anymore
42-
* if we refine recursively. */
42+
* if we refine recursively.
43+
*
44+
* \param[in, out] forest The forest to be adapted / balanced.
45+
* \param[in] forest_from The forest from which the current one is derived.
46+
* \param[in] ltree_id The local id of the tree the element is in.
47+
* \param[in] tree_class The element class of the tree the element is in.
48+
* \param[in] lelement_id The local id of the element within the tree.
49+
* \param[in] scheme The scheme class.
50+
* \param[in] is_family A switch indicating whether the passed elements form a family.
51+
* \param[in] num_elements The number of elements passed as input.
52+
* \param[in] elements The elements array.
53+
*
54+
* \return 1 if the element(s) has/have to be refined, 0 otherwise.
55+
*/
4356
static int
4457
t8_forest_balance_adapt (t8_forest_t forest, t8_forest_t forest_from, const t8_locidx_t ltree_id,
4558
const t8_eclass_t tree_class, [[maybe_unused]] const t8_locidx_t lelement_id,
@@ -99,7 +112,11 @@ t8_forest_balance_adapt (t8_forest_t forest, t8_forest_t forest_from, const t8_l
99112
return 0;
100113
}
101114

102-
/* Collective function to compute the maximum occurring refinement level in a forest */
115+
/**
116+
* Collective function to compute the maximum occurring refinement level in a forest
117+
*
118+
* \param[in,out] forest The forest which the maximum refinement level is computed for and stored in.
119+
*/
103120
static void
104121
t8_forest_compute_max_element_level (t8_forest_t forest)
105122
{

src/t8_forest/t8_forest_ghost.cxx

Lines changed: 151 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -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+
*/
9299
static unsigned
93100
t8_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
*/
103117
static int
104118
t8_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+
*/
114136
static unsigned
115137
t8_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+
*/
124154
static int
125155
t8_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+
*/
136173
static unsigned
137174
t8_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+
*/
146191
static int
147192
t8_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+
*/
205257
static t8_ghost_remote_t *
206258
t8_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+
*/
393453
static void
394454
t8_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+
*/
505578
static int
506579
t8_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
*/
680757
static void
681758
t8_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
*/
811893
static t8_ghost_mpi_send_info_t *
812894
t8_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+
*/
9621052
static char *
9631053
t8_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. */
9971096
static 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+
*/
11551258
static void
11561259
t8_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+
*/
15731684
static size_t
15741685
t8_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+
*/
16361755
static t8_ghost_data_exchange_t *
16371756
t8_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+
*/
17281855
static void
17291856
t8_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+
*/
18411972
static void
18421973
t8_forest_ghost_reset (t8_forest_ghost_t *pghost)
18431974
{

src/t8_forest/t8_forest_iterate.cxx

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -36,8 +36,16 @@ typedef struct
3636
int num_children;
3737
} t8_forest_child_type_query_t;
3838

39-
/* This is the function that we call in sc_split_array to determine for an
40-
* element E that is a descendant of an element e, of which of e's children, E is a descendant. */
39+
/**
40+
* This is the function that we call in sc_split_array to determine for an
41+
* element E that is a descendant of an element e, of which of e's children, E is a descendant.
42+
*
43+
* \param[in] leaf_elements The larray of eaf elements.
44+
* \param[in] index The local id of the element within the leaf_elements array.
45+
* \param[in] data The query data.
46+
*
47+
* \return The element's ancestor id at the stored level is returned as the element's type.
48+
*/
4149
static size_t
4250
t8_forest_determine_child_type (sc_array_t *leaf_elements, size_t index, void *data)
4351
{

0 commit comments

Comments
 (0)