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  * forest the forest
41  * ltreeid the local tree id of the current tree
42  * element the element for which the query is executed
43  * is_leaf true if and only if \a element is a leaf element
44  * leaf_elements the leaf elements in \a forest that are descendants of \a element
45  * (or the element itself if \a is_leaf is true)
46  * tree_leaf_index the local index of the first leaf in \a leaf_elements
47  * query if not NULL, a query that is passed through from the search function
48  * query_index if \a query is not NULL the index of \a query in the queries array from
49  * \ref t8_forest_search
50  *
51  * return if \a query is not NULL: true if and only if the element 'matches' the query
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  */
55 typedef int (*t8_forest_search_query_fn) (t8_forest_t forest, t8_locidx_t ltreeid, const t8_element_t *element,
56  const int is_leaf, t8_element_array_t *leaf_elements,
57  t8_locidx_t tree_leaf_index, void *query, size_t query_index);
58 
59 T8_EXTERN_C_BEGIN ();
60 
61 /* TODO: Document */
62 void
63 t8_forest_split_array (const t8_element_t *element, t8_element_array_t *leaf_elements, size_t *offsets);
64 
65 /* TODO: comment */
66 /* Iterate over all leafs of an element that touch a given face of the element */
67 /* Callback is called in each recursive step with element as input.
68  * leaf_index is only not negative if element is a leaf, in which case it indicates
69  * the index of the leaf in the leafs of the tree. If it is negative, it is
70  * - (index + 1) */
71 /* Top-down iteration and callback is called on each intermediate level.
72  * If it returns false, the current element is not traversed further */
73 void
74 t8_forest_iterate_faces (t8_forest_t forest, t8_locidx_t ltreeid, const t8_element_t *element, int face,
75  t8_element_array_t *leaf_elements, void *user_data, t8_locidx_t tree_lindex_of_first_leaf,
76  t8_forest_iterate_face_fn callback);
77 
78 /* Perform a top-down search of the forest, executing a callback on each
79  * intermediate element. The search will enter each tree at least once.
80  * If the callback returns false for an element, its descendants
81  * are not further searched.
82  * To pass user data to the search_fn function use \ref t8_forest_set_user_data
83  */
84 void
85 t8_forest_search (t8_forest_t forest, t8_forest_search_query_fn search_fn, t8_forest_search_query_fn query_fn,
86  sc_array_t *queries);
87 
99 void
100 t8_forest_iterate_replace (t8_forest_t forest_new, t8_forest_t forest_old, t8_forest_replace_t replace_fn);
101 
102 T8_EXTERN_C_END ();
103 
104 #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:87
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:354