Changeset 1015


Ignore:
Timestamp:
Mar 5, 2005, 6:55:36 PM (20 years ago)
Author:
ole
Message:

Further testing of limiters and conservation

Location:
inundation/ga/storm_surge/pyvolution
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • inundation/ga/storm_surge/pyvolution/shallow_water.py

    r1007 r1015  
    526526        else:
    527527            raise 'Unknown order'
    528 
     528       
    529529    #Take bed elevation into account when water heights are small
    530530    balance_deep_and_shallow(domain)
     
    567567    """
    568568   
     569    #FIXME: Look here for error
     570   
    569571    #Shortcuts
    570572    wc = domain.quantities['stage'].centroid_values
     
    574576    hc = wc - zc  #Water depths at centroids   
    575577
     578    #print zc
     579    #print '1', wc     
    576580    #Update
    577581    for k in range(domain.number_of_elements):
     
    584588            xmomc[k] = ymomc[k] = 0.0
    585589       
     590    #print '2', wc             
    586591
    587592
  • inundation/ga/storm_surge/pyvolution/test_shallow_water.py

    r1014 r1015  
    16241624            #print xmom
    16251625            #assert allclose (xmom, initial_xmom)
    1626        
    1627        
     1626
     1627           
    16281628    def test_conservation_3(self):
    16291629        """Test that stage is conserved globally
    16301630       
    1631         This one uses a convoluted bed, reflective bdries and a suitable
     1631        This one uses a larger grid, convoluted bed, reflective bdries and a suitable
    16321632        initial condition
    16331633        """
     
    16381638
    16391639        #Create basic mesh
    1640         points, vertices, boundary = rectangular(6, 6)
     1640        points, vertices, boundary = rectangular(2, 1)
    16411641
    16421642        #Create shallow water domain
    16431643        domain = Domain(points, vertices, boundary)
    16441644        domain.smooth = False
    1645         domain.default_order=1  #FIXME: 2 will fail
     1645        domain.default_order=2
    16461646        domain.beta_h = 0
    16471647
     
    16551655                    z[i] = -0.5
    16561656                if 0.5 <= x[i] < 0.7: 
    1657                     z[i] = 0.4       
    1658                     #z[i] = 0.7                     
     1657                    z[i] = 0.39                     
    16591658                if 0.7 <= x[i]: 
    16601659                    z[i] = x[i]/3                   
     
    16781677        initial_xmom = domain.quantities['xmomentum'].get_integral()     
    16791678       
     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       
    16801755       
    16811756        #Let surface settle according to limiter
     
    16841759        #needs to respect the law of the limiters?
    16851760        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                               
    16861771        initial_volume = domain.quantities['stage'].get_integral()         
    16871772               
     
    29503035if __name__ == "__main__":
    29513036    suite = unittest.makeSuite(TestCase,'test')
    2952     #suite = unittest.makeSuite(TestCase,'test_balance_deep_and_shallow')
    29533037    runner = unittest.TextTestRunner()
    29543038    runner.run(suite)
Note: See TracChangeset for help on using the changeset viewer.