"""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 from pyvolution.shallow_water import Domain, Dirichlet_boundary from pyvolution.data_manager import convert_dem_from_ascii2netcdf, dem2pts from pyvolution.combine_pts import combine_rectangular_points_files from pmesh.mesh_interface import create_mesh_from_regions # Application specific imports import project # Define file names and polygons from pyvolution.smf import slump_tsunami # Function for submarine mudslide #------------------------------------------------------------------------------ # Prepare bathymetric and topographic data #------------------------------------------------------------------------------ # filenames coarsedemname = project.coarsedemname + '.pts' finedemname = project.finedemname + '.pts' combineddemname = project.combineddemname + '.pts' meshname = project.meshname+'.msh' # combining the coarse and fine data combine_rectangular_points_files(finedemname, coarsedemname, combineddemname) #------------------------------------------------------------------------------ # Setup computational domain #------------------------------------------------------------------------------ # Interior regions and mesh resolutions interior_res = 5000 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]] 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 = 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 = 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 = combineddemname, use_cache = True, verbose = True) #------------------------------------------------------------------------------ # Setup boundary conditions (all Dirichlet) #------------------------------------------------------------------------------ print 'Available boundary tags', domain.get_boundary_tags() Bd = 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)