source: anuga_work/production/newcastle_2006/run_newcastle_slide.py @ 4058

Last change on this file since 4058 was 4058, checked in by sexton, 17 years ago

updates for all slide scenarios

File size: 7.6 KB
Line 
1"""Script for running a tsunami inundation scenario for Newcastle, 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.outputtimedir
6
7The scenario is defined by a triangular mesh created from project.polygon,
8the elevation data and a tsunami wave generated by s submarine mass failure.
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
20from shutil import copy
21from os.path import dirname, basename
22from os import mkdir, access, F_OK, sep
23import sys
24
25# Related major packages
26from anuga.shallow_water import Domain, Reflective_boundary, Dirichlet_boundary
27from anuga.shallow_water.data_manager import convert_dem_from_ascii2netcdf, dem2pts
28from anuga.geospatial_data.geospatial_data import *
29from anuga.abstract_2d_finite_volumes.util import start_screen_catcher, copy_code_files
30
31# Application specific imports
32import project_slide              # Definition of file names and polygons
33
34#-------------------------------------------------------------------------------
35# Copy scripts to time stamped output directory and capture screen
36# output to file
37#-------------------------------------------------------------------------------
38
39# creates copy of code in output dir
40copy_code_files(project.outputtimedir,__file__,dirname(project.__file__)+sep+ project.__name__+'.py' )
41myid = 0
42numprocs = 1
43start_screen_catcher(project.outputtimedir, myid, numprocs)
44
45print 'USER:    ', project.user
46
47#-------------------------------------------------------------------------------
48# Preparation of topographic data
49#
50# Convert ASC 2 DEM 2 PTS using source data and store result in source data
51#-------------------------------------------------------------------------------
52
53# filenames
54nsw_dem_name = project_slide.nsw_dem_name
55meshname = project_slide.meshname+'.msh'
56
57# creates DEM from asc data
58convert_dem_from_ascii2netcdf(nsw_dem_name, use_cache=True, verbose=True)
59
60#creates pts file for onshore DEM
61dem2pts(nsw_dem_name,
62        easting_min=project_slide.eastingmin_nsw,
63        easting_max=project_slide.eastingmax_nsw,
64        northing_min=project_slide.northingmin_nsw,
65        northing_max= project_slide.northingmax_nsw,
66        use_cache=True, verbose=True)
67
68print 'create offshore'
69G11 = Geospatial_data(file_name = project_slide.offshore_dem_name2 + '.xya')+\
70      Geospatial_data(file_name = project_slide.offshore_dem_name3 + '.xya')
71G12 = Geospatial_data(file_name = project_slide.offshore_dem_name4 + '.xya')+\
72      Geospatial_data(file_name = project_slide.offshore_dem_name5 + '.xya')+\
73      Geospatial_data(file_name = project_slide.offshore_dem_name6 + '.xya')+\
74      Geospatial_data(file_name = project_slide.offshore_dem_name7 + '.xya')+\
75      Geospatial_data(file_name = project_slide.offshore_dem_name8 + '.xya')+\
76      Geospatial_data(file_name = project_slide.offshore_dem_name9 + '.xya')
77print 'create onshore'
78G4 = Geospatial_data(file_name = project_slide.nsw_dem_name + '.pts')
79print 'add'
80G = G11.clip(Geospatial_data(project_slide.poly_surveyclip)) +\
81    G12.clip(Geospatial_data(project_slide.polyAll))
82    (G4.clip(Geospatial_data(project_slide.polyAll))).clip_outside(Geospatial_data(project_slide.poly_surveyclip))
83print 'export points'
84G.export_points_file(project_slide.combined_dem_name + '.pts')
85#G.export_points_file(project_slide.combined_dem_name + '.xya')
86
87
88#----------------------------------------------------------------------------
89# Create the triangular mesh based on overall clipping polygon with a tagged
90# boundary and interior regions defined in project.py along with
91# resolutions (maximal area of per triangle) for each polygon
92#-------------------------------------------------------------------------------
93
94from anuga.pmesh.mesh_interface import create_mesh_from_regions
95remainder_res = 500000
96local_res = 25000
97newcastle_res = 5000
98coast_res = 500
99interior_regions = [[project.poly_newcastle1, local_res],
100                    [project.poly_newcastle2, newcastle_res],
101                    [project.poly_newcastle3, coast_res]]
102
103from caching import cache
104_ = cache(create_mesh_from_regions,
105          project.polyAll,
106           {'boundary_tags': {'e0': [0], 'e1': [1], 'e2': [2],
107                              'e3': [3], 'e4':[4], 'e5': [5],
108                              'e6': [6]},
109           'maximum_triangle_area': remainder_res,
110           'filename': meshname,
111           'interior_regions': interior_regions},
112          verbose = True, evaluate=False)
113print 'created mesh'
114
115#-------------------------------------------------------------------------------                                 
116# Setup computational domain
117#-------------------------------------------------------------------------------                                 
118domain = Domain(meshname, use_cache = True, verbose = True)
119
120print 'Number of triangles = ', len(domain)
121print 'The extent is ', domain.get_extent()
122print domain.statistics()
123
124domain.set_name(project.basename)
125domain.set_datadir(project.outputtimedir)
126domain.set_quantities_to_be_stored(['stage', 'xmomentum', 'ymomentum'])
127domain.set_minimum_storable_height(0.01)
128
129#-------------------------------------------------------------------------------                                 
130# Setup initial conditions
131#-------------------------------------------------------------------------------
132
133tide = 0.0
134domain.set_quantity('stage', tide)
135domain.set_quantity('friction', 0.0) 
136domain.set_quantity('elevation', 
137                    filename = project.combined_dem_name + '.pts',
138                    use_cache = True,
139                    verbose = True,
140                    alpha = 0.1
141                    )
142
143#-------------------------------------------------------------------------------
144# Set up scenario (tsunami_source is a callable object used with set_quantity)
145#-------------------------------------------------------------------------------
146from smf import slide_tsunami
147
148tsunami_source = slide_tsunami(length=30000.0,
149                               depth=400.0,
150                               slope=6.0,
151                               thickness=176.0, 
152                               radius=3330,
153                               dphi=0.23,
154                               x0=project.slump_origin[0], 
155                               y0=project.slump_origin[1], 
156                               alpha=0.0, 
157                               domain=domain)
158
159#-------------------------------------------------------------------------------                                 
160# Setup boundary conditions
161#-------------------------------------------------------------------------------
162print 'Available boundary tags', domain.get_boundary_tags()
163
164Br = Reflective_boundary(domain)
165Bd = Dirichlet_boundary([tide,0,0])
166
167domain.set_boundary( {'e0': Bd,  'e1': Bd, 'e2': Bd, 'e3': Bd, 'e4': Bd,
168                      'e5': Bd,  'e6': Bd} )
169
170
171#-------------------------------------------------------------------------------                                 
172# Evolve system through time
173#-------------------------------------------------------------------------------
174import time
175t0 = time.time()
176
177for t in domain.evolve(yieldstep = 30, finaltime = 480): 
178    domain.write_time()
179    domain.write_boundary_statistics(tags = 'e14')
180    stagestep = domain.get_quantity('stage') 
181
182    if allclose(t, 30):
183        slide = Quantity(domain)
184        slide.set_values(tsunami_source)
185        domain.set_quantity('stage', slide + stagestep)
186   
187print 'That took %.2f seconds' %(time.time()-t0)
188
189print 'finished'
Note: See TracBrowser for help on using the repository browser.