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

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

(1) updates to Dampier script based on Perth script (2) minor updates to Onslow report

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