source: documentation/user_manual/examples/runsydney.py @ 3383

Last change on this file since 3383 was 3190, checked in by sexton, 19 years ago

MOST and ANUGA comparisons and updates

File size: 5.7 KB
RevLine 
[2461]1"""Script for running a tsunami inundation scenario for Sydney, NSW, 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
10"""
11
12
[2887]13#------------------------------------------------------------------------------
[2478]14# Import necessary modules
[2887]15#------------------------------------------------------------------------------
[2461]16
17# Standard modules
18import os
19import time
20
21# Related major packages
[3136]22from pyvolution.shallow_water import Domain, Dirichlet_boundary
[2461]23from pyvolution.data_manager import convert_dem_from_ascii2netcdf, dem2pts
24from pyvolution.combine_pts import combine_rectangular_points_files
25from pmesh.mesh_interface import create_mesh_from_regions
26
27# Application specific imports
[2887]28import project                           # Define file names and polygons
[2478]29from pyvolution.smf import slump_tsunami # Function for submarine mudslide
[2461]30
31
32
[2887]33#------------------------------------------------------------------------------
[2599]34# Prepare bathymetric and topographic data
[2887]35#------------------------------------------------------------------------------
[2478]36
[2461]37# filenames
38coarsedemname = project.coarsedemname + '.pts'
39finedemname = project.finedemname + '.pts'
[2464]40combineddemname = project.combineddemname + '.pts'
[2461]41meshname = project.meshname+'.msh'
42
43
44# combining the coarse and fine data
45combine_rectangular_points_files(finedemname,
46                                 coarsedemname,
47                                 combineddemname)
48
49
[2478]50
[2887]51#------------------------------------------------------------------------------
[2478]52# Setup computational domain
[2887]53#------------------------------------------------------------------------------
[2478]54
55# Interior regions and mesh resolutions
[2461]56interior_res = 5000
[3136]57interior_regions = [[project.northern_polygon, interior_res],
58                    [project.harbour_polygon, interior_res],
[3190]59                    [project.southern_polygon, interior_res],
60                    [project.manly_polygon, interior_res],
61                    [project.top_polygon, interior_res]]
[2461]62
63
[3136]64create_mesh_from_regions(project.demopoly,
65                         boundary_tags= {'oceannorth': [0], 
[3190]66                                         'onshorenorth1': [1],
67                                         'onshorenorthwest1': [2],
68                                         'onshorenorthwest2': [3],
69                                         'onshorenorth2': [4],
70                                         'onshorewest': [5],
71                                         'onshoresouth': [6],
72                                         'oceansouth': [7],
73                                         'oceaneast': [8]},
[2478]74                         maximum_triangle_area=100000,
75                         filename=meshname,           
76                         interior_regions=interior_regions)
[2461]77
78
[2805]79#Create shallow water domain
[2461]80
[2866]81domain = Domain(meshname,
82                use_cache = True,
83                verbose = True)                                 
[2805]84
[2866]85
[2461]86print 'Number of triangles = ', len(domain)
87print 'The extent is ', domain.get_extent()
88
89domain.set_name(project.basename)
90domain.set_datadir(project.outputdir)
91domain.set_quantities_to_be_stored(['stage', 'xmomentum', 'ymomentum'])
92
93
[2887]94#------------------------------------------------------------------------------
[2461]95# Set up scenario (tsunami_source is a callable object used with set_quantity)
[2887]96#------------------------------------------------------------------------------
[2461]97
98tsunami_source = slump_tsunami(length=30000.0,
99                               depth=400.0,
100                               slope=6.0,
101                               thickness=176.0, 
102                               radius=3330,
103                               dphi=0.23,
104                               x0=project.slump_origin[0], 
105                               y0=project.slump_origin[1], 
106                               alpha=0.0, 
107                               domain=domain)
108
109
[2887]110#------------------------------------------------------------------------------
[2461]111# Setup initial conditions
[2887]112#------------------------------------------------------------------------------
[2461]113
114domain.set_quantity('stage', tsunami_source)
115domain.set_quantity('friction', 0.0) 
116domain.set_quantity('elevation',
117                    filename = combineddemname,
118                    use_cache = True,
119                    verbose = True)
120
[2887]121#------------------------------------------------------------------------------
[3136]122# Setup boundary conditions (all Dirichlet)
[2887]123#------------------------------------------------------------------------------
[2461]124
125print 'Available boundary tags', domain.get_boundary_tags()
126
[3136]127Bd = Dirichlet_boundary([0.0,0.0,0.0])
[3190]128domain.set_boundary( {'oceannorth': Bd,
129                      'onshorenorth1': Bd,
130                      'onshorenorthwest1': Bd,
131                      'onshorenorthwest2': Bd,
132                      'onshorenorth2': Bd,
133                      'onshorewest': Bd,
134                      'onshoresouth': Bd,
135                      'oceansouth': Bd,
136                      'oceaneast': Bd} )
[2461]137
[2887]138#------------------------------------------------------------------------------
[2461]139# Evolve system through time
[2887]140#------------------------------------------------------------------------------
[2461]141
142import time
143t0 = time.time()
144
[3190]145for t in domain.evolve(yieldstep = 60, finaltime = 7200):
[2497]146    print domain.timestepping_statistics()
[3136]147    print domain.boundary_statistics(tags = 'oceaneast')   
[2461]148   
149print 'That took %.2f seconds' %(time.time()-t0)
Note: See TracBrowser for help on using the repository browser.