Changeset 6536


Ignore:
Timestamp:
Mar 17, 2009, 11:14:17 PM (15 years ago)
Author:
ole
Message:

Added first step in dealing with ticket:314 - a different way of
assessing whether a point is inside a triangle. Next step is to remove
all the now unnecessary epsilon tests in search_functions.py.

Tests using the Okushiri fitting example revealed that this approach is
over 30% faster.

Location:
anuga_core/source/anuga/fit_interpolate
Files:
2 edited

Legend:

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

    r6174 r6536  
    88import time
    99
     10from anuga.utilities.polygon import is_inside_triangle
    1011from anuga.utilities.numerical_tools import get_machine_precision
    1112from anuga.config import max_float
     
    145146    for k, tri_verts_norms in triangles:
    146147        tri = tri_verts_norms[0]
    147         n0, n1, n2 = tri_verts_norms[1]
     148
    148149        # k is the triangle index
    149150        # tri is a list of verts (x, y), representing a tringle
    150151        # Find triangle that contains x (if any) and interpolate
    151         element_found, sigma0, sigma1, sigma2 =\
    152                        find_triangle_compute_interpolation(tri, n0, n1, n2, x)
     152        if is_inside_triangle(x, tri, closed=True):
     153            n0, n1, n2 = tri_verts_norms[1]       
     154            element_found, sigma0, sigma1, sigma2 =\
     155                find_triangle_compute_interpolation(tri, n0, n1, n2, x)
     156        else:
     157            element_found = False
     158
     159           
    153160        if element_found is True:
    154161            # Don't look for any other triangles in the triangle list
  • anuga_core/source/anuga/fit_interpolate/test_search_functions.py

    r6152 r6536  
    210210#-------------------------------------------------------------
    211211if __name__ == "__main__":
    212     suite = unittest.makeSuite(Test_search_functions,'test')
    213     #suite = unittest.makeSuite(Test_search_functions,'expanding_search')
     212    suite = unittest.makeSuite(Test_search_functions, 'test')
    214213    runner = unittest.TextTestRunner(verbosity=1)
    215214    runner.run(suite)
Note: See TracChangeset for help on using the changeset viewer.