"""Script for running a tsunami inundation scenario for Cairns, QLD 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 directory named after the scenario, i.e slide or fixed_wave. The scenario is defined by a triangular mesh created from project.polygon, the elevation data and a tsunami wave generated by a submarine mass failure. Ole Nielsen and Duncan Gray, GA - 2005 and Jane Sexton and Nick Bartzis, GA - 2006 """ #------------------------------------------------------------------------------ # Import necessary modules #------------------------------------------------------------------------------ # Standard modules import os import time import sys # Related major packages from anuga.shallow_water import Domain from anuga.shallow_water import Reflective_boundary from anuga.shallow_water import Dirichlet_boundary from anuga.shallow_water import Time_boundary from anuga.shallow_water import Transmissive_Momentum_Set_Stage_boundary from anuga.abstract_2d_finite_volumes.util import file_function from anuga.pmesh.mesh_interface import create_mesh_from_regions from anuga.shallow_water.data_manager import convert_dem_from_ascii2netcdf from anuga.shallow_water.data_manager import dem2pts from anuga.geospatial_data.geospatial_data import Geospatial_data from anuga.shallow_water.shallow_water_domain import Inflow # Application specific imports import project # Definition of file names and polygons #------------------------------------------------------------------------------ # Define scenario as either slide or fixed_wave. #------------------------------------------------------------------------------ scenario = 'slide' #scenario = 'fixed_wave' if os.access(scenario, os.F_OK) == 0: os.mkdir(scenario) basename = scenario + 'source' #------------------------------------------------------------------------------ # Preparation of topographic data # Convert ASC 2 DEM 2 PTS using source data and store result in source data #------------------------------------------------------------------------------ # Filenames basename = 'blackbutt' meshname = basename+'.msh' elevation_file = 'ALL_Grd_Bui_Comb_Smth_Rds_XYZPts_only' # Create pts file #G = Geospatial_data(elevation_file+'.csv') #G.export_points_file(basename+'.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 #------------------------------------------------------------------------------ W = 302500 S = 6171740 N = 6172270 E = 304000 bounding_polygon = [[W, S], [E, S], [E, N], [W, N]] channel_polygon = [[W, S+100], [E, S+100], [E, N-100], [W, N-100]] interior_regions = [ [channel_polygon, 100] ] # 100 m^2 create_mesh_from_regions(bounding_polygon, boundary_tags={'south': [0], 'east': [1], 'north': [2], 'west': [3]}, maximum_triangle_area=400, interior_regions=interior_regions, filename=meshname, use_cache=False, verbose=True) #------------------------------------------------------------------------------ # Setup computational domain #------------------------------------------------------------------------------ domain = Domain(meshname, use_cache=True, verbose=True) print domain.statistics() domain.set_name(basename) #------------------------------------------------------------------------------ # Setup initial conditions #------------------------------------------------------------------------------ tide = -100 domain.set_quantity('stage', tide) domain.set_quantity('friction', 0.0, location = 'centroids') domain.set_quantity('elevation', filename=basename+'.pts', use_cache=True, verbose=True, alpha=0.01) #------------------------------------------------------------------------------ # Setup specialised forcing terms #------------------------------------------------------------------------------ hydrograph = Inflow(center=(300, 300), radius=50, flow=file_function('Q/QPMF_Rot_Sub13.tms')) domain.forcing_terms.append(hydrograph) #------------------------------------------------------------------------------ # Setup boundary conditions #------------------------------------------------------------------------------ print 'Available boundary tags', domain.get_boundary_tags() Br = Reflective_boundary(domain) Bd = Dirichlet_boundary([tide,0,0]) # boundary conditions for slide scenario domain.set_boundary({'west': Bd, 'south': Bd, 'east': Transmissive_Momentum_Set_Stage_boundary(domain, lambda t: tide), 'north': Bd}) #------------------------------------------------------------------------------ # Evolve system through time #------------------------------------------------------------------------------ import time t0 = time.time() for t in domain.evolve(yieldstep = 1, finaltime = 3000): domain.write_time() #domain.write_boundary_statistics(tags='east', quantities='stage') if t > 2538: hydrograph.flow = 0.0