Changeset 1016
- Timestamp:
- Mar 6, 2005, 4:18:34 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
r1015 r1016 830 830 wv = domain.quantities['stage'].vertex_values 831 831 zv = domain.quantities['elevation'].vertex_values 832 hv = wv -zv832 hv = wv - zv 833 833 834 834 #Momentums at centroids … … 842 842 #Limit h 843 843 hvbar = h_limiter(domain) 844 845 #This is how one would make a first order h_limited value 846 #as in the old balancer (pre 17 Feb 2005): 847 #from Numeric import zeros, Float 848 #hvbar = zeros( (len(hc), 3), Float) 849 #for i in range(3): 850 # hvbar[:,i] = hc[:] 844 851 845 852 from shallow_water_ext import balance_deep_and_shallow 846 #balance_deep_and_shallow(wc, zc, hc, wv, zv, hv,847 # xmomc, ymomc, xmomv, ymomv)848 849 853 balance_deep_and_shallow(wc, zc, hc, wv, zv, hv, hvbar, 850 854 xmomc, ymomc, xmomv, ymomv) -
inundation/ga/storm_surge/pyvolution/test_shallow_water.py
r1015 r1016 1644 1644 domain.smooth = False 1645 1645 domain.default_order=2 1646 domain.beta_h = 0 1646 domain.beta_h = 0.2 1647 1647 1648 1648 #IC … … 1695 1695 1696 1696 #Evolution 1697 for t in domain.evolve(yieldstep = 0.05, finaltime = 5):1697 for t in domain.evolve(yieldstep = 0.05, finaltime = 10): 1698 1698 volume = domain.quantities['stage'].get_integral() 1699 1699 #print t, volume, initial_volume … … 1729 1729 if 0.3 <= x[i] < 0.5: 1730 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 1731 if 0.5 <= x[i] < 0.7: 1732 #z[i] = 0.3 #OK with beta == 0.2 1733 z[i] = 0.34 #OK with beta == 0.0 1734 #z[i] = 0.35#Fails after 80 timesteps with an error 1735 #of the order 1.0e-5 1734 1736 if 0.7 <= x[i]: 1735 1737 z[i] = x[i]/3 … … 1753 1755 initial_xmom = domain.quantities['xmomentum'].get_integral() 1754 1756 1755 1756 #Let surface settle according to limiter1757 #FIXME: What exactly is the significance of this?1758 #Is it a problem that an arbitrary initial condition1759 # needs to respect the law of the limiters?1757 import copy 1758 ref_centroid_values =\ 1759 copy.copy(domain.quantities['stage'].centroid_values) 1760 1761 #Test limiter by itself 1760 1762 domain.distribute_to_vertices_and_edges() 1761 1762 1763 #FIXME: At this point study the centroid of individual triangles.1764 1763 1765 1764 #Check that initial limiter doesn't violate cons quan 1766 1765 assert allclose (domain.quantities['stage'].get_integral(), 1767 1766 initial_volume) 1768 1767 #NOTE: This would fail if any initial stage was less than the 1768 #corresponding bed elevation - but that is reasonable. 1769 1769 1770 1771 initial_volume = domain.quantities['stage'].get_integral()1772 1770 1773 #print initial_volume1774 1775 #print initial_xmom1776 1777 1771 #Evolution 1778 1772 for t in domain.evolve(yieldstep = 0.05, finaltime = 10.0): 1779 1773 volume = domain.quantities['stage'].get_integral() 1774 1780 1775 #print t, volume, initial_volume 1776 1781 1777 1778 #if not allclose (volume, initial_volume): 1779 # print 't==4.05' 1780 # for k in range(domain.number_of_elements): 1781 # pass 1782 # print domain.quantities['stage'].centroid_values[k] -\ 1783 # ref_centroid_values[k] 1784 1782 1785 assert allclose (volume, initial_volume) 1783 1784 #FIXME: What would we expect from momentum 1785 #xmom = domain.quantities['xmomentum'].get_integral() 1786 #print xmom 1787 #assert allclose (xmom, initial_xmom) 1788 1789 1786 1787 1788 1789 1790 1791 def test_conservation_5(self): 1792 """Test that momentum is conserved globally in 1793 steady state scenario 1794 1795 This one uses a slopy bed, dirichlet and reflective bdries 1796 """ 1797 from mesh_factory import rectangular 1798 from shallow_water import Domain, Reflective_boundary,\ 1799 Dirichlet_boundary, Constant_height 1800 from Numeric import array 1801 1802 #Create basic mesh 1803 points, vertices, boundary = rectangular(6, 6) 1804 1805 #Create shallow water domain 1806 domain = Domain(points, vertices, boundary) 1807 domain.smooth = False 1808 domain.default_order=2 1809 1810 #IC 1811 def x_slope(x, y): 1812 return x/3 1813 1814 domain.set_quantity('elevation', x_slope) 1815 domain.set_quantity('friction', 0) 1816 domain.set_quantity('stage', 0.4) #Steady 1817 1818 # Boundary conditions (reflective everywhere) 1819 Br = Reflective_boundary(domain) 1820 Bleft = Dirichlet_boundary([0.5,0,0]) 1821 Bright = Dirichlet_boundary([0.1,0,0]) 1822 domain.set_boundary({'left': Bleft, 'right': Bright, 1823 'top': Br, 'bottom': Br}) 1824 1825 domain.check_integrity() 1826 1827 #domain.visualise = True #If you want to take a sticky beak 1828 1829 initial_volume = domain.quantities['stage'].get_integral() 1830 initial_xmom = domain.quantities['xmomentum'].get_integral() 1831 1832 1833 #Evolution 1834 for t in domain.evolve(yieldstep = 0.05, finaltime = 15.0): 1835 stage = domain.quantities['stage'].get_integral() 1836 xmom = domain.quantities['xmomentum'].get_integral() 1837 ymom = domain.quantities['ymomentum'].get_integral() 1838 1839 if allclose(t, 6): #Steady state reached 1840 steady_xmom = domain.quantities['xmomentum'].get_integral() 1841 steady_ymom = domain.quantities['ymomentum'].get_integral() 1842 steady_stage = domain.quantities['stage'].get_integral() 1843 1844 if t > 6: 1845 #print '%.2f %14.8f %14.8f' %(t, ymom, steady_ymom) 1846 assert allclose(xmom, steady_xmom) 1847 assert allclose(ymom, steady_ymom) 1848 assert allclose(stage, steady_stage) 1849 1850 1851 1790 1852 1791 1853 def test_second_order_flat_bed_onestep(self):
Note: See TracChangeset
for help on using the changeset viewer.