Changeset 5717
- Timestamp:
- Aug 29, 2008, 4:40:31 PM (17 years ago)
- Location:
- anuga_core/source/anuga/pmesh
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
anuga_core/source/anuga/pmesh/mesh_interface.py
r4888 r5717 5 5 from Numeric import Float 6 6 from anuga.utilities.polygon import inside_polygon 7 8 7 9 8 10 # This is due to pmesh being a package and a module and … … 15 17 import exceptions 16 18 class PolygonError(exceptions.Exception): pass 19 class SegmentError(exceptions.Exception): pass 17 20 18 21 def create_mesh_from_regions(bounding_polygon, … … 129 132 See create_mesh_from_regions for documentation. 130 133 """ 131 #FIXME (OLE-DSG) 134 135 132 136 # check the segment indexes - throw an error if they are out of bounds 133 #(DSG) Yes! 137 if boundary_tags is not None: 138 max_segs = len(bounding_polygon) 139 for key in boundary_tags.keys(): 140 if len([x for x in boundary_tags[key] if x > max_segs-1]) >= 1: 141 msg = 'Boundary tag %s has segment out of bounds.'\ 142 %(str(key)) 143 raise SegmentError, msg 144 145 134 146 135 147 136 148 #In addition I reckon the polygons could be of class Geospatial_data 137 149 #(DSG) If polygons were classes caching would break in places. 138 139 # First check that interior polygons are fully contained in bounding140 # polygon141 #Note, Both poly's have the same geo_ref, therefore don't take into account142 # geo_ref143 150 144 151 # Simple check … … 149 156 150 157 # 151 if interior_regions is not None: 152 # Test that all the interior polygons are inside the bounding_poly 153 # and throw out those that aren't fully included. 158 if interior_regions is not None: 159 160 # Test that all the interior polygons are inside the 161 # bounding_poly and throw out those that aren't fully 162 # included. #Note, Both poly's have the same geo_ref, 163 # therefore don't take into account # geo_ref 164 154 165 155 166 polygons_inside_boundary = [] -
anuga_core/source/anuga/pmesh/test_mesh_interface.py
r5638 r5717 930 930 for t in domain.evolve(yieldstep, finaltime): 931 931 domain.write_time() 932 933 934 935 def test_create_mesh_from_regions_check_segs(self): 936 """Test that create_mesh_from_regions fails when an interior region is 937 outside bounding polygon. """ 938 939 940 # These are the absolute values 941 min_x = 10 942 min_y = 88 943 polygon = [[min_x,min_y],[1000,100],[1000,1000],[100,1000]] 944 945 boundary_tags = {'walls':[0,1,3],'bom':[2]} 946 # boundary_tags = {'walls':[0,1]} 947 # This one is inside bounding polygon - should pass 948 inner_polygon = [[800,400],[900,500],[800,600]] 949 950 interior_regions = [(inner_polygon, 5)] 951 m = create_mesh_from_regions(polygon, 952 boundary_tags, 953 10000000, 954 interior_regions=interior_regions) 955 956 boundary_tags = {'walls':[0,1,3,4],'bom':[2]} 957 958 try: 959 m = create_mesh_from_regions(polygon, 960 boundary_tags, 961 10000000, 962 interior_regions=interior_regions) 963 except: 964 pass 965 else: 966 msg = 'segment out of bounds not caught ' 967 raise msg 968 969 932 970 #------------------------------------------------------------- 933 971 if __name__ == "__main__": 934 972 suite = unittest.makeSuite(TestCase,'test') 935 #suite = unittest.makeSuite(TestCase,' concept_ungenerateIII')973 #suite = unittest.makeSuite(TestCase,'test_create_mesh_from_regions_check_segs') 936 974 runner = unittest.TextTestRunner() #verbosity=2) 937 975 runner.run(suite)
Note: See TracChangeset
for help on using the changeset viewer.