Changeset 2564


Ignore:
Timestamp:
Mar 21, 2006, 11:00:02 AM (19 years ago)
Author:
duncan
Message:

removing obsolete functions

File:
1 edited

Legend:

Unmodified
Added
Removed
  • inundation/fit_interpolate/interpolate.py

    r2563 r2564  
    169169                    print 'Could not find triangle for point', x
    170170        return A
    171 
    172     def _search_tree_of_vertices_OBSOLETE(self, root, mesh, x):
    173         """
    174         Find the triangle (element) that the point x is in.
    175 
    176         root: A quad tree of the vertices
    177         Return the associated sigma and k values
    178            (and if the element was found) .
    179         """
    180         #Find triangle containing x:
    181         element_found = False
    182 
    183         # This will be returned if element_found = False
    184         sigma2 = -10.0
    185         sigma0 = -10.0
    186         sigma1 = -10.0
    187         k = -10.0
    188            
    189         #Find vertices near x
    190         candidate_vertices = root.search(x[0], x[1])
    191         is_more_elements = True
    192 
    193         element_found, sigma0, sigma1, sigma2, k = \
    194                        self._search_triangles_of_vertices(mesh,
    195                                                           candidate_vertices, x)
    196         while not element_found and is_more_elements:
    197             candidate_vertices, branch = root.expand_search()
    198             if branch == []:
    199                 # Searching all the verts from the root cell that haven't
    200                 # been searched.  This is the last try
    201                 element_found, sigma0, sigma1, sigma2, k = \
    202                       self._search_triangles_of_vertices(mesh,
    203                                                          candidate_vertices, x)
    204                 is_more_elements = False
    205             else:
    206                 element_found, sigma0, sigma1, sigma2, k = \
    207                       self._search_triangles_of_vertices(mesh,
    208                                                          candidate_vertices, x)
    209 
    210         return element_found, sigma0, sigma1, sigma2, k
    211 
    212     def _search_triangles_of_vertices_OBSOLETE(self, mesh, candidate_vertices, x):
    213         #Find triangle containing x:
    214         element_found = False
    215 
    216         # This will be returned if element_found = False
    217         sigma2 = -10.0
    218         sigma0 = -10.0
    219         sigma1 = -10.0
    220         k = -10.0
    221         #print "*$* candidate_vertices", candidate_vertices
    222         #For all vertices in same cell as point x
    223         for v in candidate_vertices:
    224             #FIXME (DSG-DSG): this catches verts with no triangle.
    225             #Currently pmesh is producing these.
    226             #this should be stopped,
    227             if mesh.vertexlist[v] is None:
    228                 continue
    229             #for each triangle id (k) which has v as a vertex
    230             for k, _ in mesh.vertexlist[v]:
    231                 #Get the three vertex_points of candidate triangle
    232                 xi0 = mesh.get_vertex_coordinate(k, 0)
    233                 xi1 = mesh.get_vertex_coordinate(k, 1)
    234                 xi2 = mesh.get_vertex_coordinate(k, 2)
    235 
    236                 #Get the three normals
    237                 n0 = mesh.get_normal(k, 0)
    238                 n1 = mesh.get_normal(k, 1)
    239                 n2 = mesh.get_normal(k, 2)
    240 
    241                 #Compute interpolation
    242                 sigma2 = dot((x-xi0), n2)/dot((xi2-xi0), n2)
    243                 sigma0 = dot((x-xi1), n0)/dot((xi0-xi1), n0)
    244                 sigma1 = dot((x-xi2), n1)/dot((xi1-xi2), n1)
    245                    
    246                 #FIXME: Maybe move out to test or something
    247                 epsilon = 1.0e-6
    248                 assert abs(sigma0 + sigma1 + sigma2 - 1.0) < epsilon
    249 
    250                 #Check that this triangle contains the data point
    251                
    252                 #Sigmas can get negative within
    253                 #machine precision on some machines (e.g nautilus)
    254                 #Hence the small eps
    255                 eps = 1.0e-15
    256                 if sigma0 >= -eps and sigma1 >= -eps and sigma2 >= -eps:
    257                     element_found = True
    258                     break
    259 
    260             if element_found is True:
    261                 #Don't look for any other triangle
    262                 break
    263         return element_found, sigma0, sigma1, sigma2, k
    264 
    265171
    266172
Note: See TracChangeset for help on using the changeset viewer.