Changeset 546 for inundation/ga/storm_surge/pyvolution/test_domain.py
- Timestamp:
- Nov 16, 2004, 10:40:37 AM (20 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
inundation/ga/storm_surge/pyvolution/test_domain.py
r486 r546 12 12 if tag == "mound": 13 13 domain.test = "Mound" 14 15 16 14 15 16 def set_bottom_friction(tag, elements, domain): 17 if tag == "bottom": 18 #print 'bottom - indexes',elements 19 domain.set_quantity('friction', 0.09, indexes = elements) 20 21 def set_top_friction(tag, elements, domain): 22 if tag == "top": 23 #print 'top - indexes',elements 24 domain.set_quantity('friction', 1., indexes = elements) 25 26 27 def set_all_friction(tag, elements, domain): 28 if tag == "all": 29 new_values = domain.get_quantity('friction', indexes = elements) + 10.0 30 31 domain.set_quantity('friction', new_values, indexes = elements) 32 33 17 34 class TestCase(unittest.TestCase): 18 35 def setUp(self): … … 276 293 277 294 278 def test z_set_region(self):295 def test_set_region(self): 279 296 """Set quantities for sub region 280 297 """ … … 330 347 'set region failed') 331 348 349 350 351 def test_region_tags(self): 352 """ 353 get values based on triangle lists. 354 """ 355 from mesh_factory import rectangular 356 from shallow_water import Domain 357 from Numeric import zeros, Float 358 359 #Create basic mesh 360 points, vertices, boundary = rectangular(1, 3) 361 362 #Create shallow water domain 363 domain = Domain(points, vertices, boundary) 364 domain.build_tagged_elements_dictionary({'bottom':[0,1], 365 'top':[4,5], 366 'all':[0,1,2,3,4,5]}) 367 368 369 #Set friction 370 manning = 0.07 371 domain.set_quantity('friction', manning) 372 373 domain.set_region([set_bottom_friction, set_top_friction]) 374 #print domain.quantities['friction'].get_values() 375 assert allclose(domain.quantities['friction'].get_values(), [[ 0.09, 0.09, 0.09], 376 [ 0.09, 0.09, 0.09], 377 [ 0.07, 0.07, 0.07], 378 [ 0.07, 0.07, 0.07], 379 [ 1.0, 1.0, 1.0], 380 [ 1.0, 1.0, 1.0]]) 381 382 domain.set_region([set_all_friction]) 383 #print domain.quantities['friction'].get_values() 384 assert allclose(domain.quantities['friction'].get_values(), 385 [[ 10.09, 10.09, 10.09], 386 [ 10.09, 10.09, 10.09], 387 [ 10.07, 10.07, 10.07], 388 [ 10.07, 10.07, 10.07], 389 [ 11.0, 11.0, 11.0], 390 [ 11.0, 11.0, 11.0]]) 332 391 #------------------------------------------------------------- 333 392 if __name__ == "__main__":
Note: See TracChangeset
for help on using the changeset viewer.