# Changeset 4653

Ignore:
Timestamp:
Aug 6, 2007, 9:56:50 AM (17 years ago)
Message:

checking in for benchmarking. When fitting cell data - triangle vertices and norms - are calculated the first time a point is looked for in a cell. This is to speed thing up.

Location:
anuga_core/source/anuga
Files:
4 edited

Unmodified
Removed
• ## anuga_core/source/anuga/fit_interpolate/search_functions.py

 r4651 k = -10.0 #Find vertices near x candidate_vertices = root.search(x[0], x[1]) #Get triangles in the cell that the point is in. # Triangle is a list, first element triangle_id, # second element the triangle triangles = root.search(x[0], x[1]) is_more_elements = True element_found, sigma0, sigma1, sigma2, k = \ _search_triangles_of_vertices(mesh, candidate_vertices, x) triangles, x) while not element_found and is_more_elements: candidate_vertices, branch = root.expand_search() triangles, branch = root.expand_search() if branch == []: # Searching all the verts from the root cell that haven't # been searched.  This is the last try element_found, sigma0, sigma1, sigma2, k = \ _search_triangles_of_vertices(mesh, candidate_vertices, x) _search_triangles_of_vertices(mesh,triangles, x) is_more_elements = False else: element_found, sigma0, sigma1, sigma2, k = \ _search_triangles_of_vertices(mesh, candidate_vertices, x) _search_triangles_of_vertices(mesh,triangles, x) return element_found, sigma0, sigma1, sigma2, k def _search_triangles_of_vertices(mesh, candidate_vertices, x): def _search_triangles_of_vertices(mesh, triangles, x): """Search for triangle containing x amongs candidate_vertices in mesh #For all vertices in same cell as point x for v in candidate_vertices: #FIXME (DSG-DSG): this catches verts with no triangle. #Currently pmesh is producing these. #this should be stopped, if mesh.number_of_triangles_per_node[v] == 0: continue # Get all triangles which has v as a vertex # The list has elements (triangle, vertex), but only the # first component will be used here triangle_list = mesh.get_triangles_and_vertices_per_node(node=v) for k, tri_verts_norms in triangles: tri = tri_verts_norms[0] n0, n1, n2 = tri_verts_norms[1] # k is the triangle index # tri is a list of verts (x, y), representing a tringle # Find triangle that contains x (if any) and interpolate for k, _ in triangle_list: element_found, sigma0, sigma1, sigma2, k =\ find_triangle_compute_interpolation(mesh, k, x) if element_found is True: # Don't look for any other triangles in the triangle list break element_found, sigma0, sigma1, sigma2 =\ find_triangle_compute_interpolation(tri, n0, n1, n2, x) if element_found is True: # Don't look for any other triangle_lists from the # candidate_vertices # Don't look for any other triangles in the triangle list break return element_found, sigma0, sigma1, sigma2, k def find_triangle_compute_interpolation(mesh, k, x): def find_triangle_compute_interpolation(triangle, n0, n1, n2, x): """Compute linear interpolation of point x and triangle k in mesh. It is assumed that x belongs to triangle k. # Get the three vertex_points of candidate triangle k xi0, xi1, xi2 = mesh.get_vertex_coordinates(triangle_id=k) xi0, xi1, xi2 = triangle # this is where we can call some fast c code. if  x[0] > xmax + epsilon: return False,0,0,0,0 return False,0,0,0 if  x[0] < xmin - epsilon: return False,0,0,0,0 return False,0,0,0 if  x[1] > ymax + epsilon: return False,0,0,0,0 return False,0,0,0 if  x[1] < ymin - epsilon: return False,0,0,0,0 return False,0,0,0 # Get the three normals n0 = mesh.get_normal(k, 0) n1 = mesh.get_normal(k, 1) n2 = mesh.get_normal(k, 2) #n0 = norms[0] #n1 = norms[1] #n2 = norms[2] # Compute interpolation else: element_found = False return element_found, sigma0, sigma1, sigma2, k return element_found, sigma0, sigma1, sigma2
• ## anuga_core/source/anuga/fit_interpolate/ticket178_benchmark.py

 r4652 ofile = 'lbm_resultsII.csv' delimiter = ',' run_profile = True #False #True run_profile = False #True is_fit_list = [True, False] num_of_points_list = [3, 200, 600, 2000, 6000, 10000, 20000]