source: anuga_work/production/broome_2006/run_broome.py @ 4429

Last change on this file since 4429 was 4429, checked in by nick, 17 years ago

update broome

File size: 7.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, mkdir, access, F_OK
19from os.path import dirname, basename
20from shutil import copy
21import time
22import sys
23
24# Related major packages
25from anuga.shallow_water import Domain
26from anuga.shallow_water import Dirichlet_boundary, File_boundary, Reflective_boundary
27from anuga.shallow_water import Field_boundary
28from Numeric import allclose
29from anuga.pmesh.mesh_interface import create_mesh_from_regions
30from anuga.geospatial_data.geospatial_data import *
31from anuga.abstract_2d_finite_volumes.util import start_screen_catcher, copy_code_files
32from anuga_parallel.parallel_api import distribute, numprocs, myid, barrier
33from anuga.utilities.polygon import plot_polygons, polygon_area
34from anuga_parallel.parallel_abstraction import get_processor_name
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
44if myid == 0:
45    copy_code_files(project.output_run_time_dir,__file__, 
46                 dirname(project.__file__)+sep+ project.__name__+'.py' )
47barrier()
48
49start_screen_catcher(project.output_run_time_dir, myid, numprocs)
50
51# filenames
52boundaries_name = project.scenario
53meshes_dir_name = project.meshes_dir_name+'.msh'
54boundaries_dir_name = project.boundaries_dir_name
55
56tide = project.tide
57
58# creates copy of code in output dir
59print "Processor Name:",get_processor_name()
60
61print 'USER: ', project.user
62print 'min triangles', project.trigs_min,
63print 'Note: This is generally about 20% less than the final amount'
64
65#--------------------------------------------------------------------------
66# Create the triangular mesh based on overall clipping polygon with a
67# tagged
68# boundary and interior regions defined in project.py along with
69# resolutions (maximal area of per triangle) for each polygon
70#--------------------------------------------------------------------------
71
72if myid == 0:     
73
74    print 'start create mesh from regions'
75    create_mesh_from_regions(project.poly_all,
76#                         boundary_tags={'back': [1, 2], 'side': [0,3],
77#                                        'ocean': [4, 5, 6]},
78                         boundary_tags={'back': [1, 2], 'side': [0,3],
79                                        'ocean': [4]},
80                         maximum_triangle_area=project.res_poly_all,
81                         interior_regions=project.interior_regions,
82                         filename=meshes_dir_name,
83                         use_cache=False,
84                         verbose=True)
85
86# to sync all processors are ready
87barrier()
88
89#-------------------------------------------------------------------------
90# Setup computational domain
91#-------------------------------------------------------------------------
92print 'Setup computational domain'
93#domain = Domain(meshes_time_dir_name, use_cache=True, verbose=True)
94domain = Domain(meshes_dir_name, use_cache=False, verbose=True)
95print domain.statistics()
96
97#-------------------------------------------------------------------------
98# Setup initial conditions
99#-------------------------------------------------------------------------
100if myid == 0:
101
102    print 'Setup initial conditions'
103
104    from polygon import Polygon_function
105    #following sets the stage/water to be offcoast only
106    IC = Polygon_function( [(project.poly_mainland, -1.0)], default = tide,
107                             geo_reference = domain.geo_reference)
108    domain.set_quantity('stage', IC)
109    #combined_time_dir_name = project.topographies_dir+build_time+project.combined_name
110    print 'Start Set quantity'
111    print 'project.combined_dir_name_unclipped1',project.combined_dir_name_unclipped1+'.txt'
112    domain.set_quantity('elevation', 
113#                    filename = project.combined_dir_name+'.txt',
114                    filename = project.combined_dir_name_unclipped1+'.txt',
115#                    filename = project.combined_smaller_name_dir+'.xya',
116                    use_cache = True,
117                    verbose = True,
118                    alpha = 0.1)
119    print 'Finished Set quantity'
120barrier()
121
122#------------------------------------------------------
123# Distribute domain to implement parallelism !!!
124#------------------------------------------------------
125
126if numprocs > 1:
127    domain=distribute(domain)
128
129#------------------------------------------------------
130# Set domain parameters
131#------------------------------------------------------
132
133domain.set_name(project.scenario_name)
134domain.set_datadir(project.output_run_time_dir)
135domain.set_default_order(2) # Apply second order scheme
136domain.set_minimum_storable_height(0.01) # Don't store anything less than 1cm
137domain.set_store_vertices_uniquely(False)
138domain.set_quantities_to_be_stored(['stage', 'xmomentum', 'ymomentum'])
139domain.set_maximum_allowed_speed(0.1) # Allow a little runoff (0.1 is OK)
140
141#-------------------------------------------------------------------------
142# Setup boundary conditions
143#-------------------------------------------------------------------------
144print 'Available boundary tags', domain.get_boundary_tags()
145
146print 'Reading Boundary file'
147print 'domain id', id(domain)
148#Bf = File_boundary(boundaries_dir_name + '.sww',
149#                  domain, time_thinning=12, use_cache=True, verbose=True)
150Bf = Field_boundary(boundaries_dir_name + '.sww',
151                  domain, time_thinning=1, mean_stage=tide, 
152                  use_cache=True, verbose=True)
153
154print 'finished reading boundary file'
155Br = Reflective_boundary(domain)
156Bd = Dirichlet_boundary([tide,0,0])
157Bo = Dirichlet_boundary([tide+5.0,0,0])
158
159print'set_boundary'
160domain.set_boundary({'back': Br,
161                     'side': Bd,
162                     'ocean': Bf}) 
163#                     'ocean': Bd})
164print'finish set boundary'
165
166#----------------------------------------------------------------------------
167# Evolve system through time
168#----------------------------------------------------------------------------
169
170t0 = time.time()
171
172for t in domain.evolve(yieldstep = 60, finaltime = 30000):
173    domain.write_time()
174    domain.write_boundary_statistics(tags = 'ocean')
175#    if allclose(t, 120):
176#        domain.set_boundary({'back': Br, 'side': Bd, 'ocean': Bo})
177
178#    if allclose(t, 1020):
179#        domain.set_boundary({'back': Br, 'side': Bd, 'ocean': Bd})
180
181   
182print 'That took %.2f seconds' %(time.time()-t0)
183
Note: See TracBrowser for help on using the repository browser.