source: production/onslow_2006/run_onslow.py @ 2443

Last change on this file since 2443 was 2443, 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'''
44#finedemname = project.finedemname
45'''
46meshname = project.meshname+'.msh'
47
48# coarse data
49convert_dem_from_ascii2netcdf(coarsedemname, use_cache=True, verbose=True)
50dem2pts(coarsedemname, use_cache=True, verbose=True)
51'''
52# fine data (clipping the points file to smaller area)
53convert_dem_from_ascii2netcdf(finedemname, use_cache=True, verbose=True)
54dem2pts(finedemname,
55        easting_min=project.eastingmin,
56        easting_max=project.eastingmax,
57        northing_min=project.northingmin,
58        northing_max= project.northingmax,
59        use_cache=True,
60        verbose=True)
61
62
63# combining the coarse and fine data
64combine_rectangular_points_files(project.finedemname + '.pts',
65                                 project.coarsedemname + '.pts',
66                                 project.combineddemname + '.pts')
67'''
68
69#-------------------------------------------------------------------------------                                 
70# Create the triangular mesh based on overall clipping polygon with a tagged
71# boundary and interior regions defined in project.py along with
72# resolutions (maximal area of per triangle) for each polygon
73#-------------------------------------------------------------------------------
74
75from pmesh.create_mesh import create_mesh_from_regions
76
77# original
78interior_res = 5000
79interior_regions = [[project.poly_onslow, interior_res],
80                    [project.poly_thevenard, interior_res],
81                    [project.poly_direction, interior_res]]
82
83#FIXME: Fix caching of this one once the mesh_interface is ready
84from caching import cache
85_ = cache(create_mesh_from_regions,
86          project.polyAll,
87          {'boundary_tags': {'top': [0], 'topleft': [1],
88                             'left': [2], 'bottom': [3],
89                             'bottomright': [4], 'topright': [5]},
90           'resolution': 100000,
91           'filename': meshname,           
92           'interior_regions': interior_regions,
93           'UTM': True,
94           'refzone': project.refzone},
95          verbose = True)
96
97
98#-------------------------------------------------------------------------------                                 
99# Setup computational domain
100#-------------------------------------------------------------------------------                                 
101
102domain = pmesh_to_domain_instance(meshname, Domain,
103                                  use_cache = True,
104                                  verbose = True)
105
106print 'Number of triangles = ', len(domain)
107print 'The extent is ', domain.get_extent()
108
109domain.set_name(project.basename)
110domain.set_datadir(project.outputdir)
111domain.set_quantities_to_be_stored(['stage', 'xmomentum', 'ymomentum'])
112
113
114#-------------------------------------------------------------------------------
115# Set up scenario (tsunami_source is a callable object used with set_quantity)
116#-------------------------------------------------------------------------------
117'''
118tsunami_source = slump_tsunami(length=30000.0,
119                               depth=400.0,
120                               slope=6.0,
121                               thickness=176.0,
122                               radius=3330,
123                               dphi=0.23,
124                               x0=project.slump_origin[0],
125                               y0=project.slump_origin[1],
126                               alpha=0.0,
127                               domain=domain)
128
129'''
130#-------------------------------------------------------------------------------                                 
131# Setup initial conditions
132#-------------------------------------------------------------------------------
133
134domain.set_quantity('stage', 0.)
135domain.set_quantity('friction', 0.0) 
136domain.set_quantity('elevation', 
137#                    filename = project.combineddemname + '.pts',
138                    filename = project.coarsedemname + '.pts',
139                    use_cache = True,
140                    verbose = True
141                    )
142
143
144#-------------------------------------------------------------------------------                                 
145# Setup boundary conditions (all reflective)
146#-------------------------------------------------------------------------------
147
148print 'Available boundary tags', domain.get_boundary_tags()
149
150Br = Reflective_boundary(domain)
151# 10 min square wave starting at 1 min, 6m high
152Bw = Time_boundary(domain = domain,
153                   f=lambda t: [(50<t<800)*6, 0, 0])
154
155domain.set_boundary( {'top': Bw, 'topleft': Br,
156                             'left': Br, 'bottom': Br,
157                             'bottomright': Br, 'topright': Br} )
158
159
160#-------------------------------------------------------------------------------                                 
161# Evolve system through time
162#-------------------------------------------------------------------------------
163
164import time
165t0 = time.time()
166
167for t in domain.evolve(yieldstep = 50, finaltime = 5000): 
168    domain.write_time()
169    domain.write_boundary_statistics(tags = 'top')     
170   
171print 'That took %.2f seconds' %(time.time()-t0)
Note: See TracBrowser for help on using the repository browser.