[2461] | 1 | """Script for running a tsunami inundation scenario for Sydney, NSW, Australia. |
---|
| 2 | |
---|
| 3 | Source data such as elevation and boundary data is assumed to be available in |
---|
| 4 | directories specified by project.py |
---|
| 5 | The output sww file is stored in project.outputdir |
---|
| 6 | |
---|
| 7 | The scenario is defined by a triangular mesh created from project.polygon, |
---|
| 8 | the elevation data and a simulated submarine landslide. |
---|
| 9 | |
---|
| 10 | """ |
---|
| 11 | |
---|
| 12 | |
---|
[2887] | 13 | #------------------------------------------------------------------------------ |
---|
[2478] | 14 | # Import necessary modules |
---|
[2887] | 15 | #------------------------------------------------------------------------------ |
---|
[2461] | 16 | |
---|
| 17 | # Standard modules |
---|
| 18 | import os |
---|
| 19 | import time |
---|
| 20 | |
---|
| 21 | # Related major packages |
---|
[3136] | 22 | from pyvolution.shallow_water import Domain, Dirichlet_boundary |
---|
[2461] | 23 | from pyvolution.data_manager import convert_dem_from_ascii2netcdf, dem2pts |
---|
| 24 | from pyvolution.combine_pts import combine_rectangular_points_files |
---|
| 25 | from pmesh.mesh_interface import create_mesh_from_regions |
---|
| 26 | |
---|
| 27 | # Application specific imports |
---|
[2887] | 28 | import project # Define file names and polygons |
---|
[2478] | 29 | from pyvolution.smf import slump_tsunami # Function for submarine mudslide |
---|
[2461] | 30 | |
---|
| 31 | |
---|
| 32 | |
---|
[2887] | 33 | #------------------------------------------------------------------------------ |
---|
[2599] | 34 | # Prepare bathymetric and topographic data |
---|
[2887] | 35 | #------------------------------------------------------------------------------ |
---|
[2478] | 36 | |
---|
[2461] | 37 | # filenames |
---|
| 38 | coarsedemname = project.coarsedemname + '.pts' |
---|
| 39 | finedemname = project.finedemname + '.pts' |
---|
[2464] | 40 | combineddemname = project.combineddemname + '.pts' |
---|
[2461] | 41 | meshname = project.meshname+'.msh' |
---|
| 42 | |
---|
| 43 | |
---|
| 44 | # combining the coarse and fine data |
---|
| 45 | combine_rectangular_points_files(finedemname, |
---|
| 46 | coarsedemname, |
---|
| 47 | combineddemname) |
---|
| 48 | |
---|
| 49 | |
---|
[2478] | 50 | |
---|
[2887] | 51 | #------------------------------------------------------------------------------ |
---|
[2478] | 52 | # Setup computational domain |
---|
[2887] | 53 | #------------------------------------------------------------------------------ |
---|
[2478] | 54 | |
---|
| 55 | # Interior regions and mesh resolutions |
---|
[2461] | 56 | interior_res = 5000 |
---|
[3136] | 57 | interior_regions = [[project.northern_polygon, interior_res], |
---|
| 58 | [project.harbour_polygon, interior_res], |
---|
[3190] | 59 | [project.southern_polygon, interior_res], |
---|
| 60 | [project.manly_polygon, interior_res], |
---|
| 61 | [project.top_polygon, interior_res]] |
---|
[2461] | 62 | |
---|
| 63 | |
---|
[3136] | 64 | create_mesh_from_regions(project.demopoly, |
---|
| 65 | boundary_tags= {'oceannorth': [0], |
---|
[3190] | 66 | 'onshorenorth1': [1], |
---|
| 67 | 'onshorenorthwest1': [2], |
---|
| 68 | 'onshorenorthwest2': [3], |
---|
| 69 | 'onshorenorth2': [4], |
---|
| 70 | 'onshorewest': [5], |
---|
| 71 | 'onshoresouth': [6], |
---|
| 72 | 'oceansouth': [7], |
---|
| 73 | 'oceaneast': [8]}, |
---|
[2478] | 74 | maximum_triangle_area=100000, |
---|
| 75 | filename=meshname, |
---|
| 76 | interior_regions=interior_regions) |
---|
[2461] | 77 | |
---|
| 78 | |
---|
[2805] | 79 | #Create shallow water domain |
---|
[2461] | 80 | |
---|
[2866] | 81 | domain = Domain(meshname, |
---|
| 82 | use_cache = True, |
---|
| 83 | verbose = True) |
---|
[2805] | 84 | |
---|
[2866] | 85 | |
---|
[2461] | 86 | print 'Number of triangles = ', len(domain) |
---|
| 87 | print 'The extent is ', domain.get_extent() |
---|
| 88 | |
---|
| 89 | domain.set_name(project.basename) |
---|
| 90 | domain.set_datadir(project.outputdir) |
---|
| 91 | domain.set_quantities_to_be_stored(['stage', 'xmomentum', 'ymomentum']) |
---|
| 92 | |
---|
| 93 | |
---|
[2887] | 94 | #------------------------------------------------------------------------------ |
---|
[2461] | 95 | # Set up scenario (tsunami_source is a callable object used with set_quantity) |
---|
[2887] | 96 | #------------------------------------------------------------------------------ |
---|
[2461] | 97 | |
---|
| 98 | tsunami_source = slump_tsunami(length=30000.0, |
---|
| 99 | depth=400.0, |
---|
| 100 | slope=6.0, |
---|
| 101 | thickness=176.0, |
---|
| 102 | radius=3330, |
---|
| 103 | dphi=0.23, |
---|
| 104 | x0=project.slump_origin[0], |
---|
| 105 | y0=project.slump_origin[1], |
---|
| 106 | alpha=0.0, |
---|
| 107 | domain=domain) |
---|
| 108 | |
---|
| 109 | |
---|
[2887] | 110 | #------------------------------------------------------------------------------ |
---|
[2461] | 111 | # Setup initial conditions |
---|
[2887] | 112 | #------------------------------------------------------------------------------ |
---|
[2461] | 113 | |
---|
| 114 | domain.set_quantity('stage', tsunami_source) |
---|
| 115 | domain.set_quantity('friction', 0.0) |
---|
| 116 | domain.set_quantity('elevation', |
---|
| 117 | filename = combineddemname, |
---|
| 118 | use_cache = True, |
---|
| 119 | verbose = True) |
---|
| 120 | |
---|
[2887] | 121 | #------------------------------------------------------------------------------ |
---|
[3136] | 122 | # Setup boundary conditions (all Dirichlet) |
---|
[2887] | 123 | #------------------------------------------------------------------------------ |
---|
[2461] | 124 | |
---|
| 125 | print 'Available boundary tags', domain.get_boundary_tags() |
---|
| 126 | |
---|
[3136] | 127 | Bd = Dirichlet_boundary([0.0,0.0,0.0]) |
---|
[3190] | 128 | domain.set_boundary( {'oceannorth': Bd, |
---|
| 129 | 'onshorenorth1': Bd, |
---|
| 130 | 'onshorenorthwest1': Bd, |
---|
| 131 | 'onshorenorthwest2': Bd, |
---|
| 132 | 'onshorenorth2': Bd, |
---|
| 133 | 'onshorewest': Bd, |
---|
| 134 | 'onshoresouth': Bd, |
---|
| 135 | 'oceansouth': Bd, |
---|
| 136 | 'oceaneast': Bd} ) |
---|
[2461] | 137 | |
---|
[2887] | 138 | #------------------------------------------------------------------------------ |
---|
[2461] | 139 | # Evolve system through time |
---|
[2887] | 140 | #------------------------------------------------------------------------------ |
---|
[2461] | 141 | |
---|
| 142 | import time |
---|
| 143 | t0 = time.time() |
---|
| 144 | |
---|
[3190] | 145 | for t in domain.evolve(yieldstep = 60, finaltime = 7200): |
---|
[2497] | 146 | print domain.timestepping_statistics() |
---|
[3136] | 147 | print domain.boundary_statistics(tags = 'oceaneast') |
---|
[2461] | 148 | |
---|
| 149 | print 'That took %.2f seconds' %(time.time()-t0) |
---|