source: anuga_work/production/dampier_2006/run_dampier.py @ 4212

Last change on this file since 4212 was 4212, checked in by nick, 18 years ago

update to dampier

File size: 8.1 KB
Line 
1"""Script for running tsunami inundation scenario for Dampier, 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.output_run_time_dir
6
7The scenario is defined by a triangular mesh created from project.polygon,
8the elevation data and a simulated tsunami generated with URS code.
9
10Ole Nielsen and Duncan Gray, GA - 2005 and Jane Sexton, Nick Bartzis, GA - 2006
11"""
12
13#------------------------------------------------------------------------------
14# Import necessary modules
15#------------------------------------------------------------------------------
16
17# Standard modules
18from os import sep
19from os.path import dirname, basename
20from os import mkdir, access, F_OK
21from shutil import copy
22import time
23import sys
24
25# Related major packages
26from anuga.shallow_water import Domain
27from anuga.shallow_water import Dirichlet_boundary
28from anuga.shallow_water import File_boundary
29from anuga.shallow_water import Reflective_boundary
30from Numeric import allclose
31
32from anuga.pmesh.mesh_interface import create_mesh_from_regions
33from anuga.abstract_2d_finite_volumes.util import start_screen_catcher, copy_code_files
34from anuga_parallel.parallel_api import distribute, numprocs, myid, barrier
35
36# Application specific imports
37import project                 # Definition of file names and polygons
38
39#------------------------------------------------------------------------------
40# Copy scripts to time stamped output directory and capture screen
41# output to file
42#------------------------------------------------------------------------------
43
44start_screen_catcher(project.output_run_time_dir, myid, numprocs)
45
46# filenames
47#boundaries_name = project.boundaries_name
48meshes_dir_name = project.meshes_dir_name+'.msh'
49#boundaries_dir_name = project.boundaries_dir_name
50
51tide = project.tide
52
53# creates copy of code in output dir
54if myid == 0:
55    copy_code_files(project.output_run_time_dir,__file__, 
56                 dirname(project.__file__)+sep+ project.__name__+'.py' )
57barrier()
58
59print 'USER: ', project.user
60print 'min triangles', project.trigs_min,
61print 'Note: This is generally about 20% less than the final amount'
62
63#--------------------------------------------------------------------------
64# Create the triangular mesh based on overall clipping polygon with a
65# tagged
66# boundary and interior regions defined in project.py along with
67# resolutions (maximal area of per triangle) for each polygon
68#--------------------------------------------------------------------------
69'''
70poly = [[0,0],[0,100],[100,100],[100,0]]
71
72create_mesh_from_regions(poly,
73                             boundary_tags={'back': [0], 'side': [1,3],
74                                            'ocean': [2]},
75                             maximum_triangle_area=1,
76                             interior_regions=None,
77                             filename=meshes_dir_name,
78                             use_cache=True,
79                             verbose=True)
80
81sys.exit()
82'''
83if myid == 0:
84   
85    print 'start create mesh from regions'
86    create_mesh_from_regions(project.poly_all,
87                             boundary_tags={'back': [2,3], 'side': [0, 1, 4],
88                                            'ocean': [5]},
89                             maximum_triangle_area=project.res_poly_all,
90                             interior_regions=project.interior_regions,
91                             filename=meshes_dir_name,
92                             use_cache=True,
93                             verbose=True)
94
95# to sync all processors are ready
96barrier()
97
98#-------------------------------------------------------------------------
99# Setup computational domain
100#-------------------------------------------------------------------------
101print 'Setup computational domain'
102domain = Domain(meshes_dir_name, use_cache=True, verbose=True)
103print domain.statistics()
104boundaries_dir_name=project.boundaries_dir_name
105
106print 'starting to create boundary conditions'
107
108from anuga.shallow_water.data_manager import urs2sww
109
110# put above distribute
111print 'boundary file is: ',project.boundaries_dir_name
112from caching import cache
113if myid == 0:
114    cache(urs2sww,
115          (project.boundaries_in_dir_name,
116           project.boundaries_dir_name), 
117          {'verbose': True,
118           'minlat': project.south_boundary,
119           'maxlat': project.north_boundary,
120           'minlon': project.west_boundary,
121           'maxlon': project.east_boundary,
122           'mint': 0, 'maxt': 35100,
123           'origin': domain.geo_reference.get_origin(),
124           'mean_stage': project.tide,
125#           'zscale': 1,                 #Enhance tsunami
126           'fail_on_NaN': False},
127           verbose = True,
128           )
129barrier()
130
131
132#-------------------------------------------------------------------------
133# Setup initial conditions
134#-------------------------------------------------------------------------
135if myid == 0:
136
137    print 'Setup initial conditions'
138
139    from polygon import *
140    #following sets the stage/water to be offcoast only
141    IC = Polygon_function( [(project.poly_bathy, 0.)], default = tide)
142    domain.set_quantity('stage', IC)
143    domain.set_quantity('friction', 0.01) 
144    print 'Start Set quantity'
145
146    domain.set_quantity('elevation', 
147#                    filename = project.combined_dir_name + '.pts',
148# MUST USE TXT FILES FOR CACHING TO WORK!
149                    filename = project.combined_dir_name + '.txt',
150                    use_cache = True,
151                    verbose = True,
152                    alpha = 0.1)
153    print 'Finished Set quantity'
154barrier()
155
156
157#------------------------------------------------------
158# Distribute domain to implement parallelism !!!
159#------------------------------------------------------
160
161if numprocs > 1:
162    domain=distribute(domain)
163
164#------------------------------------------------------
165# Set domain parameters
166#------------------------------------------------------
167
168domain.set_name(project.scenario_name)
169domain.set_datadir(project.output_run_time_dir)
170domain.set_default_order(2) # Apply second order scheme
171domain.set_minimum_storable_height(0.01) # Don't store anything less than 1cm
172domain.set_store_vertices_uniquely(False)
173domain.set_quantities_to_be_stored(['stage', 'xmomentum', 'ymomentum'])
174domain.set_maximum_allowed_speed(0.1) # Allow a little runoff (0.1 is OK)
175
176#-------------------------------------------------------------------------
177# Setup boundary conditions
178#-------------------------------------------------------------------------
179print 'Available boundary tags', domain.get_boundary_tags()
180print 'domain id', id(domain)
181print 'Reading Boundary file'
182Bf = File_boundary(boundaries_dir_name + '.sww',
183                  domain, time_thinning=1, use_cache=True, verbose=True)
184
185print 'finished reading boundary file'
186
187Br = Reflective_boundary(domain)
188Bd = Dirichlet_boundary([tide,0,0])
189
190print'set_boundary'
191##domain.set_boundary({'back': Br,
192##                     'side': Bf,
193##                     'ocean': Bf})
194domain.set_boundary({'back': Br,
195                     'side': Bd,
196                     'ocean': Bf}) 
197print'finish set boundary'
198
199#----------------------------------------------------------------------------
200# Evolve system through time
201#----------------------------------------------------------------------------
202
203t0 = time.time()
204
205for t in domain.evolve(yieldstep = 120, finaltime = 9000):
206    domain.write_time()
207    domain.write_boundary_statistics(tags = 'ocean')
208
209#for t in domain.evolve(yieldstep = 120, finaltime = 9000):
210#    domain.write_time()
211#    domain.write_boundary_statistics(tags = 'ocean')
212     
213for t in domain.evolve(yieldstep = 60, finaltime = 28800
214                       ,skip_initial_step = True):
215    domain.write_time()
216    domain.write_boundary_statistics(tags = 'ocean')   
217
218for t in domain.evolve(yieldstep = 120, finaltime = 34800
219                       ,skip_initial_step = True): 
220    domain.write_time()
221    domain.write_boundary_statistics(tags = 'ocean')   
222
223x, y = domain.get_maximum_inundation_location()
224q = domain.get_maximum_inundation_elevation()
225
226print 'Maximum runup observed at (%.2f, %.2f) with elevation %.2f' %(x,y,q)
227
228print 'That took %.2f seconds' %(time.time()-t0)
229
Note: See TracBrowser for help on using the repository browser.