Changeset 4684


Ignore:
Timestamp:
Aug 27, 2007, 6:22:59 PM (17 years ago)
Author:
ole
Message:

Flux test

File:
1 edited

Legend:

Unmodified
Added
Removed
  • anuga_core/source/anuga/shallow_water/test_shallow_water_domain.py

    r4677 r4684  
    191191        assert allclose(max_speed, 1.31414103233)
    192192
     193    def test_flux_computation(self):   
     194        """test_flux_computation - test flux calculation (actual C implementation)
     195        This one tests the constant case where only the pressure term contributes to each edge and cancels out
     196        once the total flux has been summed up.
     197        """
     198               
     199        a = [0.0, 0.0]
     200        b = [0.0, 2.0]
     201        c = [2.0,0.0]
     202        d = [0.0, 4.0]
     203        e = [2.0, 2.0]
     204        f = [4.0,0.0]
     205
     206        points = [a, b, c, d, e, f]
     207        #bac, bce, ecf, dbe, daf, dae
     208        vertices = [ [1,0,2], [1,2,4], [4,2,5], [3,1,4]]
     209
     210        domain = Domain(points, vertices)
     211        domain.check_integrity()
     212
     213        # The constant case             
     214        domain.set_quantity('elevation', -1)
     215        domain.set_quantity('stage', 1)
     216       
     217        domain.compute_fluxes()
     218        assert allclose(domain.get_quantity('stage').explicit_update[1], 0) # Central triangle
     219       
     220
     221        # The more general case                 
     222        def surface(x,y):
     223            return -x/2                   
     224       
     225        domain.set_quantity('elevation', -10)
     226        domain.set_quantity('stage', surface)   
     227        domain.set_quantity('xmomentum', 1)             
     228       
     229        domain.compute_fluxes()
     230       
     231        print domain.get_quantity('stage').explicit_update
     232        # FIXME (Ole): TODO the general case
     233        #assert allclose(domain.get_quantity('stage').explicit_update[1], ........??)
     234               
     235       
     236               
    193237    def test_sw_domain_simple(self):
    194238        a = [0.0, 0.0]
     
    47554799       
    47564800if __name__ == "__main__":
    4757     suite = unittest.makeSuite(Test_Shallow_Water,'test')   
     4801    suite = unittest.makeSuite(Test_Shallow_Water,'test_flux_computation')   
    47584802    #suite = unittest.makeSuite(Test_Shallow_Water,'test_tight_slope_limiters')
    47594803    #suite = unittest.makeSuite(Test_Shallow_Water,'test_get_maximum_inundation_from_sww')
Note: See TracChangeset for help on using the changeset viewer.