Changeset 2564
 Timestamp:
 Mar 21, 2006, 11:00:02 AM (18 years ago)
 File:

 1 edited
Legend:
 Unmodified
 Added
 Removed

inundation/fit_interpolate/interpolate.py
r2563 r2564 169 169 print 'Could not find triangle for point', x 170 170 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 vertices177 Return the associated sigma and k values178 (and if the element was found) .179 """180 #Find triangle containing x:181 element_found = False182 183 # This will be returned if element_found = False184 sigma2 = 10.0185 sigma0 = 10.0186 sigma1 = 10.0187 k = 10.0188 189 #Find vertices near x190 candidate_vertices = root.search(x[0], x[1])191 is_more_elements = True192 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't200 # been searched. This is the last try201 element_found, sigma0, sigma1, sigma2, k = \202 self._search_triangles_of_vertices(mesh,203 candidate_vertices, x)204 is_more_elements = False205 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, k211 212 def _search_triangles_of_vertices_OBSOLETE(self, mesh, candidate_vertices, x):213 #Find triangle containing x:214 element_found = False215 216 # This will be returned if element_found = False217 sigma2 = 10.0218 sigma0 = 10.0219 sigma1 = 10.0220 k = 10.0221 #print "*$* candidate_vertices", candidate_vertices222 #For all vertices in same cell as point x223 for v in candidate_vertices:224 #FIXME (DSGDSG): 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 continue229 #for each triangle id (k) which has v as a vertex230 for k, _ in mesh.vertexlist[v]:231 #Get the three vertex_points of candidate triangle232 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 normals237 n0 = mesh.get_normal(k, 0)238 n1 = mesh.get_normal(k, 1)239 n2 = mesh.get_normal(k, 2)240 241 #Compute interpolation242 sigma2 = dot((xxi0), n2)/dot((xi2xi0), n2)243 sigma0 = dot((xxi1), n0)/dot((xi0xi1), n0)244 sigma1 = dot((xxi2), n1)/dot((xi1xi2), n1)245 246 #FIXME: Maybe move out to test or something247 epsilon = 1.0e6248 assert abs(sigma0 + sigma1 + sigma2  1.0) < epsilon249 250 #Check that this triangle contains the data point251 252 #Sigmas can get negative within253 #machine precision on some machines (e.g nautilus)254 #Hence the small eps255 eps = 1.0e15256 if sigma0 >= eps and sigma1 >= eps and sigma2 >= eps:257 element_found = True258 break259 260 if element_found is True:261 #Don't look for any other triangle262 break263 return element_found, sigma0, sigma1, sigma2, k264 265 171 266 172
Note: See TracChangeset
for help on using the changeset viewer.