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 | Ole Nielsen and Duncan Gray, GA - 2005 and Adrian Hitchman and Jane Sexton, GA - 2006 |
---|
11 | """ |
---|
12 | |
---|
13 | |
---|
14 | #------------------------------------------------------------------------------- |
---|
15 | # Import necessary modules |
---|
16 | #------------------------------------------------------------------------------- |
---|
17 | |
---|
18 | # Standard modules |
---|
19 | import os |
---|
20 | import time |
---|
21 | |
---|
22 | # Related major packages |
---|
23 | from pyvolution.shallow_water import Domain, Reflective_boundary |
---|
24 | from pyvolution.data_manager import convert_dem_from_ascii2netcdf, dem2pts |
---|
25 | from pyvolution.combine_pts import combine_rectangular_points_files |
---|
26 | from pyvolution.pmesh2domain import pmesh_to_domain_instance |
---|
27 | from pmesh.mesh_interface import create_mesh_from_regions |
---|
28 | |
---|
29 | # Application specific imports |
---|
30 | import project # Definition of file names and polygons |
---|
31 | from pyvolution.smf import slump_tsunami # Function for submarine mudslide |
---|
32 | |
---|
33 | |
---|
34 | |
---|
35 | #------------------------------------------------------------------------------- |
---|
36 | # Prepare bathymetric and topographic data |
---|
37 | #------------------------------------------------------------------------------- |
---|
38 | |
---|
39 | # filenames |
---|
40 | coarsedemname = project.coarsedemname + '.pts' |
---|
41 | finedemname = project.finedemname + '.pts' |
---|
42 | combineddemname = project.combineddemname + '.pts' |
---|
43 | meshname = project.meshname+'.msh' |
---|
44 | |
---|
45 | |
---|
46 | # combining the coarse and fine data |
---|
47 | combine_rectangular_points_files(finedemname, |
---|
48 | coarsedemname, |
---|
49 | combineddemname) |
---|
50 | |
---|
51 | |
---|
52 | |
---|
53 | #------------------------------------------------------------------------------- |
---|
54 | # Setup computational domain |
---|
55 | #------------------------------------------------------------------------------- |
---|
56 | |
---|
57 | # Interior regions and mesh resolutions |
---|
58 | interior_res = 5000 |
---|
59 | interior_regions = [[project.harbour_polygon_2, interior_res], |
---|
60 | [project.botanybay_polygon_2, interior_res]] |
---|
61 | |
---|
62 | |
---|
63 | create_mesh_from_regions(project.diffpolygonall, |
---|
64 | boundary_tags= {'bottom': [0], |
---|
65 | 'right1': [1], |
---|
66 | 'right0': [2], |
---|
67 | 'right2': [3], |
---|
68 | 'top': [4], |
---|
69 | 'left1': [5], |
---|
70 | 'left2': [6], |
---|
71 | 'left3': [7]}, |
---|
72 | maximum_triangle_area=100000, |
---|
73 | filename=meshname, |
---|
74 | interior_regions=interior_regions) |
---|
75 | |
---|
76 | |
---|
77 | #Create shallow water domain |
---|
78 | domain = pmesh_to_domain_instance(meshname, Domain, |
---|
79 | use_cache = True, |
---|
80 | verbose = True) |
---|
81 | #domain = Domain(meshname) |
---|
82 | |
---|
83 | |
---|
84 | print 'Number of triangles = ', len(domain) |
---|
85 | print 'The extent is ', domain.get_extent() |
---|
86 | |
---|
87 | domain.set_name(project.basename) |
---|
88 | domain.set_datadir(project.outputdir) |
---|
89 | domain.set_quantities_to_be_stored(['stage', 'xmomentum', 'ymomentum']) |
---|
90 | |
---|
91 | |
---|
92 | #------------------------------------------------------------------------------- |
---|
93 | # Set up scenario (tsunami_source is a callable object used with set_quantity) |
---|
94 | #------------------------------------------------------------------------------- |
---|
95 | |
---|
96 | tsunami_source = slump_tsunami(length=30000.0, |
---|
97 | depth=400.0, |
---|
98 | slope=6.0, |
---|
99 | thickness=176.0, |
---|
100 | radius=3330, |
---|
101 | dphi=0.23, |
---|
102 | x0=project.slump_origin[0], |
---|
103 | y0=project.slump_origin[1], |
---|
104 | alpha=0.0, |
---|
105 | domain=domain) |
---|
106 | |
---|
107 | |
---|
108 | #------------------------------------------------------------------------------- |
---|
109 | # Setup initial conditions |
---|
110 | #------------------------------------------------------------------------------- |
---|
111 | |
---|
112 | domain.set_quantity('stage', tsunami_source) |
---|
113 | domain.set_quantity('friction', 0.0) |
---|
114 | domain.set_quantity('elevation', |
---|
115 | filename = combineddemname, |
---|
116 | use_cache = True, |
---|
117 | verbose = True) |
---|
118 | |
---|
119 | |
---|
120 | #------------------------------------------------------------------------------- |
---|
121 | # Setup boundary conditions (all reflective) |
---|
122 | #------------------------------------------------------------------------------- |
---|
123 | |
---|
124 | print 'Available boundary tags', domain.get_boundary_tags() |
---|
125 | |
---|
126 | Br = Reflective_boundary(domain) |
---|
127 | domain.set_boundary( {'bottom': Br, 'right1': Br, 'right0': Br, |
---|
128 | 'right2': Br, 'top': Br, 'left1': Br, |
---|
129 | 'left2': Br, 'left3': Br} ) |
---|
130 | |
---|
131 | |
---|
132 | #------------------------------------------------------------------------------- |
---|
133 | # Evolve system through time |
---|
134 | #------------------------------------------------------------------------------- |
---|
135 | |
---|
136 | import time |
---|
137 | t0 = time.time() |
---|
138 | |
---|
139 | for t in domain.evolve(yieldstep = 120, duration = 18000): |
---|
140 | print domain.timestepping_statistics() |
---|
141 | print domain.boundary_statistics(tags = 'bottom') |
---|
142 | |
---|
143 | print 'That took %.2f seconds' %(time.time()-t0) |
---|