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

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

updates to dampier

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