Changeset 6653


Ignore:
Timestamp:
Mar 28, 2009, 1:26:15 PM (15 years ago)
Author:
ole
Message:

Started work on volumetric check as per ticket:324 - then visitors arrived.
Will try to continue later.

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  
    796796        # Run through boundary array and compute for each segment
    797797        # 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.
    799799        # 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 integral
     800        # record into forcing_inflow and forcing_outflow. Finally compute integral
    801801        # of depth to obtain total volume of domain.
    802802                       
    803803                       
    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       
    806822               
    807823               
  • anuga_core/source/anuga/shallow_water/test_shallow_water_domain.py

    r6652 r6653  
    67346734        else:
    67356735            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                               
    67376823       
    67386824    def Xtest_inflow_using_flowline(self):
     
    68766962       
    68776963       
    6878     def Xtest_friction_dependent_flow_using_flowline(self):
     6964    def test_friction_dependent_flow_using_flowline(self):
    68796965        """test_friction_dependent_flow_using_flowline
    68806966       
     
    70117097                    if verbose:
    70127098                        print 'Depth: ANUGA = %f, Mannings = %f' % (domain_depth, normal_depth)                   
    7013        
     7099
     7100                       
     7101                       
     7102                               
    70147103if __name__ == "__main__":
    70157104    #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
    70177108    runner = unittest.TextTestRunner(verbosity=1)   
    70187109    runner.run(suite)
Note: See TracChangeset for help on using the changeset viewer.