source: anuga_work/production/MOST_example/run_pt_hedland.py @ 4631

Last change on this file since 4631 was 3609, checked in by duncan, 18 years ago

comments

File size: 8.4 KB
Line 
1"""Script for running a tsunami inundation scenario for Onslow, WA, Australia.
2
3 Boundary data is assumed to be in this directory.
4Move the SU-AU_clip_blahblah.nc files into this directory, from teh pt_hedland
5data directory.
6
7The file cripple_pts_file creates the elevation file
8pt_hedland_combined_elevation_31204.pts, from
9pt_hedland_combined_elevation.pts - which is created by the other
10run_pt_hedland script.
11 
12directories specified by project.py
13The output sww file is stored in project.outputtimedir
14
15The scenario is defined by a triangular mesh created from project.polygon,
16the elevation data and a simulated submarine landslide.
17
18Use shallow_water.most2nc to create the SU-AU_clip_e.nc file.
19
20Ole Nielsen, Duncan Gray and Nick Bartzis, GA - 2005,2006
21"""
22#-------------------------------------------------------------------------------# Import necessary modules
23#-------------------------------------------------------------------------------
24
25# Standard modules
26from os import sep
27from os.path import dirname, basename
28import time
29
30# Related major packages
31from anuga.shallow_water import Domain, Reflective_boundary, \
32                            Dirichlet_boundary, Time_boundary, File_boundary
33from anuga.shallow_water.data_manager import convert_dem_from_ascii2netcdf, \
34     dem2pts, ferret2sww
35from shutil import copy
36from os import mkdir, access, F_OK
37from anuga.geospatial_data.geospatial_data import *
38import sys
39from anuga.abstract_2d_finite_volumes.util import Screen_Catcher
40
41from anuga.fit_interpolate.fit import fit_to_mesh_file
42
43# Application specific imports
44import project                 # Definition of file names and polygons
45
46#-------------------------------------------------------------------------------
47# Copy scripts to time stamped output directory and capture screen
48# output to file
49#-------------------------------------------------------------------------------
50
51# creates copy of code in output dir if dir doesn't exist
52if access(project.outputtimedir,F_OK) == 0 :
53    mkdir (project.outputtimedir)
54copy (dirname(project.__file__) +sep+ project.__name__+'.py', project.outputtimedir + project.__name__+'.py')
55copy (__file__, project.outputtimedir + basename(__file__))
56print 'project.outputtimedir',project.outputtimedir
57
58# normal screen output is stored in
59#screen_output_name = project.outputtimedir + "screen_output.txt"
60#screen_error_name = project.outputtimedir + "screen_error.txt"
61
62# used to catch screen output to file
63#sys.stdout = Screen_Catcher(screen_output_name)
64#sys.stderr = Screen_Catcher(screen_error_name)
65print 'USER:    ', project.user
66
67#-------------------------------------------------------------------------------
68# Preparation of topographic data
69#
70# Convert ASC 2 DEM 2 PTS using source data and store result in source data
71# Do for coarse and fine data
72# Fine pts file to be clipped to area of interest
73#-------------------------------------------------------------------------------
74
75# filenames
76meshname = project.meshname + '.tsh'
77mesh_elevname = project.mesh_elevname  + '.tsh'
78source_dir = project.boundarydir
79
80
81#-------------------------------------------------------------------------------                                 
82# Create the triangular mesh based on overall clipping polygon with a tagged
83# boundary and interior regions defined in project.py along with
84# resolutions (maximal area of per triangle) for each polygon
85#-------------------------------------------------------------------------------
86
87from anuga.pmesh.mesh_interface import create_mesh_from_regions
88
89region_res = 5000000
90coast_res = 500000
91pt_hedland_res = 500000
92interior_regions = [[project.poly_pt_hedland, pt_hedland_res],
93                    [project.poly_region, region_res]]
94
95print 'number of interior regions', len(interior_regions)
96
97print 'start create mesh from regions'
98from caching import cache
99_ = cache(create_mesh_from_regions,
100          project.polyAll,
101          {'boundary_tags': {'topright': [0], 'topleft': [1],
102                             'left': [2], 'bottom0': [3],
103                             'bottom1': [4], 'bottom2': [5],
104                             'bottom3': [6], 'right': [7]},
105           'maximum_triangle_area': 5000000,
106           'filename': meshname,           
107           'interior_regions': interior_regions},
108          verbose = True
109          #, evaluate=True
110          )
111
112cache(fit_to_mesh_file,(meshname,
113                 'pt_hedland_combined_elevation_31204' + '.pts',
114                 mesh_elevname),
115      {'verbose': True}
116      #,evaluate = True     
117      ,verbose = False
118      )
119#-------------------------------------------------------------------------------                                 
120# Setup computational domain
121#-------------------------------------------------------------------------------                                 
122domain = Domain(mesh_elevname, use_cache = False, verbose = True)
123
124print domain.statistics()
125print 'Number of triangles = ', len(domain)
126print 'The extent is ', domain.get_extent()
127print domain.statistics()
128
129domain.set_name(project.basename)
130domain.set_datadir(project.outputtimedir)
131domain.set_quantities_to_be_stored(['stage', 'xmomentum', 'ymomentum'])
132
133#-------------------------------------------------------------------------------                                 
134# Setup initial conditions
135#-------------------------------------------------------------------------------
136
137tide = 0.
138#high
139#tide = 3.6
140#low
141#tide = -3.9
142
143domain.set_quantity('stage', tide)
144domain.set_quantity('friction', 0.0) 
145print 'hi and file',project.combined_dem_name + '.pts'
146
147#domain.set_quantity('elevation',
148#                    filename = project.combined_dem_name + '.pts',
149#                    use_cache = True,
150#                    verbose = True,
151#                    alpha = 0.1
152 #                   )
153
154#-------------------------------------------------------------------------------                                 
155# Setup boundary conditions (all reflective)
156#-------------------------------------------------------------------------------
157print 'start ferret2sww'
158# skipped as results in file SU-AU_clipped is correct for all WA
159
160
161south = project.south
162north = project.north
163west = project.west
164east = project.east
165
166#note only need to do when an SWW file for the MOST boundary doesn't exist
167cache(ferret2sww,
168      (project.boundary_basename,
169       project.boundary_basename+'_'+project.basename), 
170      {'verbose': True,
171       'minlat': south,
172       'maxlat': north,
173       'minlon': west,
174       'maxlon': east,
175#       'origin': project.mesh_origin,
176       'origin': domain.geo_reference.get_origin(),
177       'mean_stage': tide,
178       'zscale': 10,                 #Enhance tsunami
179       'fail_on_NaN': False,
180       'inverted_bathymetry': True},
181       #evaluate = True,
182       verbose = True,
183      dependencies = source_dir + project.boundary_basename + '.sww')
184
185print 'Available boundary tags', domain.get_boundary_tags()
186
187Bf = File_boundary(project.boundary_basename+'_'+project.basename + '.sww', 
188                    domain, verbose = True)
189Br = Reflective_boundary(domain)
190Bd = Dirichlet_boundary([tide,0,0])
191domain.set_boundary( {'topright': Bf,'topleft': Bf, 'left':  Bd, 'bottom0': Bd,
192                      'bottom1': Bd, 'bottom2': Bd, 'bottom3': Bd, 
193                        'right': Bd})
194
195#-------------------------------------------------------------------------------                                 
196# Evolve system through time
197#-------------------------------------------------------------------------------
198import time
199t0 = time.time()
200
201for t in domain.evolve(yieldstep = 240, finaltime = 10800): 
202    domain.write_time()
203    domain.write_boundary_statistics(tags = 'topright')     
204
205for t in domain.evolve(yieldstep = 120, finaltime = 16200
206                       ,skip_initial_step = True): 
207    domain.write_time()
208    domain.write_boundary_statistics(tags = 'topright')     
209
210for t in domain.evolve(yieldstep = 60, finaltime = 21600
211                       ,skip_initial_step = True): 
212    domain.write_time()
213    domain.write_boundary_statistics(tags = 'topright')     
214   
215for t in domain.evolve(yieldstep = 120, finaltime = 27000
216                       ,skip_initial_step = True): 
217    domain.write_time()
218    domain.write_boundary_statistics(tags = 'topright')     
219
220for t in domain.evolve(yieldstep = 240, finaltime = 36000
221                       ,skip_initial_step = True): 
222    domain.write_time()
223    domain.write_boundary_statistics(tags = 'topright')   
224 
225print 'That took %.2f seconds' %(time.time()-t0)
226
227print 'finished'
Note: See TracBrowser for help on using the repository browser.