source: production/onslow_2006/run_onslow.py @ 2441

Last change on this file since 2441 was 2441, checked in by nick, 19 years ago
File size: 6.7 KB
Line 
1"""Script for running a tsunami inundation scenario for Onslow, WA, 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 Nick Bartzis, GA - 2006
11"""
12
13
14#-------------------------------------------------------------------------------# Import necessary modules
15#-------------------------------------------------------------------------------
16
17# Standard modules
18import os
19import time
20
21# Related major packages
22from pyvolution.shallow_water import Domain, Reflective_boundary
23from pyvolution.shallow_water import Domain, Time_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
27
28# Application specific imports
29import project                 # Definition of file names and polygons
30from smf import slump_tsunami  # Function for submarine mudslide
31
32
33#-------------------------------------------------------------------------------
34# Preparation of topographic data
35#
36# Convert ASC 2 DEM 2 PTS using source data and store result in source data
37# Do for coarse and fine data
38# Fine pts file to be clipped to area of interest
39#-------------------------------------------------------------------------------
40'''
41# filenames
42coarsedemname = project.coarsedemname
43#finedemname = project.finedemname
44'''
45meshname = project.meshname+'.msh'
46'''
47# coarse data
48convert_dem_from_ascii2netcdf(coarsedemname, use_cache=True, verbose=True)
49dem2pts(coarsedemname, use_cache=True, verbose=True)
50
51# fine data (clipping the points file to smaller area)
52convert_dem_from_ascii2netcdf(finedemname, use_cache=True, verbose=True)
53dem2pts(finedemname,
54        easting_min=project.eastingmin,
55        easting_max=project.eastingmax,
56        northing_min=project.northingmin,
57        northing_max= project.northingmax,
58        use_cache=True,
59        verbose=True)
60
61
62# combining the coarse and fine data
63combine_rectangular_points_files(project.finedemname + '.pts',
64                                 project.coarsedemname + '.pts',
65                                 project.combineddemname + '.pts')
66'''
67
68#-------------------------------------------------------------------------------                                 
69# Create the triangular mesh based on overall clipping polygon with a tagged
70# boundary and interior regions defined in project.py along with
71# resolutions (maximal area of per triangle) for each polygon
72#-------------------------------------------------------------------------------
73
74from pmesh.create_mesh import create_mesh_from_regions
75
76# original
77interior_res = 5000
78interior_regions = [[project.poly_onslow, interior_res],
79                    [project.poly_thevenard, interior_res],
80                    [project.poly_direction, interior_res]]
81
82#FIXME: Fix caching of this one once the mesh_interface is ready
83from caching import cache
84_ = cache(create_mesh_from_regions,
85          project.polyAll,
86          {'boundary_tags': {'top': [0], 'topleft': [1],
87                             'left': [2], 'bottom': [3],
88                             'bottomright': [4], 'topright': [5]},
89           'resolution': 100000,
90           'filename': meshname,           
91           'interior_regions': interior_regions,
92           'UTM': True,
93           'refzone': project.refzone},
94          verbose = True)
95
96
97#-------------------------------------------------------------------------------                                 
98# Setup computational domain
99#-------------------------------------------------------------------------------                                 
100
101domain = pmesh_to_domain_instance(meshname, Domain,
102                                  use_cache = True,
103                                  verbose = True)
104
105print 'Number of triangles = ', len(domain)
106print 'The extent is ', domain.get_extent()
107
108domain.set_name(project.basename)
109domain.set_datadir(project.outputdir)
110domain.set_quantities_to_be_stored(['stage', 'xmomentum', 'ymomentum'])
111
112
113#-------------------------------------------------------------------------------
114# Set up scenario (tsunami_source is a callable object used with set_quantity)
115#-------------------------------------------------------------------------------
116'''
117tsunami_source = slump_tsunami(length=30000.0,
118                               depth=400.0,
119                               slope=6.0,
120                               thickness=176.0,
121                               radius=3330,
122                               dphi=0.23,
123                               x0=project.slump_origin[0],
124                               y0=project.slump_origin[1],
125                               alpha=0.0,
126                               domain=domain)
127
128'''
129#-------------------------------------------------------------------------------                                 
130# Setup initial conditions
131#-------------------------------------------------------------------------------
132
133domain.set_quantity('stage', 0.)
134domain.set_quantity('friction', 0.0) 
135domain.set_quantity('elevation', 0.
136#                    filename = project.combineddemname + '.pts',
137#                    filename = project.coarsedemname + '.pts',
138#                    use_cache = True,
139#                    verbose = True
140                    )
141
142
143#-------------------------------------------------------------------------------                                 
144# Setup boundary conditions (all reflective)
145#-------------------------------------------------------------------------------
146
147print 'Available boundary tags', domain.get_boundary_tags()
148
149Br = Reflective_boundary(domain)
150# 10 min square wave starting at 1 min, 6m high
151Bw = Time_boundary(domain = domain,
152                   f=lambda t: [(20<t<200)*6, 0, 0])
153
154domain.set_boundary( {'top': Br, 'topleft': Br,
155                             'left': Br, 'bottom': Br,
156                             'bottomright': Br, 'topright': Br} )
157
158
159#-------------------------------------------------------------------------------                                 
160# Evolve system through time
161#-------------------------------------------------------------------------------
162
163import time
164t0 = time.time()
165
166for t in domain.evolve(yieldstep = 10, finaltime = 20): 
167    domain.write_time()
168    domain.write_boundary_statistics(tags = 'top')     
169   
170print 'That took %.2f seconds' %(time.time()-t0)
Note: See TracBrowser for help on using the repository browser.