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

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

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

File size: 7.5 KB
RevLine 
[3800]1"""Script for running tsunami inundation scenario for Dampier, WA, Australia.
[3627]2
3Source data such as elevation and boundary data is assumed to be available in
4directories specified by project.py
[3851]5The output sww file is stored in project.output_run_time_dir
[3627]6
7The scenario is defined by a triangular mesh created from project.polygon,
[4147]8the elevation data and a simulated tsunami generated with URS code.
[3627]9
[3631]10Ole Nielsen and Duncan Gray, GA - 2005 and Jane Sexton, Nick Bartzis, GA - 2006
[3627]11"""
[3713]12
[3627]13#------------------------------------------------------------------------------
14# Import necessary modules
15#------------------------------------------------------------------------------
16
17# Standard modules
18from os import sep
19from os.path import dirname, basename
[3631]20from os import mkdir, access, F_OK
21from shutil import copy
[3627]22import time
[3631]23import sys
[3627]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
[4049]30from Numeric import allclose
[3627]31
32from anuga.pmesh.mesh_interface import create_mesh_from_regions
[3940]33from anuga.abstract_2d_finite_volumes.util import start_screen_catcher, copy_code_files
[3905]34from anuga_parallel.parallel_api import distribute, numprocs, myid, barrier
[3627]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
[4147]44start_screen_catcher(project.output_run_time_dir, myid, numprocs)
[3940]45
[3627]46# filenames
[3940]47build_time = '20061107_063840_build'
48bound_time = '20061102_221245_build'
[3905]49
[3851]50boundaries_name = project.boundaries_name
[3940]51meshes_dir_name = project.meshes_dir_name+'.msh'
52boundaries_dir_name = project.boundaries_dir_name
[4147]53
[3905]54tide = project.tide
[3627]55
[3940]56# creates copy of code in output dir
[3885]57if myid == 0:
[3940]58    copy_code_files(project.output_run_time_dir,__file__, 
59                 dirname(project.__file__)+sep+ project.__name__+'.py' )
[3905]60barrier()
[3885]61
62print 'USER: ', project.user
[4147]63print 'min triangles', project.trigs_min,
64print 'Note: This is generally about 20% less than the final amount'
65
[3885]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
[3905]73if myid == 0:
[3997]74   
75    print 'start create mesh from regions'
[4147]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)
[3885]84
[3905]85# to sync all processors are ready
86barrier()
87
[3713]88#-------------------------------------------------------------------------
89# Setup computational domain
90#-------------------------------------------------------------------------
[3851]91print 'Setup computational domain'
[3940]92domain = Domain(meshes_dir_name, use_cache=True, verbose=True)
[3713]93print domain.statistics()
[3627]94
[4147]95"""
[3905]96print 'starting to create boundary conditions'
97boundaries_in_dir_name = project.boundaries_in_dir_name
98
[4147]99from anuga.shallow_water.data_manager import urs2sw
[3905]100
101# put above distribute
[3940]102print 'boundary file is: ',boundaries_dir_name
[3905]103from caching import cache
[3940]104if myid == 0:
[4147]105    cache(urs2sww,
[3940]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,
[4049]118           'mint': 0, 'maxt': 35100,
[3940]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()
[4147]126"""
[3905]127
[3713]128#-------------------------------------------------------------------------
129# Setup initial conditions
130#-------------------------------------------------------------------------
[4049]131if myid == 0:
[3905]132
[4049]133    print 'Setup initial conditions'
[3905]134
[4049]135    domain.set_quantity('stage', tide)
[4147]136    domain.set_quantity('friction', 0.01) 
[4049]137    #combined_time_dir_name = project.topographies_dir+build_time+project.combined_name
138    print 'Start Set quantity'
139
140    domain.set_quantity('elevation', 
[4147]141                    filename = project.combined_dir_name + '.txt',
[3851]142                    use_cache = True,
[3713]143                    verbose = True,
144                    alpha = 0.1)
[4049]145    print 'Finished Set quantity'
146barrier()
[3627]147
[3905]148
[3877]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)
[3940]162domain.set_default_order(2) # Apply second order scheme
[3877]163domain.set_minimum_storable_height(0.01) # Don't store anything less than 1cm
[3940]164domain.set_store_vertices_uniquely(False)
165domain.set_quantities_to_be_stored(['stage', 'xmomentum', 'ymomentum'])
[4147]166domain.set_maximum_allowed_speed(0.1) # Allow a little runoff (0.1 is OK)
[3877]167
[3713]168#-------------------------------------------------------------------------
169# Setup boundary conditions
170#-------------------------------------------------------------------------
[3905]171print 'Available boundary tags', domain.get_boundary_tags()
[4147]172print 'domain id', id(domain)
[3905]173print 'Reading Boundary file'
[4147]174#Bf = File_boundary(boundaries_dir_name + '.sww',
175#                  domain, time_thinning=5, use_cache=True, verbose=True)
[3828]176
[3905]177print 'finished reading boundary file'
[3808]178
[3713]179Br = Reflective_boundary(domain)
180Bd = Dirichlet_boundary([tide,0,0])
[3905]181
182print'set_boundary'
[3713]183domain.set_boundary({'back': Br,
184                     'side': Bd,
185                     'ocean': Bf}) 
[3905]186print'finish set boundary'
[3627]187
188#----------------------------------------------------------------------------
189# Evolve system through time
190#----------------------------------------------------------------------------
[3905]191
[3627]192t0 = time.time()
193
[4147]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):
[3940]199#    domain.write_time()
200#    domain.write_boundary_statistics(tags = 'ocean')
201     
[4147]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')   
[3940]206
[4147]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')   
[3627]211   
212print 'That took %.2f seconds' %(time.time()-t0)
213
Note: See TracBrowser for help on using the repository browser.