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

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

updates to dampier

File size: 10.0 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 submarine landslide.
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
26# Related major packages
27from anuga.shallow_water import Domain
28from anuga.shallow_water import Dirichlet_boundary
29from anuga.shallow_water import File_boundary
30from anuga.shallow_water import Reflective_boundary
31from Numeric import allclose
32
33from anuga.pmesh.mesh_interface import create_mesh_from_regions
34
35from anuga.geospatial_data.geospatial_data import *
36from anuga.abstract_2d_finite_volumes.util import start_screen_catcher, copy_code_files
37from anuga_parallel.parallel_api import distribute, numprocs, myid, barrier
38
39# Application specific imports
40import project                 # Definition of file names and polygons
41
42#------------------------------------------------------------------------------
43# Copy scripts to time stamped output directory and capture screen
44# output to file
45#------------------------------------------------------------------------------
46
47
48# filenames
49
50#build_time = '20061029_231935_build_tide_24'
51#build_time = '20061030_165746_build_tide_24'
52#build_time = '20061102_215532_build_plus_old_data'
53#build_time = '20061103_055258_build'
54build_time = '20061107_063840_build'
55#build_time = '20061025_153643_build_basic'
56bound_time = '20061102_221245_build'
57
58boundaries_name = project.boundaries_name
59#meshes_time_dir_name = project.meshes_time_dir_name+'.msh'
60meshes_dir_name = project.meshes_dir_name+'.msh'
61#source_dir = project.boundarydir
62#boundaries_time_dir_name = project.boundaries_dir + build_time + sep + boundaries_name
63boundaries_time_dir_name = project.boundaries_time_dir_name
64boundaries_dir_name = project.boundaries_dir_name
65tide = project.tide
66
67# creates copy of code in output dir
68if myid == 0:
69    copy_code_files(project.output_run_time_dir,__file__, 
70                 dirname(project.__file__)+sep+ project.__name__+'.py' )
71barrier()
72#start_screen_catcher(project.output_run_time_dir, myid, numprocs)
73
74print 'USER: ', project.user
75#sys.exit()
76#--------------------------------------------------------------------------
77# Create the triangular mesh based on overall clipping polygon with a
78# tagged
79# boundary and interior regions defined in project.py along with
80# resolutions (maximal area of per triangle) for each polygon
81#--------------------------------------------------------------------------
82
83if myid == 0:
84   
85    print 'start create mesh from regions'
86    interior_regions = [#[project.karratha_polygon, 25000],
87                    [project.poly_coast, 10000],
88                    [project.poly_pipeline, 2000],
89                    [project.poly_facility, 500]]   
90#                    [project.poly_interior, 1000]]       
91    from anuga.utilities.polygon import plot_polygons
92    figname = project.output_run_time_dir + 'poly_pic'
93    plot_polygons([project.poly_coast,project.poly_pipeline,project.poly_facility,
94               project.bounding_polygon],
95               figname,
96               verbose = True)
97#    if access(project.meshes_time_dir,F_OK) == 0:
98#        mkdir(project.meshes_time_dir)
99#    if access(project.meshes_dir,F_OK) == 0:
100#        mkdir(project.meshes_dir)
101    import sys; sys.exit()
102    print 'start create mesh from regions'
103    interior_regions = [#[project.karratha_polygon, 25000],
104#                    [project.cipma_polygon, 1000],
105#                    [project.poly_pipeline, 5000],
106#                    [project.poly_facility, 500]]   
107                    [project.poly_interior, 1000]]   
108#    meshes_dir_name = project.meshes_dir_name + '.msh'
109
110    create_mesh_from_regions(project.bounding_polygon,
111                         boundary_tags={'back': [7, 8], 'side': [0, 6],
112                                        'ocean': [1, 2, 3, 4, 5]},
113                         maximum_triangle_area=100000,
114                         interior_regions=interior_regions,
115#                         filename=meshes_time_dir_name,
116                         filename=meshes_dir_name,
117                         use_cache=True,
118                         verbose=True)
119
120# to sync all processors are ready
121barrier()
122
123#-------------------------------------------------------------------------
124# Setup computational domain
125#-------------------------------------------------------------------------
126print 'Setup computational domain'
127#domain = Domain(meshes_time_dir_name, use_cache=True, verbose=True)
128domain = Domain(meshes_dir_name, use_cache=True, verbose=True)
129print domain.statistics()
130
131print 'starting to create boundary conditions'
132boundaries_in_dir_name = project.boundaries_in_dir_name
133
134from anuga.shallow_water.data_manager import urs2sww, ferret2sww
135
136print 'maxlat=project.south_boundary, minlat=project.north_boundary', project.south_boundary,project.north_boundary
137print 'minlon= project.west_boundary, maxlon=project.east_boundary',project.west_boundary, project.east_boundary
138print ' maxlon=project.east',project.east
139
140print 'origin: domain.geo_reference.get_origin()',domain.geo_reference.get_origin()
141
142#import sys; sys.exit()
143
144#if access(project.boundaries_time_dir,F_OK) == 0:
145#    mkdir (project.boundaries_time_dir)
146# put above distribute
147print 'boundary file is: ',boundaries_dir_name
148from caching import cache
149if myid == 0:
150    cache(ferret2sww,
151          (boundaries_in_dir_name,
152    #       boundaries_time_dir_name),
153           boundaries_dir_name), 
154          {'verbose': True,
155           'minlat': project.south_boundary,
156           'maxlat': project.north_boundary,
157           'minlon': project.west_boundary,
158           'maxlon': project.east_boundary,
159#           'minlat': project.south,
160#           'maxlat': project.north,
161#           'minlon': project.west,
162#           'maxlon': project.east,
163           'mint': 0, 'maxt': 35100,
164           'origin': domain.geo_reference.get_origin(),
165           'mean_stage': project.tide,
166#           'zscale': 1,                 #Enhance tsunami
167           'fail_on_NaN': False},
168           verbose = True,
169           )
170barrier()
171
172
173#-------------------------------------------------------------------------
174# Setup initial conditions
175#-------------------------------------------------------------------------
176if myid == 0:
177
178    print 'Setup initial conditions'
179
180    domain.set_quantity('stage', tide)
181    domain.set_quantity('friction', 0.0) 
182    #combined_time_dir_name = project.topographies_dir+build_time+project.combined_name
183    print 'Start Set quantity'
184
185
186    domain.set_quantity('elevation', 
187                    filename = project.topographies_dir + build_time + sep + project.combined_final_name + '.pts',
188                    use_cache = True,
189                    verbose = True,
190                    alpha = 0.1)
191    #domain.set_quantity('elevation', -50)
192    print 'Finished Set quantity'
193barrier()
194
195
196#------------------------------------------------------
197# Distribute domain to implement parallelism !!!
198#------------------------------------------------------
199
200if numprocs > 1:
201    domain=distribute(domain)
202
203#------------------------------------------------------
204# Set domain parameters
205#------------------------------------------------------
206
207domain.set_name(project.scenario_name)
208domain.set_datadir(project.output_run_time_dir)
209domain.set_default_order(2) # Apply second order scheme
210domain.set_minimum_storable_height(0.01) # Don't store anything less than 1cm
211domain.set_store_vertices_uniquely(False)
212domain.set_quantities_to_be_stored(['stage', 'xmomentum', 'ymomentum'])
213domain.set_maximum_allowed_speed(0.0) # Allow a little runoff (0.1 is OK)
214
215#-------------------------------------------------------------------------
216# Setup boundary conditions
217#-------------------------------------------------------------------------
218print 'Available boundary tags', domain.get_boundary_tags()
219
220print 'Reading Boundary file'
221#boundariesname = project.boundaries_dir + '20061101_003322_build'+sep+boundaries_name
222#print'boundariesname',boundariesname
223#Bf = File_boundary(boundaries_time_dir_name + '.sww',
224
225#Bf = File_boundary(boundariesname + '.sww',
226
227print 'domain id', id(domain)
228Bf = File_boundary(boundaries_dir_name + '.sww',
229                  domain, time_thinning=5, use_cache=True, verbose=True)
230
231print 'finished reading boundary file'
232
233Br = Reflective_boundary(domain)
234Bd = Dirichlet_boundary([tide,0,0])
235
236print'set_boundary'
237domain.set_boundary({'back': Br,
238                     'side': Bd,
239                     'ocean': Bf}) 
240print'finish set boundary'
241
242#----------------------------------------------------------------------------
243# Evolve system through time
244#----------------------------------------------------------------------------
245
246t0 = time.time()
247
248#for t in domain.evolve(yieldstep = 60, finaltime = 34000):
249#    domain.write_time()
250#    domain.write_boundary_statistics(tags = 'ocean')
251
252for t in domain.evolve(yieldstep = 120, finaltime = 9000):
253    domain.write_time()
254    domain.write_boundary_statistics(tags = 'ocean')
255#    print 'time: ',time.time()
256 
257    if allclose(t, 6000):
258        domain.set_quantity('xmomentum', 0)
259        domain.set_quantity('ymomentum', 0)
260#import sys; sys.exit()
261     
262for t in domain.evolve(yieldstep = 60, finaltime = 28800
263                       ,skip_initial_step = True):
264    domain.write_time()
265    domain.write_boundary_statistics(tags = 'ocean')   
266
267for t in domain.evolve(yieldstep = 120, finaltime = 34800
268                       ,skip_initial_step = True): 
269    domain.write_time()
270    domain.write_boundary_statistics(tags = 'ocean')   
271   
272print 'That took %.2f seconds' %(time.time()-t0)
273
Note: See TracBrowser for help on using the repository browser.