Ignore:
Timestamp:
Sep 26, 2007, 4:25:51 PM (17 years ago)
Author:
duncan
Message:

Increasing the number of verts in a quad tree cell. Having it set at 8 causes problems with verts connected to 9 triangles.

File:
1 edited

Legend:

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

    r4588 r4739  
    16841684        os.remove(velocity_x_file)
    16851685        os.remove(velocity_y_file)
     1686
     1687       
     1688    def test_interpolate_one_point_many_triangles(self):
     1689        # this test has 10 triangles that share the same vert.
     1690        # If the number of points per cell in  a quad tree is less
     1691        # than 10 it will crash.
     1692        z0 = [2.0, 5.0]
     1693        z1 = [2.0, 5.0]
     1694        z2 = [2.0, 5.0]
     1695        z3 = [2.0, 5.0]
     1696        z4 = [2.0, 5.0]
     1697        z5 = [2.0, 5.0]
     1698        z6 = [2.0, 5.0]
     1699        z7 = [2.0, 5.0]
     1700        z8 = [2.0, 5.0]
     1701        z9 = [2.0, 5.0]
     1702        z10 = [2.0, 5.0]
     1703       
     1704        v0 = [0.0, 0.0]
     1705        v1 = [1.0, 0.0]
     1706        v2 = [2.0, 0.0]
     1707        v3 = [3.0, 0.0]
     1708        v4 = [4.0, 0.0]
     1709        v5 = [0.0, 10.0]
     1710        v6 = [1.0, 10.0]
     1711        v7 = [2.0, 10.0]
     1712        v8 = [3.0, 10.0]
     1713        v9 = [4.0, 10.0]
     1714
     1715        vertices = [z0,v0, v1, v2, v3,v4 ,v5, v6, v7, v8, v9,
     1716                    z1, z2, z3, z4, z5, z6, z7, z8, z9]
     1717        triangles = [
     1718                      [11,1,2],
     1719                      [12,2,3],
     1720                      [13,3,4],
     1721                      [14,4,5],
     1722                      [7,6,15],
     1723                      [8,7,16],
     1724                      [9,8,17],
     1725                      [10,9,18],
     1726                      [6,1,19],
     1727                      [5,10,0]
     1728                      ]
     1729
     1730        d0 = [1.0, 1.0]
     1731        d1 = [1.0, 2.0]
     1732        d2 = [3.0, 1.0]
     1733        point_coords = [ d0, d1, d2]
     1734        try:
     1735            interp = Interpolate(vertices, triangles)
     1736        except RuntimeError:
     1737            self.failUnless(0 ==1,  'quad fails with 10 verts at the same \
     1738            position. Real problems have had 9. \
     1739            Should be able to handle 13.')
     1740        f = linear_function(vertices)
     1741        z = interp.interpolate(f, point_coords)
     1742        answer = linear_function(point_coords)
     1743
     1744        #print "z",z
     1745        #print "answer",answer
     1746        assert allclose(z, answer)
     1747
    16861748#-------------------------------------------------------------
    16871749if __name__ == "__main__":
    1688 
    1689     #suite = unittest.makeSuite(Test_Interpolate,'test_sigma_epsilon')
    16901750    suite = unittest.makeSuite(Test_Interpolate,'test')
     1751    #suite = unittest.makeSuite(Test_Interpolate,'test_interpolate_one_point_many_triangles')
    16911752    runner = unittest.TextTestRunner(verbosity=1)
    16921753    runner.run(suite)
Note: See TracChangeset for help on using the changeset viewer.