Changeset 2402 for inundation/pmesh/test_mesh_interface.py
- Timestamp:
- Feb 14, 2006, 3:29:10 PM (19 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
inundation/pmesh/test_mesh_interface.py
r2301 r2402 5 5 from mesh_interface import * 6 6 from load_mesh.loadASCII import * 7 from coordinate_transforms.geo_reference import Geo_reference8 7 from utilities.polygon import inside_polygon 8 from coordinate_transforms.geo_reference import Geo_reference,DEFAULT_ZONE 9 9 10 10 class TestCase(unittest.TestCase): … … 107 107 closed = False), 108 108 'FAILED!') 109 110 111 112 def test_create_mesh_from_regions2(self): 113 114 # These are the absolute values 115 min_x = 10 116 min_y = 88 117 polygon_absolute = [[min_x,min_y],[1000,100],[1000,1000],[100,1000]] 118 119 x_p = -10 120 y_p = -40 121 zone = 808 122 geo_ref_poly = Geo_reference(zone, x_p, y_p) 123 polygon = geo_ref_poly.change_points_geo_ref(polygon_absolute) 124 125 boundary_tags = {'walls':[0,1],'bom':[2]} 126 127 inner1_polygon_absolute = [[10,10],[20,10],[20,20],[10,20]] 128 inner1_polygon = geo_ref_poly. \ 129 change_points_geo_ref(inner1_polygon_absolute) 130 131 inner2_polygon_absolute = [[30,30],[40,30],[40,40],[30,40]] 132 inner2_polygon = geo_ref_poly. \ 133 change_points_geo_ref(inner2_polygon_absolute) 134 135 interior_regions = [(inner1_polygon, 5),(inner2_polygon, 0.2)] 136 m = create_mesh_from_regions(polygon, 137 boundary_tags, 138 10000000, 139 interior_regions=interior_regions, 140 poly_geo_reference=geo_ref_poly) 141 142 143 # Test the mesh instance 144 self.failUnless(len(m.regions)==3, 145 'FAILED!') 146 segs = m.getUserSegments() 147 self.failUnless(len(segs)==12, 148 'FAILED!') 149 self.failUnless(len(m.userVertices)==12, 150 'FAILED!') 151 self.failUnless(segs[0].tag=='walls', 152 'FAILED!') 153 self.failUnless(segs[1].tag=='walls', 154 'FAILED!') 155 156 self.failUnless(segs[2].tag=='bom', 157 'FAILED!') 158 self.failUnless(segs[3].tag=='', 159 'FAILED!') 160 161 self.failUnless(m.geo_reference.get_zone()==zone, 162 'FAILED!') 163 self.failUnless(m.geo_reference.get_xllcorner()==min_x, 164 'FAILED!') 165 self.failUnless(m.geo_reference.get_yllcorner()==min_y, 166 'FAILED!') 167 168 169 def test_create_mesh_from_regions3(self): 170 171 # These are the absolute values 172 min_x = 10 173 min_y = 88 174 polygon = [[min_x,min_y],[1000,100],[1000,1000],[100,1000]] 175 176 177 x_p = -10 178 y_p = -40 179 geo_ref_poly = Geo_reference(56, x_p, y_p) 180 181 boundary_tags = {'walls':[0,1],'bom':[2]} 182 183 inner1_polygon_absolute = [[10,10],[20,10],[20,20],[10,20]] 184 inner1_polygon = geo_ref_poly. \ 185 change_points_geo_ref(inner1_polygon_absolute) 186 187 inner2_polygon_absolute = [[30,30],[40,30],[40,40],[30,40]] 188 inner2_polygon = geo_ref_poly. \ 189 change_points_geo_ref(inner2_polygon_absolute) 190 191 interior_regions = [(inner1_polygon, 5),(inner2_polygon, 0.2)] 192 m = create_mesh_from_regions(polygon, 193 boundary_tags, 194 10000000, 195 interior_regions=interior_regions) 196 197 198 # Test the mesh instance 199 self.failUnless(len(m.regions)==3, 200 'FAILED!') 201 segs = m.getUserSegments() 202 self.failUnless(len(segs)==12, 203 'FAILED!') 204 self.failUnless(len(m.userVertices)==12, 205 'FAILED!') 206 self.failUnless(segs[0].tag=='walls', 207 'FAILED!') 208 self.failUnless(segs[1].tag=='walls', 209 'FAILED!') 210 211 self.failUnless(segs[2].tag=='bom', 212 'FAILED!') 213 self.failUnless(segs[3].tag=='', 214 'FAILED!') 215 216 self.failUnless(m.geo_reference.get_zone()==DEFAULT_ZONE, 217 'FAILED!') 218 self.failUnless(m.geo_reference.get_xllcorner()==min_x, 219 'FAILED!') 220 self.failUnless(m.geo_reference.get_yllcorner()==min_y, 221 'FAILED!') 222 109 223 #------------------------------------------------------------- 110 224 if __name__ == "__main__":
Note: See TracChangeset
for help on using the changeset viewer.