source: anuga_work/production/MOST_example/run_onslow.py @ 3601

Last change on this file since 3601 was 3600, checked in by duncan, 19 years ago

comitting onslow work, before switching over to pt hedland

File size: 5.2 KB
Line 
1"""Script for running a tsunami inundation scenario for Onslow, 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.outputdir
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 Nick Bartzis, GA - 2006
11"""
12
13
14#-------------------------------------------------------------------------------# Import necessary modules
15#-------------------------------------------------------------------------------
16
17# Standard modules
18import os
19import time
20
21# Related major packages
22from anuga.pyvolution.shallow_water import Domain, Reflective_boundary, \
23                            Dirichlet_boundary, Time_boundary, File_boundary
24from anuga.pyvolution.data_manager import convert_dem_from_ascii2netcdf, dem2pts
25from anuga.pyvolution.combine_pts import combine_rectangular_points_files
26from anuga.pyvolution.pmesh2domain import pmesh_to_domain_instance
27from anuga.fit_interpolate.fit import fit_to_mesh_file
28
29from anuga.caching import cache
30
31# Application specific imports
32import project                 # Definition of file names and polygons
33from smf import slump_tsunami  # Function for submarine mudslide
34
35from shutil import copy
36from os import mkdir, access, F_OK
37
38from anuga.geospatial_data.geospatial_data import *
39
40#-------------------------------------------------------------------------------
41# Preparation of topographic data
42#
43# Convert ASC 2 DEM 2 PTS using source data and store result in source data
44# Do for coarse and fine data
45# Fine pts file to be clipped to area of interest
46#-------------------------------------------------------------------------------
47
48# filenames
49coarsedemname = project.coarsedemname
50
51onshore_dem_name = project.onshore_dem_name
52
53offshore_points = project.offshore_dem_name
54
55meshname = project.meshname+'.tsh'
56
57source_dir = project.boundarydir
58
59# creates copy of code in output dir
60if access(project.outputdir,F_OK) == 0 :
61    mkdir (project.outputdir)
62copy (project.codedirname, project.outputdir + project.codename)
63copy (project.codedir + 'run_onslow.py', project.outputdir + 'run_onslow.py')
64
65
66
67#-------------------------------------------------------------------------------                                 
68# Setup computational domain
69#-------------------------------------------------------------------------------                                 
70mesh_elevname = 'mesh_source_elv.msh'
71domain = pmesh_to_domain_instance(mesh_elevname, Domain,
72                                  use_cache = True,
73                                  verbose = True)
74
75print 'Number of triangles = ', len(domain)
76print 'The extent is ', domain.get_extent()
77print domain.statistics()
78
79domain.set_name(project.basename)
80domain.set_datadir(project.outputdir)
81domain.set_quantities_to_be_stored(['stage'])
82
83
84#-------------------------------------------------------------------------------                                 
85# Setup initial conditions
86#-------------------------------------------------------------------------------
87
88tide = 0.
89
90domain.set_quantity('stage', tide)
91domain.set_quantity('friction', 0.0) 
92print 'hi1'
93
94#-------------------------------------------------------------------------------                                 
95# Setup boundary conditions (all reflective)
96#-------------------------------------------------------------------------------
97
98from anuga.pyvolution.data_manager import ferret2sww
99
100south = project.south
101north = project.north
102west = project.west
103east = project.east
104
105cache(ferret2sww,
106      (project.boundary_basename,
107       project.boundary_basename), 
108      {'verbose': True,
109       'minlat': south,
110       'maxlat': north,
111       'minlon': west,
112       'maxlon': east,
113       'origin': domain.geo_reference.get_origin(),
114       'mean_stage': tide,
115       'zscale': 1,                 #Enhance tsunami
116       'fail_on_NaN': False,
117       'inverted_bathymetry': True},
118      #evaluate = True,
119       verbose = True)
120
121
122print 'Available boundary tags', domain.get_boundary_tags()
123
124Bf = File_boundary(project.boundary_basename + '.sww', 
125                    domain, verbose = True)
126Br = Reflective_boundary(domain)
127Bd = Dirichlet_boundary([tide,0,0])
128
129
130# 7 min square wave starting at 1 min, 6m high
131Bw = Time_boundary(domain = domain,
132                   f=lambda t: [(60<t<480)*6, 0, 0])
133
134domain.set_boundary( {'top': Bf, 'topleft': Bf,
135                             'left': Br, 'bottom': Br,
136                             'bottomright': Br, 'topright': Bf,
137                      'exterior':Bf} )
138
139
140#-------------------------------------------------------------------------------                                 
141# Evolve system through time
142#-------------------------------------------------------------------------------
143import time
144t0 = time.time()
145
146for t in domain.evolve(yieldstep = 50, finaltime = 1000): 
147    domain.write_time()
148    domain.write_boundary_statistics(tags = 'top')     
149   
150print 'That took %.2f seconds' %(time.time()-t0)
151
152print 'finished'
Note: See TracBrowser for help on using the repository browser.