Ignore:
Timestamp:
Mar 18, 2009, 3:00:24 PM (14 years ago)
Author:
ole
Message:

Removed more cluttter in search functions.

File:
1 edited

Legend:

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

    r6544 r6545  
    1919search_more_cells_time = initial_search_value
    2020
     21# FIXME(Ole): Could we come up with a less confusing structure?
    2122LAST_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.]),     
    2728                     num.array([-1.1,-1.1])))]]
    2829
    29 def search_tree_of_vertices(root, mesh, x):
     30def search_tree_of_vertices(root, x):
    3031    """
    3132    Find the triangle (element) that the point x is in.
     
    3334    Inputs:
    3435        root: A quad tree of the vertices
    35         mesh: The underlying mesh
    3636        x:    The point being placed
    3737   
     
    4848    global search_more_cells_time
    4949
    50     # This will be returned if element_found = False
    51     element_found = False   
    52     sigma2 = -10.0
    53     sigma0 = -10.0
    54     sigma1 = -10.0
    55     k = -10.0
    56 
    5750    # 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)
    6553                   
    6654    if element_found is True:
     
    7260    # second element the triangle
    7361    triangles = root.search(x[0], x[1])
     62    element_found, sigma0, sigma1, sigma2, k = \
     63                   _search_triangles_of_vertices(triangles, x)
     64
    7465    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()-t0
    79     #print "search_one_cell_time",search_one_cell_time
    80     #t0 = time.time()
    8166    while not element_found and is_more_elements:
    8267        triangles, branch = root.expand_search()
     
    8570            # been searched.  This is the last try
    8671            element_found, sigma0, sigma1, sigma2, k = \
    87                            _search_triangles_of_vertices(mesh, triangles, x)
     72                           _search_triangles_of_vertices(triangles, x)
    8873            is_more_elements = False
    8974        else:
    9075            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                       
    9478       
    9579    return element_found, sigma0, sigma1, sigma2, k
    9680
    9781
    98 def _search_triangles_of_vertices(mesh, triangles, x):
    99     """Search for triangle containing x amongs candidate_vertices in mesh
     82def _search_triangles_of_vertices(triangles, x):
     83    """Search for triangle containing x amongs candidate_vertices in triangles
    10084
    10185    This is called by search_tree_of_vertices once the appropriate node
    10286    has been found from the quad tree.
    10387   
    104 
    10588    This function is responsible for most of the compute time in
    10689    fit and interpolate.
     
    10992   
    11093    # These statments are needed if triangles is empty
    111     element_found = False
    11294    sigma2 = -10.0
    11395    sigma0 = -10.0
     
    11698
    11799    # For all vertices in same cell as point x
     100    element_found = False   
    118101    for k, tri_verts_norms in triangles:
    119102        tri = tri_verts_norms[0]
     
    163146   
    164147def search_times():
    165 
    166148    global search_one_cell_time
    167149    global search_more_cells_time
     
    170152
    171153def reset_search_times():
    172 
    173154    global search_one_cell_time
    174155    global search_more_cells_time
Note: See TracChangeset for help on using the changeset viewer.