- Timestamp:
- Sep 4, 2008, 2:45:27 PM (16 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
anuga_core/source/anuga/shallow_water/test_shallow_water_domain.py
r5450 r5729 1406 1406 1407 1407 1408 1409 def test_get_flow_through_cross_section_with_geo(self): 1410 """test_get_flow_through_cross_section(self): 1411 1412 Test that the total flow through a cross section can be 1413 correctly obtained at run-time from the ANUGA domain. 1414 1415 This test creates a flat bed with a known flow through it and tests 1416 that the function correctly returns the expected flow. 1417 1418 The specifics are 1419 e = -1 m 1420 u = 2 m/s 1421 h = 2 m 1422 w = 3 m (width of channel) 1423 1424 q = u*h*w = 12 m^3/s 1425 1426 1427 This run tries it with georeferencing and with elevation = -1 1428 1429 """ 1430 1431 import time, os 1432 from Numeric import array, zeros, allclose, Float, concatenate 1433 from Scientific.IO.NetCDF import NetCDFFile 1434 1435 # Setup 1436 from mesh_factory import rectangular 1437 1438 # Create basic mesh (20m x 3m) 1439 width = 3 1440 length = 20 1441 t_end = 1 1442 points, vertices, boundary = rectangular(length, width, 1443 length, width) 1444 1445 # Create shallow water domain 1446 domain = Domain(points, vertices, boundary, 1447 geo_reference=Geo_reference(56,308500,6189000)) 1448 1449 domain.default_order = 2 1450 domain.set_quantities_to_be_stored(None) 1451 1452 1453 e = -1.0 1454 w = 1.0 1455 h = w-e 1456 u = 2.0 1457 uh = u*h 1458 1459 Br = Reflective_boundary(domain) # Side walls 1460 Bd = Dirichlet_boundary([w, uh, 0]) # 2 m/s across the 3 m inlet: 1461 1462 1463 # Initial conditions 1464 domain.set_quantity('elevation', e) 1465 domain.set_quantity('stage', w) 1466 domain.set_quantity('xmomentum', uh) 1467 domain.set_boundary( {'left': Bd, 'right': Bd, 'top': Br, 'bottom': Br}) 1468 1469 1470 # Interpolation points down the middle 1471 I = [[0, width/2.], 1472 [length/2., width/2.], 1473 [length, width/2.]] 1474 interpolation_points = domain.geo_reference.get_absolute(I) 1475 1476 # Shortcuts to quantites 1477 stage = domain.get_quantity('stage') 1478 xmomentum = domain.get_quantity('xmomentum') 1479 ymomentum = domain.get_quantity('ymomentum') 1480 1481 for t in domain.evolve(yieldstep=0.1, finaltime = t_end): 1482 # Check that quantities are they should be in the interior 1483 1484 w_t = stage.get_values(interpolation_points) 1485 uh_t = xmomentum.get_values(interpolation_points) 1486 vh_t = ymomentum.get_values(interpolation_points) 1487 1488 assert allclose(w_t, w) 1489 assert allclose(uh_t, uh) 1490 assert allclose(vh_t, 0.0) 1491 1492 1493 # Check flows through the middle 1494 for i in range(5): 1495 x = length/2. + i*0.23674563 # Arbitrary 1496 cross_section = [[x, 0], [x, width]] 1497 1498 cross_section = domain.geo_reference.get_absolute(cross_section) 1499 Q = domain.get_flow_through_cross_section(cross_section, 1500 verbose=False) 1501 1502 assert allclose(Q, uh*width) 1503 1504 1505 1506 1507 1408 1508 1409 1509 def test_another_runup_example(self): … … 1431 1531 domain = Domain(points, vertices, boundary) # Create domain 1432 1532 domain.set_quantities_to_be_stored(None) 1433 domain.set_maximum_allowed_speed(100) # 1533 domain.set_maximum_allowed_speed(100) #FIXME (Ole): try to remove this 1434 1534 1435 1535 # FIXME (Ole): Need tests where this is commented out 1436 domain.tight_slope_limiters = 0 # Backwards compatibility (14/4/7) 1536 domain.tight_slope_limiters = 0 # Backwards compatibility (14/4/7) 1437 1537 domain.H0 = 0 # Backwards compatibility (6/2/7) 1438 1538 domain.use_centroid_velocities = 0 # Backwards compatibility (7/5/8) … … 5805 5905 if __name__ == "__main__": 5806 5906 5807 suite = unittest.makeSuite(Test_Shallow_Water,'test')5808 5809 #suite = unittest.makeSuite(Test_Shallow_Water,'test_bedslope_problem_first_order_moresteps')5907 #suite = unittest.makeSuite(Test_Shallow_Water,'test') 5908 5909 suite = unittest.makeSuite(Test_Shallow_Water,'test_get_flow_through_cross_section_with_geo') 5810 5910 #suite = unittest.makeSuite(Test_Shallow_Water,'test_fitting_using_shallow_water_domain') 5811 5911 #suite = unittest.makeSuite(Test_Shallow_Water,'test_tight_slope_limiters')
Note: See TracChangeset
for help on using the changeset viewer.