source: anuga_work/production/galle_2007/run_gal5.py @ 4547

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

add Sri Lanka scenario Galle, this was used by Saman

File size: 5.7 KB
RevLine 
[4547]1"""Script for running a tsunami inundation scenario for Southwest coast,
2Sri Lanka.
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
12Ole Nielsen and Duncan Gray, GA - 2005 and Jane Sexton and
13Nick Bartzis, GA - 2006
14"""
15
16#------------------------------------------------------------------------------
17# Import necessary modules
18#------------------------------------------------------------------------------
19
20# Standard modules
21import os
22import time
23import sys
24from os.path import dirname, basename
25
26# Related major packages
27from anuga.shallow_water import Domain
28from anuga.shallow_water import Reflective_boundary
29from anuga.shallow_water import Dirichlet_boundary
30from anuga.shallow_water import Time_boundary
31from anuga.shallow_water import File_boundary
32from anuga.shallow_water import Field_boundary
33
34from anuga.pmesh.mesh_interface import create_mesh_from_regions
35from anuga.shallow_water.data_manager import convert_dem_from_ascii2netcdf
36from anuga.abstract_2d_finite_volumes.util import start_screen_catcher, copy_code_files
37from anuga.shallow_water.data_manager import dem2pts
38from anuga.geospatial_data.geospatial_data import *
39from os import sep
40from anuga.utilities.polygon import read_polygon, Polygon_function
41
42# Application specific imports
43import project                 # Definition of file names and polygons
44
45copy_code_files(project.output_run_time_dir,__file__, 
46                dirname(project.__file__)+sep+ project.__name__+'.py' )
47
48start_screen_catcher(project.output_run_time_dir)
49
50#------------------------------------------------------------------------------
51# Create the triangular mesh based on overall clipping polygon with a tagged
52# boundary and interior regions defined in project.py along with
53# resolutions (maximal area of per triangle) for each polygon
54#------------------------------------------------------------------------------
55
56create_mesh_from_regions(project.bounding_polygon,
57                         boundary_tags={'back': [3,4,5,6], 'side': [0,2],
58                                            'ocean': [1]},
59                         maximum_triangle_area=project.regional_res,
60                         filename=project.meshes_dir_name+'.msh',
61                         interior_regions=project.interior_regions,
62                         use_cache=False,
63                         verbose=True)
64
65
66#------------------------------------------------------------------------------
67# Setup computational domain
68#------------------------------------------------------------------------------
69
70domain = Domain(project.meshes_dir_name+'.msh', use_cache=False, verbose=True)
71
72print domain.statistics()
73
74domain.set_name(project.scenario_name)
75domain.set_datadir(project.output_run_time_dir)
76domain.set_default_order(2) # Apply second order scheme
77domain.set_minimum_storable_height(0.01) # Don't store anything less than 1cm
78domain.set_store_vertices_uniquely(False)
79domain.set_quantities_to_be_stored(['stage', 'xmomentum', 'ymomentum'])
80domain.set_maximum_allowed_speed(0.1) # Allow a little runoff (0.1 is OK)
81domain.beta_h = 0 # Use first order near bathymetry (faster)
82
83#------------------------------------------------------------------------------
84# Setup initial conditions
85#------------------------------------------------------------------------------
86
87
88IC = Polygon_function( [(project.poly_mainland, -1.0)], default = project.tide,
89                         geo_reference = domain.geo_reference)
90domain.set_quantity('stage', IC)
91domain.set_quantity('friction', 0.01) 
92print'start set elevation quantity'
93domain.set_quantity('elevation', 
94#                    filename=project.combined_dem_name + '.txt',
95                    filename=project.combined_canal_fort_dem_name + '.txt',
96#                    filename=project.combined_canal_dem_name + '.txt',
97#                    filename=project.combined_dem_name + '.pts',
98                    use_cache=True,
99                    verbose=True,
100                    alpha=0.1)
101print'finish set elevation quantity'
102#------------------------------------------------------------------------------
103# Setup boundary conditions
104#------------------------------------------------------------------------------
105
106#print 'Available boundary tags', domain.get_boundary_tags()
107
108Br = Reflective_boundary(domain)
109Bd = Dirichlet_boundary([project.tide,0,0])
110
111Bf = Field_boundary(project.boundaries_dir_name+'.sww',
112                    domain, time_thinning=2, mean_stage=project.tide, 
113                    use_cache=True, verbose=True)
114
115# 60 min square wave starting at 1 min, 50m high
116#if scenario == 'fixed_wave':
117
118Bw = Time_boundary(domain = domain,
119                       f=lambda t: [(60<t<300)*3, 0, 0])
120                       
121domain.set_boundary({'back': Br,
122                         'side': Bd,
123#                         'ocean': Bw}
124                         'ocean': Bf}
125                         )
126
127   
128#------------------------------------------------------------------------------
129# Evolve system through time
130#------------------------------------------------------------------------------
131
132t0 = time.time()
133
134from anuga.abstract_2d_finite_volumes.quantity import Quantity
135
136for t in domain.evolve(yieldstep = 60, finaltime = 30000):
137    domain.write_time()
138    domain.write_boundary_statistics(tags = 'ocean')
139           
140print 'That took %.2f seconds' %(time.time()-t0)
Note: See TracBrowser for help on using the repository browser.