Ignore:
Timestamp:
Apr 21, 2008, 5:21:26 PM (16 years ago)
Author:
ole
Message:

Work done during Water Down Under 2008.
Started algorithm for flow through a cross section as per ticket:175 (test disabled).

File:
1 edited

Legend:

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

    r5189 r5226  
    1919from anuga.utilities.numerical_tools import ensure_numeric
    2020from anuga.coordinate_transforms.redfearn import degminsec2decimal_degrees
     21from anuga.abstract_2d_finite_volumes.util import file_function
    2122
    2223# This is needed to run the tests of local functions
     
    73067307
    73077308
    7308         #Cleanup
     7309        # Cleanup
    73097310        os.remove(swwfile)
     7311
     7312
     7313    def NOtest_get_flow_through_cross_section(self):
     7314        """test_get_flow_through_cross_section(self):
     7315
     7316        Test that the total flow through a cross section can be
     7317        correctly obtained from an sww file.
     7318       
     7319        This test creates a flat bed with a known flow through it and tests
     7320        that the function correctly returns the expected flow.
     7321
     7322        The specifics are
     7323        u = 2 m/s
     7324        h = 1 m
     7325        w = 5 m (width of channel)
     7326
     7327        q = u*h*w = 10 m^3/s
     7328       
     7329        """
     7330
     7331        import time, os
     7332        from Numeric import array, zeros, allclose, Float, concatenate
     7333        from Scientific.IO.NetCDF import NetCDFFile
     7334
     7335        # Setup
     7336        from mesh_factory import rectangular
     7337
     7338        # Create basic mesh (100m x 5m)
     7339        width = 5
     7340        len = 100
     7341        points, vertices, boundary = rectangular(len, width, 100, 5)
     7342
     7343        # Create shallow water domain
     7344        domain = Domain(points, vertices, boundary)
     7345        domain.default_order = 2
     7346        domain.set_minimum_storable_height(0.01)
     7347
     7348        domain.set_name('flowtest')
     7349        swwfile = domain.get_name() + '.sww'
     7350
     7351        domain.set_datadir('.')
     7352        domain.format = 'sww'
     7353        domain.smooth = True
     7354
     7355        h = 1.0
     7356        u = 2.0
     7357        uh = u*h
     7358
     7359        Br = Reflective_boundary(domain)     # Side walls
     7360        Bd = Dirichlet_boundary([h, uh, 0])  # 2 m/s across the 5 m inlet:
     7361
     7362
     7363        #---------- First run without geo referencing
     7364       
     7365        domain.set_quantity('elevation', 0.0)
     7366        domain.set_quantity('stage', h)
     7367        domain.set_quantity('xmomentum', uh)
     7368        domain.set_boundary( {'left': Bd, 'right': Bd, 'top': Br, 'bottom': Br})
     7369
     7370        for t in domain.evolve(yieldstep=1, finaltime = 50):
     7371            pass
     7372
     7373        # Check that momentum is as it should be in the interior
     7374        f = file_function(swwfile,
     7375                          quantities=['stage', 'xmomentum', 'ymomentum'],
     7376                          interpolation_points=[[0,width/2],
     7377                                                [len/2, width/2],
     7378                                                [len, width/2]],
     7379                          verbose=False)
     7380
     7381        for t in range(50):
     7382            for i in range(3):
     7383                assert allclose(f(t, i), [1, 2, 0])
     7384           
     7385
     7386
     7387        # Check flow through the middle
     7388        cross_section = [[len/2,0], [len/2,width]]
     7389        Q = get_flow_through_cross_section(swwfile,
     7390                                           cross_section,
     7391                                           verbose=True)
     7392
     7393        assert allclose(Q, uh*width) 
     7394                                     
     7395
     7396
     7397
     7398
     7399       
    73107400       
    73117401    def test_get_all_swwfiles(self):
     
    74177507#    suite = unittest.makeSuite(Test_Data_Manager,'test_screen_catcher')
    74187508    suite = unittest.makeSuite(Test_Data_Manager,'test')
    7419     #suite = unittest.makeSuite(Test_Data_Manager,'test_urs_ungridded_holeII')
     7509    #suite = unittest.makeSuite(Test_Data_Manager,'test_get_flow_through_cross_section')
    74207510    #suite = unittest.makeSuite(Test_Data_Manager,'test_urs_ungridded_holeII')
    74217511
Note: See TracChangeset for help on using the changeset viewer.