Changeset 6636
- Timestamp:
- Mar 27, 2009, 9:01:11 AM (16 years ago)
- 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 1745 1745 1746 1746 # Update area if applicable 1747 self.exchange_area = None1748 1747 if center is not None and radius is not None: 1749 1748 assert len(center) == 2 … … 1816 1815 1817 1816 1818 if self.exchange_indices is notNone:1819 #print inlet_region1820 1817 if self.exchange_indices is None: 1818 self.exchange_area = polygon_area(bounding_polygon) 1819 else: 1821 1820 if len(self.exchange_indices) == 0: 1822 1821 msg = 'No triangles have been identified in ' … … 1824 1823 raise Exception, msg 1825 1824 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] 1833 1830 1834 1831 -
anuga_core/source/anuga/shallow_water/test_shallow_water_domain.py
r6635 r6636 2529 2529 # Setup only one forcing term, constant rainfall 2530 2530 domain.forcing_terms = [] 2531 domain.forcing_terms.append( Rainfall(domain, rate=2.0))2531 domain.forcing_terms.append(Rainfall(domain, rate=2.0)) 2532 2532 2533 2533 domain.compute_forcing_terms() … … 2567 2567 polygon = [[1,1], [2,1], [2,2], [1,2]]) 2568 2568 2569 assert num.allclose(R.exchange_area, 1)2569 assert num.allclose(R.exchange_area, 2) 2570 2570 2571 2571 domain.forcing_terms.append(R) … … 2734 2734 polygon=rainfall_poly) 2735 2735 2736 assert num.allclose(R.exchange_area, 1)2736 assert num.allclose(R.exchange_area, 2) 2737 2737 2738 2738 domain.forcing_terms.append(R) … … 2807 2807 default_rate=5.0) 2808 2808 2809 assert num.allclose(R.exchange_area, 1)2809 assert num.allclose(R.exchange_area, 2) 2810 2810 2811 2811 domain.forcing_terms.append(R) … … 2882 2882 default_rate=5.0) 2883 2883 2884 assert num.allclose(R.exchange_area, 1)2884 assert num.allclose(R.exchange_area, 2) 2885 2885 2886 2886 domain.forcing_terms.append(R) … … 2923 2923 2924 2924 # 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) 2925 2927 domain.forcing_terms = [] 2926 domain.forcing_terms.append( Inflow(domain, rate=2.0, center=(1,1), radius=1))2928 domain.forcing_terms.append(I) 2927 2929 2928 2930 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) 2933 2936 assert num.allclose(domain.quantities['stage'].explicit_update[2:], 0) 2934 2937 … … 2961 2964 # Setup only one forcing term, time dependent inflow of 2 m^3/s on a circle affecting triangles #0 and #1 (bac and bce) 2962 2965 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) 2964 2968 2965 2969 domain.compute_forcing_terms() 2966 2970 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) 2969 2975 assert num.allclose(domain.quantities['stage'].explicit_update[2:], 0) 2970 2976 … … 6845 6851 6846 6852 if __name__ == "__main__": 6847 suite = unittest.makeSuite(Test_Shallow_Water, 'test_ inflow_using_flowline')6853 suite = unittest.makeSuite(Test_Shallow_Water, 'test_time') 6848 6854 runner = unittest.TextTestRunner(verbosity=1) 6849 6855 runner.run(suite)
Note: See TracChangeset
for help on using the changeset viewer.