t8  UNKNOWN
t8code is a C library to manage a forest of adaptive space-trees of general element classes in parallel.
t8_forest_iterate.h
Go to the documentation of this file.
1 /*
2  This file is part of t8code.
3  t8code is a C library to manage a collection (a forest) of multiple
4  connected adaptive space-trees of general element classes in parallel.
5 
6  Copyright (C) 2015 the developers
7 
8  t8code is free software; you can redistribute it and/or modify
9  it under the terms of the GNU General Public License as published by
10  the Free Software Foundation; either version 2 of the License, or
11  (at your option) any later version.
12 
13  t8code is distributed in the hope that it will be useful,
14  but WITHOUT ANY WARRANTY; without even the implied warranty of
15  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16  GNU General Public License for more details.
17 
18  You should have received a copy of the GNU General Public License
19  along with t8code; if not, write to the Free Software Foundation, Inc.,
20  51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
21 */
22 
28 /* TODO: begin documenting this file: make doxygen 2>&1 | grep t8_forest_iterate */
29 
30 #ifndef T8_FOREST_ITERATE_H
31 #define T8_FOREST_ITERATE_H
32 
33 #include <t8.h>
35 
36 typedef int (*t8_forest_iterate_face_fn) (t8_forest_t forest, t8_locidx_t ltreeid, const t8_element_t *element,
37  int face, void *user_data, t8_locidx_t tree_leaf_index);
38 
39 /*
40  * \param[in] forest the forest
41  * \param[in] ltreeid the local tree id of the current tree
42  * \param[in] element the element for which the query is executed
43  * \param[in] is_leaf true if and only if \a element is a leaf element
44  * \param[in] leaf_elements the leaf elements in \a forest that are descendants of \a element (or the element
45  * itself if \a is_leaf is true)
46  * \param[in] tree_leaf_index the local index of the first leaf in \a leaf_elements
47  * \param[in] queries if not NULL, a query that is passed through from the search function
48  * \param[in] query_indices if \a query is not NULL the indices of \a query in the \a queries array from \ref
49  * t8_forest_search
50  * \param[in, out] query_matches if \a query is not NULL: true at the i-th index if and only if the element 'matches'
51  * the query of the i-th query index.
52  * if \a query is NULL: true if and only if the search should continue with the
53  * children of \a element and the queries should be performed for this element.
54  * \param[in] num_active_queries The number of currently active queries. Does not have to be equal to query->elem_count,
55  * since some queries might have been deactivated from previous calls
56  */
57 typedef int (*t8_forest_search_query_fn) (t8_forest_t forest, const t8_locidx_t ltreeid, const t8_element_t *element,
58  const int is_leaf, const t8_element_array_t *leaf_elements,
59  const t8_locidx_t tree_leaf_index, void *query, sc_array_t *query_indices,
60  int *query_matches, const size_t num_active_queries);
61 
62 T8_EXTERN_C_BEGIN ();
63 
64 /* TODO: Document */
65 void
66 t8_forest_split_array (const t8_element_t *element, t8_element_array_t *leaf_elements, size_t *offsets);
67 
68 /* TODO: comment */
69 /* Iterate over all leaves of an element that touch a given face of the element */
70 /* Callback is called in each recursive step with element as input.
71  * leaf_index is only not negative if element is a leaf, in which case it indicates
72  * the index of the leaf in the leaves of the tree. If it is negative, it is
73  * - (index + 1) */
74 /* Top-down iteration and callback is called on each intermediate level.
75  * If it returns false, the current element is not traversed further */
76 void
77 t8_forest_iterate_faces (t8_forest_t forest, t8_locidx_t ltreeid, const t8_element_t *element, int face,
78  t8_element_array_t *leaf_elements, void *user_data, t8_locidx_t tree_lindex_of_first_leaf,
79  t8_forest_iterate_face_fn callback);
80 
81 /* Perform a top-down search of the forest, executing a callback on each
82  * intermediate element. The search will enter each tree at least once.
83  * If the callback returns false for an element, its descendants
84  * are not further searched.
85  * To pass user data to the search_fn function use \ref t8_forest_set_user_data
86  */
87 void
88 t8_forest_search (t8_forest_t forest, t8_forest_search_query_fn search_fn, t8_forest_search_query_fn query_fn,
89  sc_array_t *queries);
90 
102 void
103 t8_forest_iterate_replace (t8_forest_t forest_new, t8_forest_t forest_old, t8_forest_replace_t replace_fn);
104 
105 T8_EXTERN_C_END ();
106 
107 #endif /* !T8_FOREST_ITERATE_H */
The t8_element_array_t is an array to store t8_element_t * of a given eclass_scheme implementation.
Definition: t8_containers.h:42
This structure is private to the implementation.
Definition: t8_forest_types.h:69
This is the administrative header file for t8code.
int32_t t8_locidx_t
A type for processor-local indexing.
Definition: t8.h:89
struct t8_element t8_element_t
Opaque structure for a generic element, only used as pointer.
Definition: t8_element.h:42
We define the forest of trees in this file.
void(* t8_forest_replace_t)(t8_forest_t forest_old, t8_forest_t forest_new, t8_locidx_t which_tree, t8_eclass_scheme_c *ts, const int refine, const int num_outgoing, const t8_locidx_t first_outgoing, const int num_incoming, const t8_locidx_t first_incoming)
Callback function prototype to replace one set of elements with another.
Definition: t8_forest_general.h:86
void t8_forest_iterate_replace(t8_forest_t forest_new, t8_forest_t forest_old, t8_forest_replace_t replace_fn)
Given two forest where the elements in one forest are either direct children or parents of the elemen...
Definition: t8_forest_iterate.cxx:343