Ignore:
Timestamp:
Oct 25, 2006, 6:24:37 PM (18 years ago)
Author:
nick
Message:

added tests and comments

File:
1 edited

Legend:

Unmodified
Added
Removed
  • anuga_core/source/anuga/pmesh/test_mesh_interface.py

    r3742 r3868  
    556556        min_y = 88
    557557        polygon = [[min_x,min_y],[1000,100],[1000,1000],[100,1000]]
    558 
    559        
    560         boundary_tags = {'walls':[0,1],'bom':[2]}
    561 
     558       
     559        boundary_tags = {'walls':[0,1],'bom':[2]}
     560#        boundary_tags = {'walls':[0,1]}
    562561        # This one is inside bounding polygon - should pass
    563562        inner_polygon = [[800,400],[900,500],[800,600]]
    564        
     563
    565564        interior_regions = [(inner_polygon, 5)]
    566565        m = create_mesh_from_regions(polygon,
     
    571570
    572571        # This one sticks outside bounding polygon - should fail
    573         inner_polygon = [[800,400],[1100,500],[800,600]]
    574         interior_regions = [(inner_polygon, 5)]
     572        inner_polygon = [[800,400],[900,500],[800,600], [200, 995]]
     573        inner_polygon1 = [[800,400],[1100,500],[800,600]]
     574        interior_regions = [[inner_polygon, 50], [inner_polygon1, 50]]
    575575
    576576
     
    589589            raise msg
    590590
     591    def test_create_mesh_from_regions_interior_regions1(self):
     592        """Test that create_mesh_from_regions fails when an interior region is
     593         outside bounding polygon.       """
     594       
     595
     596        # These are the values
     597
     598        d0 = [310000, 7690000]
     599        d1 = [280000, 7690000]
     600        d2 = [270000, 7645000]
     601        d3 = [240000, 7625000]
     602        d4 = [270000, 7580000]
     603        d5 = [300000, 7590000]
     604        d6 = [340000, 7610000]
     605
     606        poly_all = [d0, d1, d2, d3, d4, d5, d6]
     607       
     608        i0 = [304000, 7607000]
     609        i1 = [302000, 7605000]
     610        i2 = [304000, 7603000]
     611        i3 = [307000, 7602000]
     612        i4 = [309000, 7603000]
     613#        i4 = [310000, 7580000]
     614        i5 = [307000, 7606000]
     615
     616        poly_onslow = [i0, i1, i2, i3, i4, i5]
     617
     618        #Thevenard Island
     619        j0 = [294000, 7629000]
     620        j1 = [285000, 7625000]
     621        j2 = [294000, 7621000]
     622        j3 = [299000, 7625000]
     623
     624        poly_thevenard = [j0, j1, j2, j3]
     625
     626        #med res around onslow
     627        l0 = [300000, 7610000]
     628        l1 = [285000, 7600000]
     629        l2 = [300000, 7597500]
     630        l3 = [310000, 7770000] #this one is outside
     631#        l3 = [310000, 7630000] #this one is NOT outside
     632        l4 = [315000, 7610000]
     633        poly_coast = [l0, l1, l2, l3, l4]
     634
     635        #general coast and local area to onslow region
     636        m0 = [270000, 7581000]
     637        m1 = [300000, 7591000]
     638        m2 = [339000, 7610000]
     639        m3 = [330000, 7630000]
     640        m4 = [290000, 7640000]
     641        m5 = [260000, 7600000]
     642
     643        poly_region = [m0, m1, m2, m3, m4, m5]
     644
     645        # This one sticks outside bounding polygon - should fail
     646
     647        interior_regions = [[poly_onslow, 50000], [poly_region, 50000], [poly_coast,100000], [poly_thevenard, 100000]]
     648
     649#        boundary_tags = {'walls':[0,1],'bom':[2]}
     650
     651        try:
     652            m = create_mesh_from_regions(poly_all,
     653                                         boundary_tags,
     654                                         10000000,
     655                                         interior_regions=interior_regions,
     656                                         verbose=False)
     657        except:
     658            pass
     659        else:
     660            msg = 'Interior polygon sticking outside bounding polygon should '
     661            msg += 'cause an Exception to be raised'
     662            raise msg
     663
    591664
    592665
     
    673746if __name__ == "__main__":
    674747    suite = unittest.makeSuite(TestCase,'test')
    675     #suite = unittest.makeSuite(meshTestCase,'test_asciiFile')
     748#    suite = unittest.makeSuite(TestCase,'test_create_mesh_from_regions_interior_regions')
    676749    runner = unittest.TextTestRunner() #verbosity=2)
    677750    runner.run(suite)
Note: See TracChangeset for help on using the changeset viewer.