def _create_domain(self,d_length,
                            d_width,
                            dx,
                            dy,
                            elevation_0,
                            elevation_1,
                            stage_0,
                            stage_1):
        
        points, vertices, boundary = rectangular_cross(int(d_length/dx), int(d_width/dy),
                                                        len1=d_length, len2=d_width)
        domain = Domain(points, vertices, boundary)   
        domain.set_name('Test_Outlet_Inlet')                 # Output name
        domain.set_store()
        domain.set_default_order(2)
        domain.H0 = 0.01
        domain.tight_slope_limiters = 1

        #print 'Size', len(domain)

        #------------------------------------------------------------------------------
        # Setup initial conditions
        #------------------------------------------------------------------------------

        def elevation(x, y):
            """Set up a elevation
            """
            
            z = numpy.zeros(x.shape,dtype='d')
            z[:] = elevation_0
            
            numpy.putmask(z, x > d_length/2, elevation_1)
    
            return z
            
        def stage(x,y):
            """Set up stage
            """
            z = numpy.zeros(x.shape,dtype='d')
            z[:] = stage_0
            
            numpy.putmask(z, x > d_length/2, stage_1)

            return z
            
        #print 'Setting Quantities....'
        domain.set_quantity('elevation', elevation)  # Use function for elevation
        domain.set_quantity('stage',  stage)   # Use function for elevation

        Br = anuga.Reflective_boundary(domain)
        domain.set_boundary({'left': Br, 'right': Br, 'top': Br, 'bottom': Br})
        
        return domain
Пример #2
0
    def _create_domain(self, d_length, d_width, dx, dy, elevation_0,
                       elevation_1, stage_0, stage_1):

        points, vertices, boundary = rectangular_cross(
            int(old_div(d_length, dx)),
            int(old_div(d_width, dy)),
            len1=d_length,
            len2=d_width)
        domain = Domain(points, vertices, boundary)
        domain.set_name('Test_Outlet_Inlet')  # Output name
        domain.set_store()
        domain.set_default_order(2)
        domain.H0 = 0.01
        domain.tight_slope_limiters = 1

        #print 'Size', len(domain)

        #------------------------------------------------------------------------------
        # Setup initial conditions
        #------------------------------------------------------------------------------

        def elevation(x, y):
            """Set up a elevation
            """

            z = numpy.zeros(x.shape, dtype='d')
            z[:] = elevation_0

            numpy.putmask(z, x > old_div(d_length, 2), elevation_1)

            return z

        def stage(x, y):
            """Set up stage
            """
            z = numpy.zeros(x.shape, dtype='d')
            z[:] = stage_0

            numpy.putmask(z, x > old_div(d_length, 2), stage_1)

            return z

        #print 'Setting Quantities....'
        domain.set_quantity('elevation',
                            elevation)  # Use function for elevation
        domain.set_quantity('stage', stage)  # Use function for elevation

        Br = anuga.Reflective_boundary(domain)
        domain.set_boundary({'left': Br, 'right': Br, 'top': Br, 'bottom': Br})

        return domain
    def _create_domain(self,
                       d_length,
                       d_width,
                       dx,
                       dy,
                       elevation_0,
                       elevation_1,
                       stage_0,
                       stage_1,
                       xvelocity_0=0.0,
                       xvelocity_1=0.0,
                       yvelocity_0=0.0,
                       yvelocity_1=0.0):

        points, vertices, boundary = rectangular_cross(int(d_length / dx),
                                                       int(d_width / dy),
                                                       len1=d_length,
                                                       len2=d_width)
        domain = Domain(points, vertices, boundary)
        domain.set_name('Test_Outlet_Inlet')  # Output name
        domain.set_store()
        domain.set_default_order(2)
        domain.H0 = 0.01
        domain.tight_slope_limiters = 1

        #print 'Size', len(domain)

        #------------------------------------------------------------------------------
        # Setup initial conditions
        #------------------------------------------------------------------------------

        def elevation(x, y):
            """Set up a elevation
            """

            z = numpy.zeros(x.shape, dtype='d')
            z[:] = elevation_0

            numpy.putmask(z, x > d_length / 2, elevation_1)

            return z

        def stage(x, y):
            """Set up stage
            """
            z = numpy.zeros(x.shape, dtype='d')
            z[:] = stage_0

            numpy.putmask(z, x > d_length / 2, stage_1)

            return z

        def xmom(x, y):
            """Set up xmomentum
            """
            z = numpy.zeros(x.shape, dtype='d')
            z[:] = xvelocity_0 * (stage_0 - elevation_0)

            numpy.putmask(z, x > d_length / 2,
                          xvelocity_1 * (stage_1 - elevation_1))

            return z

        def ymom(x, y):
            """Set up ymomentum
            """
            z = numpy.zeros(x.shape, dtype='d')
            z[:] = yvelocity_0 * (stage_0 - elevation_0)

            numpy.putmask(z, x > d_length / 2,
                          yvelocity_1 * (stage_1 - elevation_1))

            return z

        #print 'Setting Quantities....'
        domain.set_quantity('elevation',
                            elevation)  # Use function for elevation
        domain.set_quantity('stage', stage)  # Use function for elevation
        domain.set_quantity('xmomentum', xmom)
        domain.set_quantity('ymomentum', ymom)

        return domain
print 'Setting up domain'

length = 120. #x-Dir
width = 200.  #y-dir

dx = dy = 2.0          # Resolution: Length of subdivisions on both axes
#dx = dy = .5           # Resolution: Length of subdivisions on both axes
#dx = dy = .5           # Resolution: Length of subdivisions on both axes
#dx = dy = .1           # Resolution: Length of subdivisions on both axes

points, vertices, boundary = rectangular_cross(int(length/dx), int(width/dy),
                                                    len1=length, len2=width)
domain = Domain(points, vertices, boundary)   
domain.set_name('Test_Outlet_Ctrl')                 # Output name
domain.set_default_order(2)
domain.H0 = 0.01
domain.tight_slope_limiters = 1

print 'Size', len(domain)

#------------------------------------------------------------------------------
# Setup initial conditions
#------------------------------------------------------------------------------

def topography(x, y):
    """Set up a weir
    
    A culvert will connect either side
    """
    # General Slope of Topography
    z=10.0-x/100.0  # % Longitudinal Slope
    def _create_domain(self,d_length,
                            d_width,
                            dx,
                            dy,
                            elevation_0,
                            elevation_1,
                            stage_0,
                            stage_1,
                            xvelocity_0 = 0.0,
                            xvelocity_1 = 0.0,
                            yvelocity_0 = 0.0,
                            yvelocity_1 = 0.0):
        
        points, vertices, boundary = rectangular_cross(int(d_length/dx), int(d_width/dy),
                                                        len1=d_length, len2=d_width)
        domain = Domain(points, vertices, boundary)   
        domain.set_name('Test_Outlet_Inlet')                 # Output name
        domain.set_store()
        domain.set_default_order(2)
        domain.H0 = 0.01
        domain.tight_slope_limiters = 1

        #print 'Size', len(domain)

        #------------------------------------------------------------------------------
        # Setup initial conditions
        #------------------------------------------------------------------------------

        def elevation(x, y):
            """Set up a elevation
            """
            
            z = numpy.zeros(x.shape,dtype='d')
            z[:] = elevation_0
            
            numpy.putmask(z, x > d_length/2, elevation_1)
    
            return z
            
        def stage(x,y):
            """Set up stage
            """
            z = numpy.zeros(x.shape,dtype='d')
            z[:] = stage_0
            
            numpy.putmask(z, x > d_length/2, stage_1)

            return z
        
        def xmom(x,y):
            """Set up xmomentum
            """
            z = numpy.zeros(x.shape,dtype='d')
            z[:] = xvelocity_0*(stage_0-elevation_0)
            
            numpy.putmask(z, x > d_length/2, xvelocity_1*(stage_1-elevation_1) )

            return z
        
        def ymom(x,y):
            """Set up ymomentum
            """
            z = numpy.zeros(x.shape,dtype='d')
            z[:] = yvelocity_0*(stage_0-elevation_0)
            
            numpy.putmask(z, x > d_length/2, yvelocity_1*(stage_1-elevation_1) )

            return z
            
        #print 'Setting Quantities....'
        domain.set_quantity('elevation', elevation)  # Use function for elevation
        domain.set_quantity('stage',  stage)   # Use function for elevation
        domain.set_quantity('xmomentum',  xmom) 
        domain.set_quantity('ymomentum',  ymom) 
        
        return domain