source: documentation/user_manual/examples/runsydney.py @ 2805

Last change on this file since 2805 was 2805, checked in by ole, 19 years ago

Comments

File size: 5.4 KB
Line 
1"""Script for running a tsunami inundation scenario for Sydney, NSW, Australia.
2
3Source data such as elevation and boundary data is assumed to be available in
4directories specified by project.py
5The output sww file is stored in project.outputdir
6
7The scenario is defined by a triangular mesh created from project.polygon,
8the elevation data and a simulated submarine landslide.
9
10Ole 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
19import os
20import time
21
22# Related major packages
23from pyvolution.shallow_water import Domain, Reflective_boundary
24from pyvolution.data_manager import convert_dem_from_ascii2netcdf, dem2pts
25from pyvolution.combine_pts import combine_rectangular_points_files
26from pyvolution.pmesh2domain import pmesh_to_domain_instance
27from pmesh.mesh_interface import create_mesh_from_regions
28
29# Application specific imports
30import project                           # Definition of file names and polygons
31from pyvolution.smf import slump_tsunami # Function for submarine mudslide
32
33
34
35#-------------------------------------------------------------------------------   
36# Prepare bathymetric and topographic data
37#-------------------------------------------------------------------------------
38
39# filenames
40coarsedemname = project.coarsedemname + '.pts'
41finedemname = project.finedemname + '.pts'
42combineddemname = project.combineddemname + '.pts'
43meshname = project.meshname+'.msh'
44
45
46# combining the coarse and fine data
47combine_rectangular_points_files(finedemname,
48                                 coarsedemname,
49                                 combineddemname)
50
51
52
53#-------------------------------------------------------------------------------   
54# Setup computational domain
55#-------------------------------------------------------------------------------
56
57# Interior regions and mesh resolutions
58interior_res = 5000
59interior_regions = [[project.harbour_polygon_2, interior_res],
60                    [project.botanybay_polygon_2, interior_res]]
61
62
63create_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
78domain = pmesh_to_domain_instance(meshname, Domain,
79                                  use_cache = True,
80                                  verbose = True)
81#domain = Domain(meshname)
82
83
84print 'Number of triangles = ', len(domain)
85print 'The extent is ', domain.get_extent()
86
87domain.set_name(project.basename)
88domain.set_datadir(project.outputdir)
89domain.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
96tsunami_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
112domain.set_quantity('stage', tsunami_source)
113domain.set_quantity('friction', 0.0) 
114domain.set_quantity('elevation',
115                    filename = combineddemname,
116                    use_cache = True,
117                    verbose = True)
118
119
120#-------------------------------------------------------------------------------
121# Setup boundary conditions (all reflective)
122#-------------------------------------------------------------------------------
123
124print 'Available boundary tags', domain.get_boundary_tags()
125
126Br = Reflective_boundary(domain)
127domain.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
136import time
137t0 = time.time()
138
139for t in domain.evolve(yieldstep = 120, duration = 18000):
140    print domain.timestepping_statistics()
141    print domain.boundary_statistics(tags = 'bottom')   
142   
143print 'That took %.2f seconds' %(time.time()-t0)
Note: See TracBrowser for help on using the repository browser.