t8  1.2.0
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>
34 #include <t8_forest.h>
35 
36 typedef int (*t8_forest_iterate_face_fn) (t8_forest_t forest,
37  t8_locidx_t ltreeid,
38  const t8_element_t *element,
39  int face, void *user_data,
41  tree_leaf_index);
42 
43 /*
44  * forest the forest
45  * ltreeid the local tree id of the current tree
46  * element the element for which the query is executed
47  * is_leaf true if and only if \a element is a leaf element
48  * leaf_elements the leaf elements in \a forest that are descendants of \a element
49  * (or the element itself if \a is_leaf is true)
50  * tree_leaf_index the local index of the first leaf in \a leaf_elements
51  * query if not NULL, a query that is passed through from the search function
52  * query_index if \a query is not NULL the index of \a query in the queries array from
53  * \ref t8_forest_search
54  *
55  * return if \a query is not NULL: true if and only if the element 'matches' the query
56  * if \a query is NULL: true if and only if the search should continue with the
57  * children of \a element and the queries should be performed for this element.
58  */
59 typedef int (*t8_forest_search_query_fn) (t8_forest_t forest,
60  t8_locidx_t ltreeid,
61  const t8_element_t *element,
62  const int is_leaf,
64  *leaf_elements,
65  t8_locidx_t tree_leaf_index,
66  void *query,
67  size_t query_index);
68 
69 T8_EXTERN_C_BEGIN ();
70 
71 /* TODO: Document */
72 void t8_forest_split_array (const t8_element_t *element,
73  t8_element_array_t *leaf_elements,
74  size_t *offsets);
75 
76 /* TODO: comment */
77 /* Iterate over all leafs of an element that touch a given face of the element */
78 /* Callback is called in each recursive step with element as input.
79  * leaf_index is only not negative if element is a leaf, in which case it indicates
80  * the index of the leaf in the leafs of the tree. If it is negative, it is
81  * - (index + 1) */
82 /* Top-down iteration and callback is called on each intermediate level.
83  * If it returns false, the current element is not traversed further */
84 void t8_forest_iterate_faces (t8_forest_t forest,
85  t8_locidx_t ltreeid,
86  const t8_element_t *element,
87  int face,
89  *leaf_elements, void *user_data,
91  tree_lindex_of_first_leaf,
92  t8_forest_iterate_face_fn
93  callback);
94 
95 /* Perform a top-down search of the forest, executing a callback on each
96  * intermediate element. The search will enter each tree at least once.
97  * If the callback returns false for an element, its descendants
98  * are not further searched.
99  * To pass user data to the search_fn function use \ref t8_forest_set_user_data
100  */
101 void t8_forest_search (t8_forest_t forest,
102  t8_forest_search_query_fn search_fn,
103  t8_forest_search_query_fn query_fn,
104  sc_array_t *queries);
105 
117 void t8_forest_iterate_replace (t8_forest_t forest_new,
118  t8_forest_t forest_old,
120  replace_fn);
121 
122 T8_EXTERN_C_END ();
123 
124 #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:94
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, int refine, int num_outgoing, t8_locidx_t first_outgoing, int num_incoming, t8_locidx_t first_incoming)
Callback function prototype to replace one set of elements with another.
Definition: t8_forest.h:90
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 elemnts in one forest are either direct children or parents of the element...
Definition: t8_forest_iterate.cxx:393