Changeset 6636


Ignore:
Timestamp:
Mar 27, 2009, 9:01:11 AM (16 years ago)
Author:
ole
Message:

Fixed a few unit tests up after having changed the definition of exchange_area in general_forcing

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

Legend:

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

    r6635 r6636  
    17451745
    17461746        # Update area if applicable
    1747         self.exchange_area = None       
    17481747        if center is not None and radius is not None:
    17491748            assert len(center) == 2
     
    18161815           
    18171816           
    1818         if self.exchange_indices is not None:
    1819             #print inlet_region
    1820        
     1817        if self.exchange_indices is None:
     1818            self.exchange_area = polygon_area(bounding_polygon)
     1819        else:   
    18211820            if len(self.exchange_indices) == 0:
    18221821                msg = 'No triangles have been identified in '
     
    18241823                raise Exception, msg
    18251824
    1826 
    1827 
    1828         # Compute exchange area as the sum of areas of triangles identified
    1829         # by circle or polygon
    1830         self.exchange_area = 0.0
    1831         for i in self.exchange_indices:
    1832             self.exchange_area += domain.areas[i]
     1825            # Compute exchange area as the sum of areas of triangles identified
     1826            # by circle or polygon
     1827            self.exchange_area = 0.0
     1828            for i in self.exchange_indices:
     1829                self.exchange_area += domain.areas[i]
    18331830           
    18341831
  • anuga_core/source/anuga/shallow_water/test_shallow_water_domain.py

    r6635 r6636  
    25292529        # Setup only one forcing term, constant rainfall
    25302530        domain.forcing_terms = []
    2531         domain.forcing_terms.append( Rainfall(domain, rate=2.0) )
     2531        domain.forcing_terms.append(Rainfall(domain, rate=2.0))
    25322532
    25332533        domain.compute_forcing_terms()
     
    25672567                     polygon = [[1,1], [2,1], [2,2], [1,2]])
    25682568
    2569         assert num.allclose(R.exchange_area, 1)
     2569        assert num.allclose(R.exchange_area, 2)
    25702570       
    25712571        domain.forcing_terms.append(R)
     
    27342734                     polygon=rainfall_poly)
    27352735
    2736         assert num.allclose(R.exchange_area, 1)
     2736        assert num.allclose(R.exchange_area, 2)
    27372737       
    27382738        domain.forcing_terms.append(R)
     
    28072807                     default_rate=5.0)
    28082808
    2809         assert num.allclose(R.exchange_area, 1)
     2809        assert num.allclose(R.exchange_area, 2)
    28102810       
    28112811        domain.forcing_terms.append(R)
     
    28822882                     default_rate=5.0)
    28832883
    2884         assert num.allclose(R.exchange_area, 1)
     2884        assert num.allclose(R.exchange_area, 2)
    28852885       
    28862886        domain.forcing_terms.append(R)
     
    29232923
    29242924        # Setup only one forcing term, constant inflow of 2 m^3/s on a circle affecting triangles #0 and #1 (bac and bce)
     2925
     2926        I = Inflow(domain, rate=2.0, center=(1,1), radius=1)
    29252927        domain.forcing_terms = []
    2926         domain.forcing_terms.append( Inflow(domain, rate=2.0, center=(1,1), radius=1) )
     2928        domain.forcing_terms.append(I)
    29272929
    29282930        domain.compute_forcing_terms()
    2929         #print domain.quantities['stage'].explicit_update
    2930        
    2931         assert num.allclose(domain.quantities['stage'].explicit_update[1], 2.0/pi)
    2932         assert num.allclose(domain.quantities['stage'].explicit_update[0], 2.0/pi)
     2931       
     2932        ref_dw = 2.0/I.exchange_area
     2933       
     2934        assert num.allclose(domain.quantities['stage'].explicit_update[1], ref_dw)
     2935        assert num.allclose(domain.quantities['stage'].explicit_update[0], ref_dw)
    29332936        assert num.allclose(domain.quantities['stage'].explicit_update[2:], 0)       
    29342937
     
    29612964        # Setup only one forcing term, time dependent inflow of 2 m^3/s on a circle affecting triangles #0 and #1 (bac and bce)
    29622965        domain.forcing_terms = []
    2963         domain.forcing_terms.append( Inflow(domain, rate=lambda t: 2., center=(1,1), radius=1) )
     2966        I = Inflow(domain, rate=lambda t: 2., center=(1,1), radius=1)
     2967        domain.forcing_terms.append(I)
    29642968
    29652969        domain.compute_forcing_terms()
    29662970       
    2967         assert num.allclose(domain.quantities['stage'].explicit_update[1], 2.0/pi)
    2968         assert num.allclose(domain.quantities['stage'].explicit_update[0], 2.0/pi)
     2971        ref_dw = 2.0/I.exchange_area
     2972
     2973        assert num.allclose(domain.quantities['stage'].explicit_update[1], ref_dw)
     2974        assert num.allclose(domain.quantities['stage'].explicit_update[0], ref_dw)
    29692975        assert num.allclose(domain.quantities['stage'].explicit_update[2:], 0)       
    29702976       
     
    68456851       
    68466852if __name__ == "__main__":
    6847     suite = unittest.makeSuite(Test_Shallow_Water, 'test_inflow_using_flowline')
     6853    suite = unittest.makeSuite(Test_Shallow_Water, 'test_time')
    68486854    runner = unittest.TextTestRunner(verbosity=1)   
    68496855    runner.run(suite)
Note: See TracChangeset for help on using the changeset viewer.