source: anuga_work/development/boxingday08/run_boxingday_polyline.py @ 5393

Last change on this file since 5393 was 5393, checked in by jakeman, 15 years ago

updating scripts for boxingday validation

File size: 7.6 KB
Line 
1"""Script for running the 2004 boxing Day tsunami inundation scenario for
2Phuket, Thailand.
3
4Source data such as elevation and boundary data is assumed to be available in
5directories specified by project.py
6The output sww file is stored in directory named after the scenario, i.e
7slide or fixed_wave.
8
9The scenario is defined by a triangular mesh created from project.polygon,
10the elevation data and a tsunami wave generated by a submarine mass failure.
11
12Author: John Jakeman, The Australian National University (2008)
13"""
14
15#------------------------------------------------------------------------------
16# Import necessary modules
17#------------------------------------------------------------------------------
18
19# Standard modules
20import os
21import time
22import sys
23from time import localtime, strftime
24
25# Related major packages
26from anuga.shallow_water import Domain
27from anuga.shallow_water import Reflective_boundary
28from anuga.shallow_water import Dirichlet_boundary
29from anuga.shallow_water import Time_boundary
30from anuga.shallow_water import File_boundary
31from anuga.pmesh.mesh_interface import create_mesh_from_regions
32from anuga.shallow_water.data_manager import convert_dem_from_ascii2netcdf, ferret2sww
33from anuga.shallow_water.data_manager import dem2pts
34from anuga.coordinate_transforms.redfearn import convert_from_latlon_to_utm
35from anuga.utilities.polygon import number_mesh_triangles
36from anuga.fit_interpolate.fit import fit_to_mesh_file
37from anuga.caching import cache
38from anuga.abstract_2d_finite_volumes.pmesh2domain import pmesh_to_domain_instance
39
40# Application specific imports
41import project                 # Definition of file names and polygons
42import create_boundary
43
44
45#------------------------------------------------------------------------------
46# Define scenario as either slide or fixed_wave.
47#------------------------------------------------------------------------------
48
49#scenario = 'poor_simulation'
50scenario = 'good_simulation'
51
52if os.access(scenario, os.F_OK) == 0:
53    os.mkdir(scenario)
54
55timestamp = strftime('%Y%m%d_%H%M%S',localtime())
56basename = scenario + '_polyline'
57
58
59#------------------------------------------------------------------------------
60# Preparation of topographic data
61# Convert ASC 2 DEM 2 PTS using source data and store result in source data
62#------------------------------------------------------------------------------
63
64if scenario == 'good_simualation':
65     msg = 'Must use combine_good_data to create bathymetry .pts file'
66     assert os.path.exists(project.good_combined_dir_name+'.pts'), msg
67
68#------------------------------------------------------------------------------
69# Create the triangular mesh based on overall clipping polygon with a tagged
70# boundary and interior regions defined in project.py along with
71# resolutions (maximal area of per triangle) for each polygon
72#------------------------------------------------------------------------------
73extent_res     = 10000000.0
74contour20m_res = 50000.0
75island_res     = 5000.0
76bay_res        = 2000.0
77patong_res     = 100.0
78
79
80# make polygon that contains land that does not affect result.
81
82interior_regions = [[project.patong, patong_res],
83                    [project.bay, bay_res],
84                    [project.contour20m, contour20m_res],
85                    [project.island_north, island_res],
86                    [project.island_south, island_res],
87                    [project.island_south2, island_res]]
88
89
90#for coarse run to test gauges
91extent_res = 10000000.0
92interior_regions=None
93
94from Numeric import arange,allclose
95boundary_tags={'ocean': arange(1,85).tolist(), 'otherocean': [0,89], 'land': [86, 87], 'both': [85,88]}
96
97#trigs_min = number_mesh_triangles(interior_regions, create_boundary.bounding_polygon,extent_res)
98#print 'Minimum number of traingles ', trigs_min
99
100# filenames
101meshname = project.meshname + '_polyline.tsh'
102mesh_elevname = project.mesh_elevname  + '_polyline.tsh'
103
104print 'start create mesh from regions'
105
106_ = cache(create_mesh_from_regions,
107          create_boundary.bounding_polygon,
108          {'boundary_tags': boundary_tags,
109           'maximum_triangle_area': extent_res,
110           'filename': meshname,           
111           'interior_regions': interior_regions},
112          verbose = True,
113          dependencies = ['create_boundary.py']
114          #, evaluate=True
115          )
116
117
118#------------------------------------------------------------------------------
119# Setup computational domain
120#------------------------------------------------------------------------------
121print 'Converting mesh to domain'
122
123#domain = Domain(meshname, use_cache=False, verbose=True)
124
125domain = cache(pmesh_to_domain_instance,
126               (meshname, Domain),
127               dependencies = [meshname])
128
129print 'The extent is ', domain.get_extent()
130print domain.statistics()
131
132domain.set_name(basename+'friction'+timestamp)
133#domain.set_name(basename)
134domain.set_datadir(scenario)
135domain.set_quantities_to_be_stored(['stage', 'xmomentum', 'ymomentum'])
136domain.set_minimum_storable_height(0.01)
137
138domain.beta_h = 0
139domain.tight_slope_limiters = 1
140domain.set_default_order(2)
141print 'domain.tight_slope_limiters', domain.tight_slope_limiters
142
143domain.points_file_block_line_size = 50000
144
145#------------------------------------------------------------------------------
146# Setup initial conditions
147#------------------------------------------------------------------------------
148     
149tide = 0.0
150domain.set_quantity('stage', tide)
151domain.set_quantity('friction', 0.01) 
152
153if scenario == 'poor_simulation':
154     domain.set_quantity('elevation', 
155                         filename=project.poor_combined_dir_name + '.pts',
156                         use_cache=True,
157                         verbose=True,
158                         alpha=0.1)
159
160if scenario == 'good_simulation':
161     domain.set_quantity('elevation', 
162                         filename=project.good_combined_dir_name + '.pts',
163                         use_cache=True,
164                         verbose=True,
165                         alpha=0.1)
166#------------------------------------------------------------------------------
167# Setup boundary conditions
168#------------------------------------------------------------------------------
169boundary_urs_in='data/boxing'
170boundary_urs_out=create_boundary.base_name
171
172print 'Available boundary tags', domain.get_boundary_tags()
173Bf = File_boundary(boundary_urs_out+'.sts', 
174                   domain, time_thinning=1,
175                   use_cache=False,verbose = True,boundary_polygon=create_boundary.bounding_polygon)
176
177Br = Reflective_boundary(domain)
178Bd = Dirichlet_boundary([tide,0.0,0.0])
179
180domain.set_boundary({'ocean': Bf,
181                     'otherocean': Bd,
182                     'land': Br,
183                     'both': Bd})
184
185#------------------------------------------------------------------------------
186# Evolve system through time
187#------------------------------------------------------------------------------
188import time
189t0 = time.time()
190
191#from Numeric import allclose
192#from anuga.abstract_2d_finite_volumes.quantity import Quantity
193
194# Add new loop that uses larger yieldstep until wave first reaches a point of
195# the ANUGA boundary. Or find a way to clip MOST sww boundary file to only
196# start when boundary stage first becomes non-zero.
197
198for t in domain.evolve(yieldstep = 5.0, finaltime = 18000.0, 
199                       skip_initial_step = False):
200    if allclose(t,10800.0):
201        print 'Changing urs file boundary to dirichlet. Urs gauges only have 3 hours of data'
202        domain.set_boundary({'ocean': Bd,
203                     'otherocean': Bd,
204                     'land': Br,
205                     'both': Bd})
206   
207    domain.write_time()
208           
209print 'That took %.2f seconds' %(time.time()-t0)
Note: See TracBrowser for help on using the repository browser.