- Timestamp:
- Mar 18, 2009, 3:00:24 PM (14 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
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
Note: See TracChangeset
for help on using the changeset viewer.