source: anuga_work/production/busselton/standardised_version/run_busselton.py @ 6261

Last change on this file since 6261 was 6261, checked in by ole, 10 years ago

Looped elevation data conversions

File size: 5.8 KB
Line 
1"""Script for running a tsunami inundation scenario for busselton, WA, Australia.
2
3The scenario is defined by a triangular mesh created from project.polygon,
4the elevation data is compiled into a pts file through build_busselton.py
5and a simulated tsunami is generated through an sts file from build_boundary.py.
6
7Input: sts file (build_boundary.py for respective event)
8       pts file (build_busselton.py)
9       information from project file
10Outputs: sww file stored in project.output_run_time_dir
11The export_results_all.py and get_timeseries.py is reliant
12on the outputs of this script
13
14Ole Nielsen and Duncan Gray, GA - 2005, Jane Sexton, Nick Bartzis, GA - 2006
15Ole Nielsen, Jane Sexton and Kristy Van Putten - 2008
16"""
17
18# Note repeated use of domain id
19# Note naming of fundamental datasets and directories
20
21
22#------------------------------------------------------------------------------
23# Import necessary modules
24#------------------------------------------------------------------------------
25
26# Standard modules
27import os
28from os.path import dirname
29import time
30
31# Related major packages
32from anuga.interface import create_domain_from_regions
33from anuga.interface import Dirichlet_boundary
34from anuga.interface import Reflective_boundary
35from anuga.interface import Field_boundary
36from anuga.interface import create_sts_boundary
37from anuga.interface import csv2building_polygons
38
39from anuga.shallow_water.data_manager import start_screen_catcher
40from anuga.shallow_water.data_manager import copy_code_files
41from anuga.utilities.polygon import read_polygon, Polygon_function
42   
43# Application specific imports
44import project  # Definition of file names and polygons
45
46
47#-----------------------------------------------------------------------
48# Copy scripts to time stamped output directory and capture screen
49# output to file
50#-----------------------------------------------------------------------
51
52#copy script must be before screen_catcher
53#copy_code_files(project.output_run_time_dir, __file__,
54#         dirname(project.__file__)+os.sep+ project.__name__+'.py' )
55#start_screen_catcher(project.output_run_time_dir, myid, numprocs)
56
57
58#--------------------------------------------------------------------------
59# Create the computational domain based on overall clipping polygon with
60# a tagged boundary and interior regions defined in project.py along with
61# resolutions (maximal area of per triangle) for each polygon
62#--------------------------------------------------------------------------
63print 'Create computational domain'
64
65# Read in boundary from ordered sts file
66urs_bounding_polygon = create_sts_boundary(project.urs_boundary_name)
67
68# Reading the landward defined points, this incorporates the original clipping
69# polygon minus the 100m contour
70landward_bounding_polygon = read_polygon(project.landward_dir)
71
72# Combine sts polyline with landward points
73bounding_polygon = urs_bounding_polygon + landward_bounding_polygon
74
75# Number of boundary segments
76N = len(urs_bounding_polygon)-1
77
78# Boundary tags refer to project.landward 4 points equals 5 segments start at N
79boundary_tags={'back': [N+1,N+2,N+3,N+4, N+5],
80               'side': [N,N+6],
81               'ocean': range(N)}
82
83# Build mesh and domain
84domain = create_domain_from_regions(bounding_polygon,
85                                    boundary_tags=boundary_tags,
86                                    maximum_triangle_area=project.res_poly_all,
87                                    interior_regions=project.interior_regions,
88                                    mesh_filename=project.meshes_dir_name,
89                                    use_cache=True,
90                                    verbose=True)
91print domain.statistics()
92
93domain.set_name(project.scenario_name)
94domain.set_datadir(project.output_run_time_dir) 
95domain.set_minimum_storable_height(0.01)    # Don't store depth less than 1cm
96
97#-------------------------------------------------------------------------
98# Setup initial conditions
99#-------------------------------------------------------------------------
100print 'Setup initial conditions'
101
102# Set the initial stage in the offcoast region only
103IC = Polygon_function([(project.poly_mainland, 0),
104                       (project.poly_marina, 0)], 
105                      default=project.tide,
106                      geo_reference=domain.geo_reference)
107domain.set_quantity('stage', IC, use_cache=True, verbose=True)
108domain.set_quantity('friction', project.friction) 
109domain.set_quantity('elevation', 
110                    filename=project.combined_dir_name+'.pts',
111                    use_cache=True,
112                    verbose=True,
113                    alpha = project.alpha)
114
115
116#-------------------------------------------------------------------------
117# Setup boundary conditions
118#-------------------------------------------------------------------------
119print 'Set boundary - available tags:', domain.get_boundary_tags()
120
121Br = Reflective_boundary(domain)
122Bd = Dirichlet_boundary([project.tide,0,0])
123Bf = Field_boundary(project.urs_boundary_name+'.sts',
124                    domain, mean_stage=project.tide,
125                    time_thinning=1,
126                    default_boundary=Bd,
127                    boundary_polygon=bounding_polygon,                   
128                    use_cache=True,
129                    verbose=True)
130
131domain.set_boundary({'back': Br,
132                     'side': Bd,
133                     'ocean': Bf}) 
134
135#-------------------------------------------------------------------------
136# Evolve system through time
137#-------------------------------------------------------------------------
138t0 = time.time()
139for t in domain.evolve(yieldstep=project.yieldstep, 
140                       finaltime=project.finaltime,
141                       skip_initial_step=False): 
142    print domain.timestepping_statistics()
143    print domain.boundary_statistics(tags='ocean')
144
145print 'Simulation took %.2f seconds' %(time.time()-t0)
146
147   
148   
149
150     
151   
Note: See TracBrowser for help on using the repository browser.