Ignore:
Timestamp:
Oct 12, 2005, 9:09:20 AM (20 years ago)
Author:
duncan
Message:

comments, test added.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • inundation/pyvolution/test_least_squares.py

    r1891 r1898  
    573573        #Point on common vertex
    574574        d6 = [0., 5.]
    575 
    576 
     575       
    577576        point_coords = [d0, d1, d2, d3, d4, d5, d6]
    578577
     
    593592                   [5., 7.5, 7.5, -5.], # (2.5, 2.5)
    594593                   [5., 6., 9., -2.],   # (4,1)
    595                    [5., 10., 5., -10.]] # (0,5)
     594                   [5., 10., 5., -10.]]  # (0,5)
    596595
    597596        #print "***********"
     
    599598        #print "answer",answer
    600599        #print "***********"
     600
     601        #Should an error message be returned if points are outside
     602        # of the mesh? Not currently. 
     603
     604        assert allclose(z, answer)
     605
     606
     607    def test_interpolate_point_outside_of_mesh(self):
     608        """Test linear interpolation of known values at vertices to
     609        new points inside a triangle
     610        """
     611        a = [0.0, 0.0]
     612        b = [0.0, 5.0]
     613        c = [5.0, 0.0]
     614        d = [5.0, 5.0]
     615
     616        vertices = [a, b, c, d]
     617        triangles = [ [1,0,2], [2,3,1] ]   #bac, cdb
     618
     619        #Far away point
     620        d7 = [-1., -1.]
     621       
     622        point_coords = [ d7]
     623
     624        interp = Interpolation(vertices, triangles, point_coords)
     625
     626        #Known values at vertices
     627        #Functions are x+y, x+2y, 2x+y, x-y-5
     628        f = [ [0., 0., 0., -5.],        # (0,0)
     629              [5., 10., 5., -10.],      # (0,5)
     630              [5., 5., 10.0, 0.],       # (5,0)
     631              [10., 15., 15., -5.]]     # (5,5)
     632
     633        z = interp.interpolate(f)
     634        answer = [ [0., 0., 0., 0.]] # (-1,-1)
     635
     636        #print "***********"
     637        #print "z",z
     638        #print "answer",answer
     639        #print "***********"
     640
     641        #Should an error message be returned if points are outside
     642        # of the mesh? Not currently. 
    601643
    602644        assert allclose(z, answer)
Note: See TracChangeset for help on using the changeset viewer.