Changeset 8387


Ignore:
Timestamp:
Apr 10, 2012, 12:50:53 PM (13 years ago)
Author:
steve
Message:

Fixed up a number of unit test t odeal wiht new combined gravity
and flux calculation.

Location:
trunk/anuga_core/source/anuga/shallow_water
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/anuga_core/source/anuga/shallow_water/test_forcing.py

    r8371 r8387  
    19171917        os.remove(field_sts_filename+'.sww')
    19181918
    1919     def test_gravity(self):
     1919    def test_flux_gravity(self):
    19201920        #Assuming no friction
    19211921
     
    19351935        domain = Domain(points, vertices)
    19361936
     1937        B = Reflective_boundary(domain)
     1938        domain.set_boundary( {'exterior': B})
     1939
     1940
    19371941        #Set up for a gradient of (3,0) at mid triangle (bce)
    19381942        def slope(x, y):
     
    19501954            assert num.allclose(domain.quantities[name].semi_implicit_update, 0)
    19511955
    1952         domain.compute_forcing_terms()
    1953 
    1954 
     1956        # fluxes and gravity term are now combined. To ensure zero flux on boundary
     1957        # need to set reflective boundaries
     1958        domain.update_boundary()
     1959        domain.compute_fluxes()
    19551960
    19561961       
     
    19771982        domain = Domain(points, vertices)
    19781983
     1984        B = Reflective_boundary(domain)
     1985        domain.set_boundary( {'exterior': B})
     1986
    19791987        #Set up for a gradient of (3,0) at mid triangle (bce)
    19801988        def slope(x, y):
     
    19942002            assert num.allclose(domain.quantities[name].semi_implicit_update, 0)
    19952003
     2004
     2005        # Only manning friction in the forcing terms (gravity now combined with flux calc)
    19962006        domain.compute_forcing_terms()
    19972007
    19982008        assert num.allclose(domain.quantities['stage'].explicit_update, 0)
    19992009        assert num.allclose(domain.quantities['xmomentum'].explicit_update,
    2000                             -g*h*3)
     2010                            0)
    20012011        assert num.allclose(domain.quantities['ymomentum'].explicit_update, 0)
    20022012
     
    20522062
    20532063        domain = Domain(points, vertices)
     2064        B = Reflective_boundary(domain)
     2065        domain.set_boundary( {'exterior': B})
    20542066
    20552067        # Use the new function which takes into account the extra
     
    20782090        assert num.allclose(domain.quantities['stage'].explicit_update, 0)
    20792091        assert num.allclose(domain.quantities['xmomentum'].explicit_update,
    2080                             -g*h*3)
     2092                            0)
    20812093        assert num.allclose(domain.quantities['ymomentum'].explicit_update, 0)
    20822094
  • trunk/anuga_core/source/anuga/shallow_water/test_shallow_water_domain.py

    r8386 r8387  
    24502450
    24512451        domain = Domain(points, vertices)
     2452        B = Reflective_boundary(domain)
     2453        domain.set_boundary( {'exterior': B})
    24522454
    24532455        #Set up for a gradient of (3,0) at mid triangle (bce)
     
    24722474        assert num.allclose(domain.quantities['stage'].explicit_update, 0)
    24732475        assert num.allclose(domain.quantities['xmomentum'].explicit_update,
    2474                             -g*h*3)
     2476                            0)
    24752477        assert num.allclose(domain.quantities['ymomentum'].explicit_update, 0)
    24762478
     
    25272529
    25282530        domain = Domain(points, vertices)
     2531        B = Reflective_boundary(domain)
     2532        domain.set_boundary( {'exterior': B})
    25292533
    25302534        # Use the flat function which doesn't takes into account the extra
     
    25532557        assert num.allclose(domain.quantities['stage'].explicit_update, 0)
    25542558        assert num.allclose(domain.quantities['xmomentum'].explicit_update,
    2555                             -g*h*3)
     2559                            0)
    25562560        assert num.allclose(domain.quantities['ymomentum'].explicit_update, 0)
    25572561
     
    26072611
    26082612        domain = Domain(points, vertices)
     2613        B = Reflective_boundary(domain)
     2614        domain.set_boundary( {'exterior': B})
    26092615
    26102616        # Use the sloped function which takes into account the extra
     
    26332639        assert num.allclose(domain.quantities['stage'].explicit_update, 0)
    26342640        assert num.allclose(domain.quantities['xmomentum'].explicit_update,
    2635                             -g*h*3)
     2641                            0)
    26362642        assert num.allclose(domain.quantities['ymomentum'].explicit_update, 0)
    26372643
     
    75707576
    75717577
    7572         try:
    7573             domain.update_centroids_of_velocities_and_height()
    7574         except AssertionError:
    7575             pass
    7576         else:
    7577             raise Exception('should have caught H<0 error')
     7578#        try:
     7579#            domain.update_centroids_of_velocities_and_height()
     7580#        except AssertionError:
     7581#            pass
     7582#        else:
     7583#            raise Exception('should have caught H<0 error')
    75787584
    75797585        domain.set_quantity('stage',expression='elevation + 2*x')
     
    76517657if __name__ == "__main__":
    76527658    #suite = unittest.makeSuite(Test_Shallow_Water, 'test_rainfall_forcing_with_evolve')
    7653     suite = unittest.makeSuite(Test_Shallow_Water, 'test_well')
     7659    suite = unittest.makeSuite(Test_Shallow_Water, 'test')
    76547660    runner = unittest.TextTestRunner(verbosity=1)
    76557661    runner.run(suite)
Note: See TracChangeset for help on using the changeset viewer.