Exemplo n.º 1
0
def generate_channel3_domain(gpu=True):
    #-----------------------------------------------------------------------
    # Setup computational domain
    #-----------------------------------------------------------------------
    length = 40.
    width = 5.
    dx = dy = .1           # Resolution: Length of subdivisions on both axes
    
    points, vertices, boundary = anuga.rectangular_cross(int(length/dx),
                                        int(width/dy), len1=length, len2=width)
    if gpu:
        domain = GPU_domain(points, vertices, boundary )
        if '-gpu' in sys.argv:
            domain.using_gpu = True
            print " --> Enable GPU version"
        for i in range(len(sys.argv)):
            if sys.argv[i] == '-fs':
                global finaltime
                finaltime = float(sys.argv[i+1])
                print " --> Finaltime is reset as %f" % finaltime

    else:
        domain = anuga.Domain(points, vertices, boundary)
    domain.set_name('channel3')                  # Output name
    #print domain.statistics()
    
    #-----------------------------------------------------------------------
    # Setup initial conditions
    #-----------------------------------------------------------------------
    def topography(x,y):
        """Complex topography defined by a function of vectors x and y."""
    
        z = -x/10
    
        N = len(x)
        for i in range(N):
            # Step
            if 10 < x[i] < 12:
                z[i] += 0.4 - 0.05*y[i]
    
            # Constriction
            if 27 < x[i] < 29 and y[i] > 3:
                z[i] += 2
    
            # Pole
            if (x[i] - 34)**2 + (y[i] - 2)**2 < 0.4**2:
                z[i] += 2
    
        return z
    
    domain.set_quantity('elevation', topography)    # elevation is a function
    domain.set_quantity('friction', 0.01)                  # Constant friction
    domain.set_quantity('stage', expression='elevation') # Dry initial condition
    
    #-----------------------------------------------------------------------
    # Setup boundary conditions
    #-----------------------------------------------------------------------
    Bi = anuga.Dirichlet_boundary([0.4, 0, 0])          # Inflow
    Br = anuga.Reflective_boundary(domain)              # Solid reflective wall
    Bo = anuga.Dirichlet_boundary([-5, 0, 0])           # Outflow
    
    domain.set_boundary({'left': Bi, 'right': Bo, 'top': Br, 'bottom': Br})
    return domain
Exemplo n.º 2
0
def generate_channel1_domain(gpu=True):
    # --------------------------------------------------------------------------
    # Setup computational domain
    # --------------------------------------------------------------------------

    # points, vertices, boundary = anuga.rectangular_cross(10, 1,
    #                                               len1=10.0, len2=5.0) # Mesh
    points, vertices, boundary = anuga.rectangular_cross(1, 4, len1=0.1, len2=0.1)  # Mesh

    if gpu:
        domain = GPU_domain(points, vertices, boundary)  # Create domain
        for i in range(len(sys.argv)):
            if sys.argv[i] == "-gpu":
                domain.using_gpu = True
                print " --> Enable GPU version"
            elif sys.argv[i] == "-fs":
                finaltime = float(sys.argv[i + 1])
                print " --> Finaltime is reset as %f" % finaltime
            elif sys.argv[i] == "-test":
                domain.cotesting = True
                print " --> Enable Cotesting"
            elif sys.argv[i] == "-ustore":
                domain.store = True
                print " --> Disable storing"
    else:
        domain = anuga.Domain(points, vertices, boundary)  # Create domain
    domain.set_name("channel1")  # Output name

    # --------------------------------------------------------------------------
    # Setup initial conditions
    # --------------------------------------------------------------------------
    def topography(x, y):
        return -x / 10  # linear bed slope

    domain.set_quantity("elevation", topography)  # Use function for elevation
    domain.set_quantity("friction", 0.01)  # Constant friction
    domain.set_quantity("stage", expression="elevation")  # Dry bed

    # --------------------------------------------------------------------------
    # Setup boundary conditions
    # --------------------------------------------------------------------------
    Bi = anuga.Dirichlet_boundary([0.4, 0, 0])  # Inflow
    Br = anuga.Reflective_boundary(domain)  # Solid reflective wall

    domain.set_boundary({"left": Bi, "right": Br, "top": Br, "bottom": Br})

    return domain
Exemplo n.º 3
0
def generate_cairns_domain(gpu=False):
    #-----------------------------------------------------------------------
    # Preparation of topographic data
    # Convert ASC 2 DEM 2 PTS using source data
    # and store result in source data
    #-----------------------------------------------------------------------
    # Create DEM from asc data
    anuga.asc2dem(project.name_stem + '.asc', use_cache=True, verbose=True)

    # Create pts file for onshore DEM
    anuga.dem2pts(project.name_stem + '.dem', use_cache=True, verbose=True)

    #-----------------------------------------------------------------------
    # Create the triangular mesh and domain based on
    # overall clipping polygon with a tagged
    # boundary and interior regions as defined in project.py
    #-----------------------------------------------------------------------
    domain = anuga.create_domain_from_regions(
        project.bounding_polygon,
        boundary_tags={
            'top': [0],
            'ocean_east': [1],
            'bottom': [2],
            'onshore': [3]
        },
        maximum_triangle_area=project.default_res,
        mesh_filename=project.meshname,
        interior_regions=project.interior_regions,
        use_cache=True,
        verbose=True)

    if gpu:
        #domain.__class__ = GPU_domain
        domain = GPU_domain(domain=domain)
    # Print some stats about mesh and domain
    print 'Number of triangles = ', len(domain)
    #print 'The extent is ', domain.get_extent()
    #print domain.statistics()

    #-----------------------------------------------------------------------
    # Setup parameters of computational domain
    #-----------------------------------------------------------------------
    domain.set_name('cairns_' + project.scenario)  # Name of sww file
    domain.set_datadir('.')  # Store sww output here
    domain.set_minimum_storable_height(0.01)  # Store only depth > 1cm
    domain.set_flow_algorithm('tsunami')

    #-----------------------------------------------------------------------
    # Setup initial conditions
    #-----------------------------------------------------------------------
    tide = 0.0
    domain.set_quantity('stage', tide)
    domain.set_quantity('friction', 0.0)

    domain.set_quantity('elevation',
                        filename=project.name_stem + '.pts',
                        use_cache=True,
                        verbose=True,
                        alpha=0.1)

    #-----------------------------------------------------------------------
    # Setup information for slide scenario
    # (to be applied 1 min into simulation
    #-----------------------------------------------------------------------
    if project.scenario == 'slide':
        # Function for submarine slide
        tsunami_source = anuga.slide_tsunami(length=35000.0,
                                             depth=project.slide_depth,
                                             slope=6.0,
                                             thickness=500.0,
                                             x0=project.slide_origin[0],
                                             y0=project.slide_origin[1],
                                             alpha=0.0,
                                             domain=domain,
                                             verbose=True)

    #-----------------------------------------------------------------------
    # Setup boundary conditions
    #-----------------------------------------------------------------------
    print 'Available boundary tags', domain.get_boundary_tags()

    Bd = anuga.Dirichlet_boundary([tide, 0, 0])  # Mean water level
    Bs = anuga.Transmissive_stage_zero_momentum_boundary(domain)
    # Neutral boundary

    if project.scenario == 'fixed_wave':
        # Huge 50m wave starting after 60 seconds and lasting 1 hour.
        Bw = anuga.Transmissive_n_momentum_zero_t_momentum_set_stage_boundary(
            domain=domain, function=lambda t: [(60 < t < 3660) * 50, 0, 0])

        domain.set_boundary({
            'ocean_east': Bw,
            'bottom': Bs,
            'onshore': Bd,
            'top': Bs
        })

    if project.scenario == 'slide':
        # Boundary conditions for slide scenario
        domain.set_boundary({
            'ocean_east': Bd,
            'bottom': Bd,
            'onshore': Bd,
            'top': Bd
        })

    if gpu:
        if '-gpu' in sys.argv:
            domain.using_gpu = True
            print " --> Enable GPU version"
    return domain
Exemplo n.º 4
0
def generate_channel3_domain(gpu=True):
    #-----------------------------------------------------------------------
    # Setup computational domain
    #-----------------------------------------------------------------------
    length = 40.
    width = 5.
    dx = dy = .1  # Resolution: Length of subdivisions on both axes

    points, vertices, boundary = anuga.rectangular_cross(int(length / dx),
                                                         int(width / dy),
                                                         len1=length,
                                                         len2=width)
    if gpu:
        domain = GPU_domain(points, vertices, boundary)
        if '-gpu' in sys.argv:
            domain.using_gpu = True
            print " --> Enable GPU version"
        for i in range(len(sys.argv)):
            if sys.argv[i] == '-fs':
                global finaltime
                finaltime = float(sys.argv[i + 1])
                print " --> Finaltime is reset as %f" % finaltime

    else:
        domain = anuga.Domain(points, vertices, boundary)
    domain.set_name('channel3')  # Output name

    #print domain.statistics()

    #-----------------------------------------------------------------------
    # Setup initial conditions
    #-----------------------------------------------------------------------
    def topography(x, y):
        """Complex topography defined by a function of vectors x and y."""

        z = -x / 10

        N = len(x)
        for i in range(N):
            # Step
            if 10 < x[i] < 12:
                z[i] += 0.4 - 0.05 * y[i]

            # Constriction
            if 27 < x[i] < 29 and y[i] > 3:
                z[i] += 2

            # Pole
            if (x[i] - 34)**2 + (y[i] - 2)**2 < 0.4**2:
                z[i] += 2

        return z

    domain.set_quantity('elevation', topography)  # elevation is a function
    domain.set_quantity('friction', 0.01)  # Constant friction
    domain.set_quantity('stage',
                        expression='elevation')  # Dry initial condition

    #-----------------------------------------------------------------------
    # Setup boundary conditions
    #-----------------------------------------------------------------------
    Bi = anuga.Dirichlet_boundary([0.4, 0, 0])  # Inflow
    Br = anuga.Reflective_boundary(domain)  # Solid reflective wall
    Bo = anuga.Dirichlet_boundary([-5, 0, 0])  # Outflow

    domain.set_boundary({'left': Bi, 'right': Bo, 'top': Br, 'bottom': Br})
    return domain
Exemplo n.º 5
0
def generate_channel1_domain(gpu=True):
    #--------------------------------------------------------------------------
    # Setup computational domain
    #--------------------------------------------------------------------------

    #points, vertices, boundary = anuga.rectangular_cross(10, 1,
    #                                               len1=10.0, len2=5.0) # Mesh
    points, vertices, boundary = anuga.rectangular_cross(1,
                                                         4,
                                                         len1=0.1,
                                                         len2=0.1)  # Mesh

    if gpu:
        domain = GPU_domain(points, vertices, boundary)  # Create domain
        for i in range(len(sys.argv)):
            if sys.argv[i] == '-gpu':
                domain.using_gpu = True
                print " --> Enable GPU version"
            elif sys.argv[i] == '-fs':
                finaltime = float(sys.argv[i + 1])
                print " --> Finaltime is reset as %f" % finaltime
            elif sys.argv[i] == '-test':
                domain.cotesting = True
                print " --> Enable Cotesting"
            elif sys.argv[i] == '-ustore':
                domain.store = True
                print " --> Disable storing"
    else:
        domain = anuga.Domain(points, vertices, boundary)  # Create domain
    domain.set_name('channel1')  # Output name

    #--------------------------------------------------------------------------
    # Setup initial conditions
    #--------------------------------------------------------------------------
    def topography(x, y):
        return -x / 10  # linear bed slope

    domain.set_quantity('elevation', topography)  # Use function for elevation
    domain.set_quantity('friction', 0.01)  # Constant friction
    domain.set_quantity(
        'stage',  # Dry bed
        expression='elevation')

    #--------------------------------------------------------------------------
    # Setup boundary conditions
    #--------------------------------------------------------------------------
    Bi = anuga.Dirichlet_boundary([0.4, 0, 0])  # Inflow
    Br = anuga.Reflective_boundary(domain)  # Solid reflective wall

    domain.set_boundary({'left': Bi, 'right': Br, 'top': Br, 'bottom': Br})

    return domain
Exemplo n.º 6
0
def generate_cairns_domain(gpu=False):
    #-----------------------------------------------------------------------
    # Preparation of topographic data
    # Convert ASC 2 DEM 2 PTS using source data 
    # and store result in source data
    #-----------------------------------------------------------------------
    # Create DEM from asc data
    anuga.asc2dem(project.name_stem+'.asc', use_cache=True, verbose=True)
    
    # Create pts file for onshore DEM
    anuga.dem2pts(project.name_stem+'.dem', use_cache=True, verbose=True)
    
    #-----------------------------------------------------------------------
    # Create the triangular mesh and domain based on 
    # overall clipping polygon with a tagged
    # boundary and interior regions as defined in project.py
    #-----------------------------------------------------------------------
    domain = anuga.create_domain_from_regions(project.bounding_polygon,
            boundary_tags={'top': [0],
            'ocean_east': [1],
            'bottom': [2],
            'onshore': [3]},
            maximum_triangle_area=project.default_res,
            mesh_filename=project.meshname,
            interior_regions=project.interior_regions,
            use_cache=True,
            verbose=True)

    if gpu :
        #domain.__class__ = GPU_domain
        domain = GPU_domain(domain=domain)
    # Print some stats about mesh and domain
    print 'Number of triangles = ', len(domain)
    #print 'The extent is ', domain.get_extent()
    #print domain.statistics()
                                        
    #-----------------------------------------------------------------------
    # Setup parameters of computational domain
    #-----------------------------------------------------------------------
    domain.set_name('cairns_' + project.scenario) # Name of sww file
    domain.set_datadir('.')                       # Store sww output here
    domain.set_minimum_storable_height(0.01)      # Store only depth > 1cm
    domain.set_flow_algorithm('tsunami')
    
    #-----------------------------------------------------------------------
    # Setup initial conditions
    #-----------------------------------------------------------------------
    tide = 0.0
    domain.set_quantity('stage', tide)
    domain.set_quantity('friction', 0.0)
    
    
    domain.set_quantity('elevation', 
                        filename=project.name_stem + '.pts',
                        use_cache=True,
                        verbose=True,
                        alpha=0.1)
    
    #-----------------------------------------------------------------------
    # Setup information for slide scenario 
    # (to be applied 1 min into simulation
    #-----------------------------------------------------------------------
    if project.scenario == 'slide':
        # Function for submarine slide
        tsunami_source = anuga.slide_tsunami(length=35000.0,
                                       depth=project.slide_depth,
                                       slope=6.0,
                                       thickness=500.0, 
                                       x0=project.slide_origin[0], 
                                       y0=project.slide_origin[1], 
                                       alpha=0.0, 
                                       domain=domain,
                                       verbose=True)
    
    #-----------------------------------------------------------------------
    # Setup boundary conditions
    #-----------------------------------------------------------------------
    print 'Available boundary tags', domain.get_boundary_tags()
    
    Bd = anuga.Dirichlet_boundary([tide, 0, 0]) # Mean water level
    Bs = anuga.Transmissive_stage_zero_momentum_boundary(domain) 
    # Neutral boundary
    
    if project.scenario == 'fixed_wave':
        # Huge 50m wave starting after 60 seconds and lasting 1 hour.
        Bw=anuga.Transmissive_n_momentum_zero_t_momentum_set_stage_boundary(
                            domain=domain, 
                            function=lambda t: [(60<t<3660)*50, 0, 0])
    
        domain.set_boundary({'ocean_east': Bw,
                             'bottom': Bs,
                             'onshore': Bd,
                             'top': Bs})
    
    if project.scenario == 'slide':
        # Boundary conditions for slide scenario
        domain.set_boundary({'ocean_east': Bd,
                             'bottom': Bd,
                             'onshore': Bd,
                             'top': Bd})
    
    
    if gpu:
        if '-gpu' in sys.argv:
            domain.using_gpu = True
            print " --> Enable GPU version"
    return domain