"""Script for running a tsunami inundation scenario for Onslow, WA, 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. Ole Nielsen and Duncan Gray, GA - 2005 and Nick Bartzis, GA - 2006 """ #-------------------------------------------------------------------------------# Import necessary modules #------------------------------------------------------------------------------- # Standard modules import os import time # Related major packages from pyvolution.shallow_water import Domain, Reflective_boundary from pyvolution.shallow_water import Domain, Time_boundary from pyvolution.data_manager import convert_dem_from_ascii2netcdf, dem2pts from pyvolution.combine_pts import combine_rectangular_points_files from pyvolution.pmesh2domain import pmesh_to_domain_instance # Application specific imports import project # Definition of file names and polygons from smf import slump_tsunami # Function for submarine mudslide #------------------------------------------------------------------------------- # Preparation of topographic data # # Convert ASC 2 DEM 2 PTS using source data and store result in source data # Do for coarse and fine data # Fine pts file to be clipped to area of interest #------------------------------------------------------------------------------- # filenames coarsedemname = project.coarsedemname ''' #finedemname = project.finedemname ''' meshname = project.meshname+'.msh' # coarse data convert_dem_from_ascii2netcdf(coarsedemname, use_cache=True, verbose=True) dem2pts(coarsedemname, use_cache=True, verbose=True) ''' # fine data (clipping the points file to smaller area) convert_dem_from_ascii2netcdf(finedemname, use_cache=True, verbose=True) dem2pts(finedemname, easting_min=project.eastingmin, easting_max=project.eastingmax, northing_min=project.northingmin, northing_max= project.northingmax, use_cache=True, verbose=True) # combining the coarse and fine data combine_rectangular_points_files(project.finedemname + '.pts', project.coarsedemname + '.pts', project.combineddemname + '.pts') ''' #------------------------------------------------------------------------------- # Create the triangular mesh based on overall clipping polygon with a tagged # boundary and interior regions defined in project.py along with # resolutions (maximal area of per triangle) for each polygon #------------------------------------------------------------------------------- from pmesh.create_mesh import create_mesh_from_regions # original interior_res = 5000 interior_regions = [[project.poly_onslow, interior_res], [project.poly_thevenard, interior_res], [project.poly_direction, interior_res]] #FIXME: Fix caching of this one once the mesh_interface is ready from caching import cache _ = cache(create_mesh_from_regions, project.polyAll, {'boundary_tags': {'top': [0], 'topleft': [1], 'left': [2], 'bottom': [3], 'bottomright': [4], 'topright': [5]}, 'resolution': 100000, 'filename': meshname, 'interior_regions': interior_regions, 'UTM': True, 'refzone': project.refzone}, verbose = True) #------------------------------------------------------------------------------- # Setup computational domain #------------------------------------------------------------------------------- domain = pmesh_to_domain_instance(meshname, Domain, 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', 0.) domain.set_quantity('friction', 0.0) domain.set_quantity('elevation', # filename = project.combineddemname + '.pts', filename = project.coarsedemname + '.pts', use_cache = True, verbose = True ) #------------------------------------------------------------------------------- # Setup boundary conditions (all reflective) #------------------------------------------------------------------------------- print 'Available boundary tags', domain.get_boundary_tags() Br = Reflective_boundary(domain) # 10 min square wave starting at 1 min, 6m high Bw = Time_boundary(domain = domain, f=lambda t: [(50