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

Last change on this file since 7435 was 5442, checked in by ole, 17 years ago

Retired h-limiter and beta_h as per ticket:194.
All unit tests and validation tests pass.

File size: 5.5 KB
Line 
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'])
80
81
82#------------------------------------------------------------------------------
83# Setup initial conditions
84#------------------------------------------------------------------------------
85
86
87IC = Polygon_function( [(project.poly_mainland, -1.0)], default = project.tide,
88                         geo_reference = domain.geo_reference)
89domain.set_quantity('stage', IC)
90domain.set_quantity('friction', 0.01) 
91print'start set elevation quantity'
92domain.set_quantity('elevation', 
93#                    filename=project.combined_dem_name + '.txt',
94                    filename=project.combined_canal_fort_dem_name + '.txt',
95#                    filename=project.combined_canal_dem_name + '.txt',
96#                    filename=project.combined_dem_name + '.pts',
97                    use_cache=True,
98                    verbose=True,
99                    alpha=0.1)
100print'finish set elevation quantity'
101#------------------------------------------------------------------------------
102# Setup boundary conditions
103#------------------------------------------------------------------------------
104
105#print 'Available boundary tags', domain.get_boundary_tags()
106
107Br = Reflective_boundary(domain)
108Bd = Dirichlet_boundary([project.tide,0,0])
109
110Bf = Field_boundary(project.boundaries_dir_name+'.sww',
111                    domain, time_thinning=2, mean_stage=project.tide, 
112                    use_cache=True, verbose=True)
113
114# 60 min square wave starting at 1 min, 50m high
115#if scenario == 'fixed_wave':
116
117Bw = Time_boundary(domain = domain,
118                       f=lambda t: [(60<t<300)*3, 0, 0])
119                       
120domain.set_boundary({'back': Br,
121                         'side': Bd,
122#                         'ocean': Bw}
123                         'ocean': Bf}
124                         )
125
126   
127#------------------------------------------------------------------------------
128# Evolve system through time
129#------------------------------------------------------------------------------
130
131t0 = time.time()
132
133from anuga.abstract_2d_finite_volumes.quantity import Quantity
134
135for t in domain.evolve(yieldstep = 60, finaltime = 30000):
136    domain.write_time()
137    domain.write_boundary_statistics(tags = 'ocean')
138           
139print 'That took %.2f seconds' %(time.time()-t0)
Note: See TracBrowser for help on using the repository browser.