Ignore:
Timestamp:
Jun 22, 2010, 5:30:32 PM (13 years ago)
Author:
steve
Message:

Added in some more c based limiters

File:
1 edited

Legend:

Unmodified
Added
Removed
  • anuga_work/development/2010-projects/anuga_1d/base/test_quantity_1d.py

    r7860 r7868  
    376376
    377377        assert allclose(a, [ 3., 1., 0.5, 3., 3.5, 0.5])
    378        
     378
     379        quantity.beta = 2.0
     380        quantity.limiter = "minmod_kurganov"
    379381        quantity.extrapolate_second_order()
    380382
     
    405407
    406408        #Work out the others
    407 
     409        quantity.beta = 2.0
     410        quantity.limiter = "minmod_kurganov"
    408411        quantity.extrapolate_second_order()
    409412       
     
    496499
    497500
     501
     502
     503    def test_limit_minmod(self):
     504        quantity = Quantity(self.domain4)
     505
     506        #Create a deliberate overshoot (e.g. from gradient computation)
     507        quantity.set_values([[0,0], [2,10], [9,13], [12,14]])
     508
     509        #Limit
     510        quantity.limiter = 'minmod'
     511        quantity.limit_range()
     512
     513
     514
     515
     516        assert allclose(quantity.vertex_values, [[ -2.4,   2.4],
     517                                                 [  2.4,   9.6],
     518                                                 [ 10.6,  11.4],
     519                                                 [ 11.4,  14.6]] )
     520
     521        from anuga_1d.base.quantity_ext import limit_minmod_ext
     522
     523        quantity.set_values([[0,0], [2,10], [9,13], [12,14]])
     524
     525        limit_minmod_ext(quantity)
     526
     527
     528
     529
     530        assert allclose(quantity.vertex_values, [[ -2.4,   2.4],
     531                                                 [  2.4,   9.6],
     532                                                 [ 10.6,  11.4],
     533                                                 [ 11.4,  14.6]] )
     534
     535
     536
     537    def test_limit_minmod_kurganov(self):
     538        quantity = Quantity(self.domain4)
     539
     540        #Create a deliberate overshoot (e.g. from gradient computation)
     541        quantity.set_values([[0,0], [2,10], [9,13], [12,14]])
     542
     543        #Limit
     544        quantity.limiter = 'minmod_kurganov'
     545        quantity.beta = 0.5
     546        quantity.limit_range()
     547
     548
     549        #print quantity.vertex_values
     550
     551        assert allclose(quantity.vertex_values, [[ -2.4,   2.4],
     552                                                 [  4.2,   7.8],
     553                                                 [ 10.8,  11.2],
     554                                                 [ 11.4,  14.6]])
     555
     556        from anuga_1d.base.quantity_ext import limit_minmod_kurganov_ext
     557
     558        quantity.set_values([[0,0], [2,10], [9,13], [12,14]])
     559
     560        limit_minmod_kurganov_ext(quantity)
     561
     562
     563        #print quantity.vertex_values
     564
     565
     566    def test_limit_vanleer(self):
     567        quantity = Quantity(self.domain4)
     568
     569        #Create a deliberate overshoot (e.g. from gradient computation)
     570        quantity.set_values([[0,0], [2,10], [9,13], [12,14]])
     571
     572        #Limit
     573        quantity.set_limiter('vanleer')
     574        quantity.limit_range()
     575
     576
     577        #print quantity.vertex_values
     578
     579        assert allclose(quantity.vertex_values, [[ -2.4,          2.4       ],
     580                                                 [  2.32653061,   9.67346939],
     581                                                 [ 10.39393939,  11.60606061],
     582                                                 [ 11.4,         14.6       ]] )
     583
     584        from anuga_1d.base.quantity_ext import limit_vanleer_ext
     585
     586        quantity.set_values([[0,0], [2,10], [9,13], [12,14]])
     587
     588        limit_vanleer_ext(quantity)
     589
     590
     591        #print quantity.vertex_values
     592
     593        assert allclose(quantity.vertex_values, [[ -2.4,          2.4       ],
     594                                                 [  2.32653061,   9.67346939],
     595                                                 [ 10.39393939,  11.60606061],
     596                                                 [ 11.4,         14.6       ]] )
     597#
    498598
    499599    def test_find_qmax_qmin(self):
     
    542642
    543643        #Extrapolate
     644        quantity.beta = 2.0
     645        quantity.limiter = "minmod_kurganov"
    544646        quantity.extrapolate_second_order()
    545647
Note: See TracChangeset for help on using the changeset viewer.