Changeset 6653
- Timestamp:
- Mar 28, 2009, 1:26:15 PM (15 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
r6648 r6653 796 796 # Run through boundary array and compute for each segment 797 797 # the normal momentum ((uh, vh) dot normal) times segment length. 798 # Based on sign accumulate this into total_boundary_inflow and total_boundary_outflow.798 # Based on sign accumulate this into boundary_inflow and boundary_outflow. 799 799 # The go through explicit forcing update and record the rate of change for stage and 800 # record into total_forcing_inflow and total_forcing_outflow. Finally compute integral800 # record into forcing_inflow and forcing_outflow. Finally compute integral 801 801 # of depth to obtain total volume of domain. 802 802 803 803 804 805 pass 804 # Compute flows along boundary 805 806 uh = self.get_quantity('xmomentum').get_values() 807 vh = self.get_quantity('ymomentum').get_values() 808 809 # Loop through edges that lie on the boundary and calculate 810 # flows 811 inflow = 0.0 812 outflow = 0.0 813 for vol_id, edge_id in self.boundary: 814 print vol_id, edge_id, self.boundary[(vol_id, edge_id)] 815 816 # Pick edge and compute normal flow 817 print uh[vol_id, :] 818 print vh[vol_id, :] 819 820 821 806 822 807 823 -
anuga_core/source/anuga/shallow_water/test_shallow_water_domain.py
r6652 r6653 6734 6734 else: 6735 6735 os.remove(meshname) 6736 6736 6737 6738 6739 6740 def Xtest_volumetric_balance_computation(self): 6741 """test_volumetric_balance_computation 6742 6743 Test that total in and out flows are computed correctly 6744 """ 6745 6746 verbose = True 6747 6748 6749 #------------------------------------------------------------------------------ 6750 # Import necessary modules 6751 #------------------------------------------------------------------------------ 6752 from anuga.abstract_2d_finite_volumes.mesh_factory import rectangular_cross 6753 from anuga.shallow_water import Domain 6754 from anuga.shallow_water.shallow_water_domain import Reflective_boundary 6755 from anuga.shallow_water.shallow_water_domain import Dirichlet_boundary 6756 from anuga.shallow_water.shallow_water_domain import Inflow 6757 from anuga.shallow_water.data_manager import get_flow_through_cross_section 6758 6759 #------------------------------------------------------------------------------ 6760 # Setup computational domain 6761 #------------------------------------------------------------------------------ 6762 finaltime = 300.0 6763 6764 length = 300. 6765 width = 20. 6766 dx = dy = 5 # Resolution: of grid on both axes 6767 6768 # Input parameters 6769 uh = 1.0 6770 vh = 0.0 6771 d = 1.0 6772 6773 ref_flow = uh*d*width # 20 m^3/s in the x direction across entire domain 6774 6775 points, vertices, boundary = rectangular_cross(int(length/dx), int(width/dy), 6776 len1=length, len2=width) 6777 6778 6779 domain = Domain(points, vertices, boundary) 6780 domain.set_name('Inflow_flowline_test') # Output name 6781 6782 6783 #------------------------------------------------------------------------------ 6784 # Setup initial conditions 6785 #------------------------------------------------------------------------------ 6786 slope = 0.0 6787 def topography(x, y): 6788 z=-x * slope 6789 return z 6790 6791 domain.set_quantity('elevation', topography) # Use function for elevation 6792 domain.set_quantity('friction', 0.0) # Constant friction 6793 6794 domain.set_quantity('stage', 6795 expression='elevation') 6796 6797 #------------------------------------------------------------------------------ 6798 # Setup boundary conditions 6799 #------------------------------------------------------------------------------ 6800 6801 Br = Reflective_boundary(domain) # Solid reflective wall 6802 6803 # Constant flow into domain 6804 # Depth = 1m, uh=1 m/s, i.e. a flow of 20 m^3/s 6805 6806 Bi = Dirichlet_boundary([d, uh, vh]) 6807 Bo = Dirichlet_boundary([0, 0, 0]) 6808 6809 domain.set_boundary({'left': Bi, 'right': Bo, 'top': Br, 'bottom': Br}) 6810 6811 6812 #------------------------------------------------------------------------------ 6813 # Evolve system through time 6814 #------------------------------------------------------------------------------ 6815 for t in domain.evolve(yieldstep=100.0, finaltime=finaltime): 6816 if verbose : 6817 print domain.timestepping_statistics() 6818 6819 print domain.compute_volumetric_balance() 6820 6821 6822 6737 6823 6738 6824 def Xtest_inflow_using_flowline(self): … … 6876 6962 6877 6963 6878 def Xtest_friction_dependent_flow_using_flowline(self):6964 def test_friction_dependent_flow_using_flowline(self): 6879 6965 """test_friction_dependent_flow_using_flowline 6880 6966 … … 7011 7097 if verbose: 7012 7098 print 'Depth: ANUGA = %f, Mannings = %f' % (domain_depth, normal_depth) 7013 7099 7100 7101 7102 7014 7103 if __name__ == "__main__": 7015 7104 #suite = unittest.makeSuite(Test_Shallow_Water, 'test_friction_dependent_flow_using_flowline') 7016 suite = unittest.makeSuite(Test_Shallow_Water, 'test') 7105 #suite = unittest.makeSuite(Test_Shallow_Water, 'test_volumetric_balance_computation') 7106 suite = unittest.makeSuite(Test_Shallow_Water, 'test') 7107 7017 7108 runner = unittest.TextTestRunner(verbosity=1) 7018 7109 runner.run(suite)
Note: See TracChangeset
for help on using the changeset viewer.