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

Last change on this file since 6262 was 6262, checked in by ole, 15 years ago

Cleanup before coding style meeting

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