subdivide_quad
subdivide_quad(ind, C1, W1, CH1, PAR1, D1, A1, graded=True)
"Turn one cell of a quadtree or octree into four or eight, respectively
Subdivides the ind-th cell of a given octree, maintaining all the adjacency information
Parameters:
Name | Type | Description | Default |
---|---|---|---|
ind |
int
|
Index of cell to subdivide into input tree |
required |
C1 |
numpy double array
|
Matrix of cell centers of input tree |
required |
W1 |
numpy double array
|
Vector of cell half widths of input tree |
required |
CH1 |
numpy int array
|
Matrix of child indeces (-1 if leaf node) of input tree |
required |
PAR1 |
numpy int array
|
Vector of immediate parent indeces (to traverse upwards) of input tree |
required |
D1 |
numpy int array
|
Vector of tree depths of input tree |
required |
A1 |
scipy sparse.csr_matrix
|
Sparse node adjacency matrix of input tree, where a value of a in the (i,j) entry means that node j is to the a-th direction of i (a=1: left; a=2: right; a=3: bottom; a=4: top). |
required |
graded |
bool, optional (default True)
|
Whether to ensure that adjacent quads only differ by one in depth or not (this is useful for numerical applications, not so much for others like position queries). |
True
|
Returns:
Name | Type | Description |
---|---|---|
C2 |
numpy double array
|
Matrix of cell centers of output tree |
W2 |
numpy double array
|
Vector of cell half widths of output tree |
CH2 |
numpy int array
|
Matrix of child indeces (-1 if leaf node) of output tree |
PAR2 |
numpy int array
|
Vector of immediate parent indeces (to traverse upwards) of output tree |
D2 |
numpy int array
|
Vector of tree depths of output tree |
A2 |
scipy sparse.csr_matrix
|
Sparse node adjacency matrix of output tree, where a value of a in the (i,j) entry means that node j is to the a-th direction of i (a=1: left; a=2: right; a=3: bottom; a=4: top). |
See Also
initialize_quadtree.
Examples:
th = 2*np.pi*np.random.rand(200,1)
# Circle
P = 0.5*np.concatenate((np.cos(th),np.sin(th)),axis=1)
# Initialize quadtree
C,W,CH,PAR,D,A = gpytoolbox.initialize_quadtree(P,graded=False,max_depth=7,min_depth=4,vmin=np.array([-1,-1]),vmax=np.array([1,1]))
# Get leaf indices
leaf_ind = gpytoolbox.quadtree_children(CH)
# Let's choose an index:
ind = leaf_ind[20]
# And let's subdivide it
C1,W1,CH1,PAR1,D1,A1 = gpytoolbox.subdivide_quad(ind,C,W,CH,PAR,D,A,graded=False)
Source code in src/gpytoolbox/subdivide_quad.py
4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 |
|