Changeset 707 for inundation


Ignore:
Timestamp:
Dec 14, 2004, 2:18:21 PM (20 years ago)
Author:
duncan
Message:

fixed round off error in quad

Location:
inundation/ga/storm_surge/pyvolution
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • inundation/ga/storm_surge/pyvolution/quad.py

    r705 r707  
    181181                    self.store(point)
    182182                else:
     183                    x = self.__class__.mesh.coordinates[point][0]
     184                    y = self.__class__.mesh.coordinates[point][1]
     185                    print "(" + str(x) + "," + str(y) + ")"
    183186                    raise 'point not in region: %s' %str(point)
    184187               
     
    397400    ymax = max(mesh.coordinates[:,1])
    398401
     402   
    399403    #Ensure boundary points are fully contained in region
    400404    #It is a property of the cell structure that points on xmax or ymax of any given cell
     
    402406    #Hence, the root cell needs to be expanded slightly
    403407    ymax += (ymax-ymin)/10
    404     xmax += (xmax-xmin)/10   
    405 
    406 
     408    xmax += (xmax-xmin)/10
     409
     410    # To avoid round off error
     411    ymin -= (ymax-ymin)/10
     412    xmin -= (xmax-xmin)/10   
     413
     414    #print "xmin", xmin
     415    #print "xmax", xmax
     416    #print "ymin", ymin
     417    #print "ymax", ymax
     418   
    407419    #FIXME: Use mesh.filename if it exists
    408420    root = Cell(ymin, ymax, xmin, xmax,
  • inundation/ga/storm_surge/pyvolution/test_quad.py

    r705 r707  
    130130        self.assertEqual(result, [0,1,2,3])
    131131
     132     
     133    def test_build_quadtreeII(self):
     134
     135        self.cell = Cell(100, 140, 0, 40, 'cell')
    132136       
     137        p0 = [34.6292076111,-7999.92529297]
     138        p1 = [8000.0, 7999.0]
     139        p2 = [-7999.96630859, 7999.0]
     140        p3 = [34, 7999.97021484]
    133141
     142        points = [p0,p1,p2, p3]
     143        #bac, bce, ecf, dbe, daf, dae
     144        vertices = [[0,1,2],[0,2,3]]
     145
     146        mesh = Mesh(points, vertices)
     147
     148        #This was causing round off error
     149        Q = build_quadtree(mesh)
     150       
    134151#-------------------------------------------------------------
    135152if __name__ == "__main__":
Note: See TracChangeset for help on using the changeset viewer.