Changeset 7810 for trunk/anuga_core/source/anuga/pmesh/mesh_quadtree.py
- Timestamp:
- Jun 8, 2010, 2:31:04 PM (14 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/anuga_core/source/anuga/pmesh/mesh_quadtree.py
r7778 r7810 6 6 7 7 """ 8 import time9 8 10 from anuga.utilities.numerical_tools import get_machine_precision11 9 from anuga.utilities.numerical_tools import ensure_numeric 12 10 from anuga.config import max_float … … 15 13 from anuga.geometry.aabb import AABB 16 14 17 from anuga.utilities import compile 18 if compile .can_use_C_extension('polygon_ext.c'):15 from anuga.utilities import compile as compile_c 16 if compile_c.can_use_C_extension('polygon_ext.c'): 19 17 # Underlying C implementations can be accessed 20 18 from polygon_ext import _is_inside_triangle 21 19 else: 22 msg = 'C implementations could not be accessed by %s.\n ' % __file__20 msg = 'C implementations could not be accessed by %s.\n ' % __file__ 23 21 msg += 'Make sure compile_all.py has been run as described in ' 24 22 msg += 'the ANUGA installation guide.' … … 69 67 x2, y2 = V[i3+2, :] 70 68 71 node_data = [i, V[i3:i3+3, :], normals[i,:]]69 node_data = [i, V[i3:i3+3, :], normals[i, :]] 72 70 73 71 # insert a tuple with an AABB, and the triangle index as data … … 76 74 node_data)) 77 75 78 def search_fast(self, x):76 def search_fast(self, point): 79 77 """ 80 78 Find the triangle (element) that the point x is in. 81 79 82 80 Inputs: 83 x: The point to test81 point: The point to test 84 82 85 83 Return: … … 93 91 """ 94 92 95 x = ensure_numeric(x, num.float)93 point = ensure_numeric(point, num.float) 96 94 97 95 # check the last triangle found first 98 96 element_found, sigma0, sigma1, sigma2, k = \ 99 self._search_triangles_of_vertices(self.last_triangle, x)97 self._search_triangles_of_vertices(self.last_triangle, point) 100 98 if element_found: 101 99 return True, sigma0, sigma1, sigma2, k … … 104 102 105 103 # test neighbouring tris 106 tri_data = branch.test_leaves( x)104 tri_data = branch.test_leaves(point) 107 105 element_found, sigma0, sigma1, sigma2, k = \ 108 self._search_triangles_of_vertices(tri_data, x)106 self._search_triangles_of_vertices(tri_data, point) 109 107 if element_found: 110 108 return True, sigma0, sigma1, sigma2, k … … 115 113 while branch: 116 114 for sibling in next_search: 117 tri_data = sibling.search( x)115 tri_data = sibling.search(point) 118 116 element_found, sigma0, sigma1, sigma2, k = \ 119 self._search_triangles_of_vertices(tri_data, x)117 self._search_triangles_of_vertices(tri_data, point) 120 118 if element_found: 121 119 return True, sigma0, sigma1, sigma2, k … … 124 122 branch = branch.parent 125 123 if branch: 126 tri_data = branch.test_leaves( x)124 tri_data = branch.test_leaves(point) 127 125 element_found, sigma0, sigma1, sigma2, k = \ 128 self._search_triangles_of_vertices(tri_data, x)126 self._search_triangles_of_vertices(tri_data, point) 129 127 if element_found: 130 128 return True, sigma0, sigma1, sigma2, k … … 133 131 134 132 135 def _search_triangles_of_vertices(self, triangles, x):133 def _search_triangles_of_vertices(self, triangles, point): 136 134 """Search for triangle containing x among triangle list 137 135 … … 141 139 Input check disabled to speed things up. 142 140 143 xis the point to test141 point is the point to test 144 142 triangles is the triangle list 145 143 return the found triangle and its interpolation sigma. … … 147 145 148 146 for node_data in triangles: 149 if bool(_is_inside_triangle( x, node_data[0][1], \147 if bool(_is_inside_triangle(point, node_data[0][1], \ 150 148 int(True), 1.0e-12, 1.0e-12)): 151 149 normals = node_data[0][2] … … 155 153 xi0, xi1, xi2 = node_data[0][1] 156 154 157 sigma0 = num.dot(( x-xi1), n0)/num.dot((xi0-xi1), n0)158 sigma1 = num.dot(( x-xi2), n1)/num.dot((xi1-xi2), n1)159 sigma2 = num.dot(( x-xi0), n2)/num.dot((xi2-xi0), n2)155 sigma0 = num.dot((point-xi1), n0)/num.dot((xi0-xi1), n0) 156 sigma1 = num.dot((point-xi2), n1)/num.dot((xi1-xi2), n1) 157 sigma2 = num.dot((point-xi0), n2)/num.dot((xi2-xi0), n2) 160 158 161 159 # Don't look for any other triangles in the triangle list
Note: See TracChangeset
for help on using the changeset viewer.