Changeset 1015
- Timestamp:
- Mar 5, 2005, 6:55:36 PM (20 years ago)
- Location:
- inundation/ga/storm_surge/pyvolution
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
inundation/ga/storm_surge/pyvolution/shallow_water.py
r1007 r1015 526 526 else: 527 527 raise 'Unknown order' 528 528 529 529 #Take bed elevation into account when water heights are small 530 530 balance_deep_and_shallow(domain) … … 567 567 """ 568 568 569 #FIXME: Look here for error 570 569 571 #Shortcuts 570 572 wc = domain.quantities['stage'].centroid_values … … 574 576 hc = wc - zc #Water depths at centroids 575 577 578 #print zc 579 #print '1', wc 576 580 #Update 577 581 for k in range(domain.number_of_elements): … … 584 588 xmomc[k] = ymomc[k] = 0.0 585 589 590 #print '2', wc 586 591 587 592 -
inundation/ga/storm_surge/pyvolution/test_shallow_water.py
r1014 r1015 1624 1624 #print xmom 1625 1625 #assert allclose (xmom, initial_xmom) 1626 1627 1626 1627 1628 1628 def test_conservation_3(self): 1629 1629 """Test that stage is conserved globally 1630 1630 1631 This one uses a convoluted bed, reflective bdries and a suitable1631 This one uses a larger grid, convoluted bed, reflective bdries and a suitable 1632 1632 initial condition 1633 1633 """ … … 1638 1638 1639 1639 #Create basic mesh 1640 points, vertices, boundary = rectangular( 6, 6)1640 points, vertices, boundary = rectangular(2, 1) 1641 1641 1642 1642 #Create shallow water domain 1643 1643 domain = Domain(points, vertices, boundary) 1644 1644 domain.smooth = False 1645 domain.default_order= 1 #FIXME: 2 will fail1645 domain.default_order=2 1646 1646 domain.beta_h = 0 1647 1647 … … 1655 1655 z[i] = -0.5 1656 1656 if 0.5 <= x[i] < 0.7: 1657 z[i] = 0.4 1658 #z[i] = 0.7 1657 z[i] = 0.39 1659 1658 if 0.7 <= x[i]: 1660 1659 z[i] = x[i]/3 … … 1678 1677 initial_xmom = domain.quantities['xmomentum'].get_integral() 1679 1678 1679 import copy 1680 ref_centroid_values =\ 1681 copy.copy(domain.quantities['stage'].centroid_values) 1682 1683 #print 'ORG', domain.quantities['stage'].centroid_values 1684 domain.distribute_to_vertices_and_edges() 1685 1686 1687 #print domain.quantities['stage'].centroid_values 1688 assert allclose(domain.quantities['stage'].centroid_values, 1689 ref_centroid_values) 1690 1691 1692 #Check that initial limiter doesn't violate cons quan 1693 assert allclose (domain.quantities['stage'].get_integral(), 1694 initial_volume) 1695 1696 #Evolution 1697 for t in domain.evolve(yieldstep = 0.05, finaltime = 5): 1698 volume = domain.quantities['stage'].get_integral() 1699 #print t, volume, initial_volume 1700 assert allclose (volume, initial_volume) 1701 1702 1703 def test_conservation_4(self): 1704 """Test that stage is conserved globally 1705 1706 This one uses a larger grid, convoluted bed, reflective bdries and a suitable 1707 initial condition 1708 """ 1709 from mesh_factory import rectangular 1710 from shallow_water import Domain, Reflective_boundary,\ 1711 Dirichlet_boundary, Constant_height 1712 from Numeric import array 1713 1714 #Create basic mesh 1715 points, vertices, boundary = rectangular(6, 6) 1716 1717 #Create shallow water domain 1718 domain = Domain(points, vertices, boundary) 1719 domain.smooth = False 1720 domain.default_order=2 1721 domain.beta_h = 0.0 1722 1723 #IC 1724 def x_slope(x, y): 1725 z = 0*x 1726 for i in range(len(x)): 1727 if x[i] < 0.3: 1728 z[i] = x[i]/3 1729 if 0.3 <= x[i] < 0.5: 1730 z[i] = -0.5 1731 if 0.5 <= x[i] < 0.7: 1732 z[i] = 0.34 #OK 1733 #z[i] = 0.35 #Fails 1734 if 0.7 <= x[i]: 1735 z[i] = x[i]/3 1736 return z 1737 1738 1739 1740 domain.set_quantity('elevation', x_slope) 1741 domain.set_quantity('friction', 0) 1742 domain.set_quantity('stage', 0.4) #Steady 1743 1744 # Boundary conditions (reflective everywhere) 1745 Br = Reflective_boundary(domain) 1746 domain.set_boundary({'left': Br, 'right': Br, 'top': Br, 'bottom': Br}) 1747 1748 domain.check_integrity() 1749 1750 #domain.visualise = True #If you want to take a sticky beak 1751 1752 initial_volume = domain.quantities['stage'].get_integral() 1753 initial_xmom = domain.quantities['xmomentum'].get_integral() 1754 1680 1755 1681 1756 #Let surface settle according to limiter … … 1684 1759 #needs to respect the law of the limiters? 1685 1760 domain.distribute_to_vertices_and_edges() 1761 1762 1763 #FIXME: At this point study the centroid of individual triangles. 1764 1765 #Check that initial limiter doesn't violate cons quan 1766 assert allclose (domain.quantities['stage'].get_integral(), 1767 initial_volume) 1768 1769 1770 1686 1771 initial_volume = domain.quantities['stage'].get_integral() 1687 1772 … … 2950 3035 if __name__ == "__main__": 2951 3036 suite = unittest.makeSuite(TestCase,'test') 2952 #suite = unittest.makeSuite(TestCase,'test_balance_deep_and_shallow')2953 3037 runner = unittest.TextTestRunner() 2954 3038 runner.run(suite)
Note: See TracChangeset
for help on using the changeset viewer.