"""Script for running a tsunami inundation scenario for Sydney, NSW, Australia. Source data such as elevation and boundary data is assumed to be available in directories specified by project.py The output sww file is stored in project.outputdir The scenario is defined by a triangular mesh created from project.polygon, the elevation data and a simulated submarine landslide. """ #------------------------------------------------------------------------------ # Import necessary modules #------------------------------------------------------------------------------ # Standard modules import os import time # Related major packages import anuga # Application specific imports import project # Define file names and polygons #------------------------------------------------------------------------------ # Prepare bathymetric and topographic data #------------------------------------------------------------------------------ # filenames #coarsedemname = project.coarsedemname + '.pts' #finedemname = project.finedemname + '.pts' demname = project.demname meshname = project.meshname+'.msh' anuga.asc2dem(demname, use_cache=True, verbose=True) # creates pts file anuga.dem2pts(demname, use_cache=True, verbose=True) #------------------------------------------------------------------------------ # Setup computational domain #------------------------------------------------------------------------------ # Interior regions and mesh resolutions interior_res = 5000 shallow_res = 15000 ##interior_regions = [[project.northern_polygon, interior_res], ## [project.harbour_polygon, interior_res], ## [project.southern_polygon, interior_res], ## [project.manly_polygon, interior_res], ## [project.top_polygon, interior_res]] interior_regions = [[project.coastal_polygon, interior_res], [project.shallow_polygon, shallow_res]] anuga.create_mesh_from_regions(project.demopoly, boundary_tags= {'oceannorth': [0], 'onshorenorth1': [1], 'onshorenorthwest1': [2], 'onshorenorthwest2': [3], 'onshorenorth2': [4], 'onshorewest': [5], 'onshoresouth': [6], 'oceansouth': [7], 'oceaneast': [8]}, maximum_triangle_area=100000, filename=meshname, interior_regions=interior_regions) #Create shallow water domain domain = anuga.Domain(meshname, use_cache = True, verbose = True) print 'Number of triangles = ', len(domain) print 'The extent is ', domain.get_extent() domain.set_name(project.basename) domain.set_datadir(project.outputdir) domain.set_quantities_to_be_stored(['stage', 'xmomentum', 'ymomentum']) #------------------------------------------------------------------------------ # Set up scenario (tsunami_source is a callable object used with set_quantity) #------------------------------------------------------------------------------ tsunami_source = anuga.slump_tsunami(length=30000.0, depth=400.0, slope=6.0, thickness=176.0, radius=3330, dphi=0.23, x0=project.slump_origin[0], y0=project.slump_origin[1], alpha=0.0, domain=domain) #------------------------------------------------------------------------------ # Setup initial conditions #------------------------------------------------------------------------------ domain.set_quantity('stage', tsunami_source) domain.set_quantity('friction', 0.0) domain.set_quantity('elevation', filename = demname + '.pts', use_cache = True, verbose = True) #------------------------------------------------------------------------------ # Setup boundary conditions (all Dirichlet) #------------------------------------------------------------------------------ print 'Available boundary tags', domain.get_boundary_tags() Bd = anuga.Dirichlet_boundary([0.0,0.0,0.0]) domain.set_boundary( {'oceannorth': Bd, 'onshorenorth1': Bd, 'onshorenorthwest1': Bd, 'onshorenorthwest2': Bd, 'onshorenorth2': Bd, 'onshorewest': Bd, 'onshoresouth': Bd, 'oceansouth': Bd, 'oceaneast': Bd} ) #------------------------------------------------------------------------------ # Evolve system through time #------------------------------------------------------------------------------ import time t0 = time.time() for t in domain.evolve(yieldstep = 60, finaltime = 7200): print domain.timestepping_statistics() print domain.boundary_statistics(tags = 'oceaneast') print 'That took %.2f seconds' %(time.time()-t0)