Changeset 6545
- Timestamp:
- Mar 18, 2009, 3:00:24 PM (16 years ago)
- Location:
- anuga_core/source/anuga/fit_interpolate
- Files:
-
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
anuga_core/source/anuga/fit_interpolate/fit.py
r6537 r6545 279 279 280 280 element_found, sigma0, sigma1, sigma2, k = \ 281 search_tree_of_vertices(self.root, self.mesh,x)281 search_tree_of_vertices(self.root, x) 282 282 283 283 if element_found is True: -
anuga_core/source/anuga/fit_interpolate/interpolate.py
r6223 r6545 484 484 x = point_coordinates[i] 485 485 element_found, sigma0, sigma1, sigma2, k = \ 486 search_tree_of_vertices(self.root, self.mesh,x)486 search_tree_of_vertices(self.root, x) 487 487 488 488 # Update interpolation matrix A if necessary -
anuga_core/source/anuga/fit_interpolate/search_functions.py
r6544 r6545 19 19 search_more_cells_time = initial_search_value 20 20 21 # FIXME(Ole): Could we come up with a less confusing structure? 21 22 LAST_TRIANGLE = [[-10, 22 (num.array([[max_float, max_float],23 [max_float, max_float],24 [max_float, max_float]]),25 (num.array([1 ,1], num.Int), #array default#26 num.array([0 ,0], num.Int), #array default#23 (num.array([[max_float, max_float], 24 [max_float, max_float], 25 [max_float, max_float]]), 26 (num.array([1.,1.]), 27 num.array([0.,0.]), 27 28 num.array([-1.1,-1.1])))]] 28 29 29 def search_tree_of_vertices(root, mesh,x):30 def search_tree_of_vertices(root, x): 30 31 """ 31 32 Find the triangle (element) that the point x is in. … … 33 34 Inputs: 34 35 root: A quad tree of the vertices 35 mesh: The underlying mesh36 36 x: The point being placed 37 37 … … 48 48 global search_more_cells_time 49 49 50 # This will be returned if element_found = False51 element_found = False52 sigma2 = -10.053 sigma0 = -10.054 sigma1 = -10.055 k = -10.056 57 50 # Search the last triangle first 58 try: 59 element_found, sigma0, sigma1, sigma2, k = \ 60 _search_triangles_of_vertices(mesh, last_triangle, x) 61 62 except: 63 print 'This should never happen:', last_triangle 64 element_found = False 51 element_found, sigma0, sigma1, sigma2, k = \ 52 _search_triangles_of_vertices(last_triangle, x) 65 53 66 54 if element_found is True: … … 72 60 # second element the triangle 73 61 triangles = root.search(x[0], x[1]) 62 element_found, sigma0, sigma1, sigma2, k = \ 63 _search_triangles_of_vertices(triangles, x) 64 74 65 is_more_elements = True 75 element_found, sigma0, sigma1, sigma2, k = \76 _search_triangles_of_vertices(mesh,77 triangles, x)78 #search_one_cell_time += time.time()-t079 #print "search_one_cell_time",search_one_cell_time80 #t0 = time.time()81 66 while not element_found and is_more_elements: 82 67 triangles, branch = root.expand_search() … … 85 70 # been searched. This is the last try 86 71 element_found, sigma0, sigma1, sigma2, k = \ 87 _search_triangles_of_vertices( mesh,triangles, x)72 _search_triangles_of_vertices(triangles, x) 88 73 is_more_elements = False 89 74 else: 90 75 element_found, sigma0, sigma1, sigma2, k = \ 91 _search_triangles_of_vertices(mesh, triangles, x) 92 #search_more_cells_time += time.time()-t0 93 #print "search_more_cells_time", search_more_cells_time 76 _search_triangles_of_vertices(triangles, x) 77 94 78 95 79 return element_found, sigma0, sigma1, sigma2, k 96 80 97 81 98 def _search_triangles_of_vertices( mesh,triangles, x):99 """Search for triangle containing x amongs candidate_vertices in mesh82 def _search_triangles_of_vertices(triangles, x): 83 """Search for triangle containing x amongs candidate_vertices in triangles 100 84 101 85 This is called by search_tree_of_vertices once the appropriate node 102 86 has been found from the quad tree. 103 87 104 105 88 This function is responsible for most of the compute time in 106 89 fit and interpolate. … … 109 92 110 93 # These statments are needed if triangles is empty 111 element_found = False112 94 sigma2 = -10.0 113 95 sigma0 = -10.0 … … 116 98 117 99 # For all vertices in same cell as point x 100 element_found = False 118 101 for k, tri_verts_norms in triangles: 119 102 tri = tri_verts_norms[0] … … 163 146 164 147 def search_times(): 165 166 148 global search_one_cell_time 167 149 global search_more_cells_time … … 170 152 171 153 def reset_search_times(): 172 173 154 global search_one_cell_time 174 155 global search_more_cells_time -
anuga_core/source/anuga/fit_interpolate/test_search_functions.py
r6544 r6545 53 53 54 54 x = [0.2, 0.7] 55 found, s0, s1, s2, k = search_tree_of_vertices(root, 56 mesh, 57 ensure_numeric(x)) 55 found, s0, s1, s2, k = search_tree_of_vertices(root, x) 58 56 assert k == 1 # Triangle one 59 57 assert found is True … … 80 78 81 79 found, s0, s1, s2, k = search_tree_of_vertices(root, 82 mesh,83 80 ensure_numeric(x)) 84 81 … … 112 109 [10, 3]]: 113 110 114 found, s0, s1, s2, k = search_tree_of_vertices(root, 115 mesh, 116 x) 111 found, s0, s1, s2, k = search_tree_of_vertices(root, x) 117 112 118 113 if k >= 0: … … 145 140 # print x, candidate_vertices 146 141 found, sigma0, sigma1, sigma2, k = \ 147 _search_triangles_of_vertices(mesh, 148 candidate_vertices, 142 _search_triangles_of_vertices(candidate_vertices, 149 143 x) 150 144 … … 167 161 #print x, candidate_vertices 168 162 found, sigma0, sigma1, sigma2, k = \ 169 _search_triangles_of_vertices(mesh, 170 candidate_vertices, 163 _search_triangles_of_vertices(candidate_vertices, 171 164 ensure_numeric(x)) 172 165 if k >= 0: … … 215 208 x = [2.5, 1.5] 216 209 element_found, sigma0, sigma1, sigma2, k = \ 217 search_tree_of_vertices(root, mesh,x)210 search_tree_of_vertices(root, x) 218 211 # One point 219 212 x = [3.00005, 2.999994] 220 213 element_found, sigma0, sigma1, sigma2, k = \ 221 search_tree_of_vertices(root, mesh,x)214 search_tree_of_vertices(root, x) 222 215 assert element_found is True 223 216 assert k == 1
Note: See TracChangeset
for help on using the changeset viewer.