1"""
2Grid visitor definitions file
3
4
5
6
7"""
8
9
10cimport numpy as np
11
12
13cdef struct GridTreeNode:
14    np.int32_t num_children
15    np.int32_t level
16    np.int64_t index
17    np.float64_t left_edge[3]
18    np.float64_t right_edge[3]
19    GridTreeNode **children
20    np.int64_t start_index[3]
21    np.int32_t dims[3]
22    np.float64_t dds[3]
23
24cdef struct GridTreeNodePadded:
25    np.int32_t num_children
26    np.int32_t level
27    np.int64_t index
28    np.float64_t left_edge_x
29    np.float64_t left_edge_y
30    np.float64_t left_edge_z
31    np.float64_t right_edge_x
32    np.float64_t right_edge_y
33    np.float64_t right_edge_z
34    np.int_t children_pointers
35    np.int64_t start_index_x
36    np.int64_t start_index_y
37    np.int64_t start_index_z
38    np.int32_t dims_x
39    np.int32_t dims_y
40    np.int32_t dims_z
41    np.float64_t dds_x
42    np.float64_t dds_y
43    np.float64_t dds_z
44
45cdef struct GridVisitorData:
46    GridTreeNode *grid
47    np.uint64_t index
48    np.uint64_t global_index
49    np.int64_t pos[3]       # position in ints
50    int n_tuples
51    int **child_tuples # [N_child][6], where 0-1 are x_start, x_end, etc.
52    void *array
53    int ref_factor # This may change on a grid-by-grid basis
54                   # It is the number of cells a child grid has per dimension
55                   # in a cell of this grid.
56
57cdef void free_tuples(GridVisitorData *data) nogil
58cdef void setup_tuples(GridVisitorData *data) nogil
59cdef np.uint8_t check_child_masked(GridVisitorData *data) nogil
60
61ctypedef void grid_visitor_function(GridVisitorData *data,
62                                         np.uint8_t selected) nogil
63# This is similar in spirit to the way oct visitor functions work.  However,
64# there are a few important differences.  Because the grid objects are expected
65# to be bigger, we don't need to pass them along -- we will not be recursively
66# visiting.  So the GridVisitorData will be updated in between grids.
67# Furthermore, we're only going to use them for a much smaller subset of
68# operations.  All child mask evaluation is going to be conducted inside the
69# outermost level of the visitor function, and visitor functions will receive
70# information about whether they have been selected and whether they are
71# covered by child cells.
72
73cdef grid_visitor_function count_cells
74cdef grid_visitor_function mask_cells
75cdef grid_visitor_function icoords_cells
76cdef grid_visitor_function ires_cells
77cdef grid_visitor_function fcoords_cells
78cdef grid_visitor_function fwidth_cells
79