1 | """Script for running a tsunami inundation scenario for busselton, WA, Australia. |
---|
2 | |
---|
3 | The scenario is defined by a triangular mesh created from project.polygon, |
---|
4 | the elevation data is compiled into a pts file through build_busselton.py |
---|
5 | and a simulated tsunami is generated through an sts file from build_boundary.py. |
---|
6 | |
---|
7 | Input: sts file (build_boundary.py for respective event) |
---|
8 | pts file (build_busselton.py) |
---|
9 | information from project file |
---|
10 | Outputs: sww file stored in project.output_run_time_dir |
---|
11 | The export_results_all.py and get_timeseries.py is reliant |
---|
12 | on the outputs of this script |
---|
13 | |
---|
14 | Ole Nielsen and Duncan Gray, GA - 2005, Jane Sexton, Nick Bartzis, GA - 2006 |
---|
15 | Ole Nielsen, Jane Sexton and Kristy Van Putten - 2008 |
---|
16 | """ |
---|
17 | |
---|
18 | #------------------------------------------------------------------------------ |
---|
19 | # Import necessary modules |
---|
20 | #------------------------------------------------------------------------------ |
---|
21 | |
---|
22 | # Standard modules |
---|
23 | import os |
---|
24 | import time |
---|
25 | |
---|
26 | # Related major packages |
---|
27 | from anuga.interface import create_domain_from_regions |
---|
28 | from anuga.interface import Dirichlet_boundary |
---|
29 | from anuga.interface import Reflective_boundary |
---|
30 | from anuga.interface import Field_boundary |
---|
31 | from anuga.interface import create_sts_boundary |
---|
32 | from anuga.interface import csv2building_polygons |
---|
33 | |
---|
34 | from anuga.shallow_water.data_manager import start_screen_catcher |
---|
35 | from anuga.shallow_water.data_manager import copy_code_files |
---|
36 | from anuga.utilities.polygon import read_polygon, Polygon_function |
---|
37 | |
---|
38 | # Application specific imports |
---|
39 | import 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 | |
---|
47 | copy script must be before screen_catcher |
---|
48 | copy_code_files(project.output_run_time_dir, __file__, |
---|
49 | os.path.dirname(project.__file__)+os.sep+ project.__name__+'.py' ) |
---|
50 | start_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 | #-------------------------------------------------------------------------- |
---|
58 | print 'Create computational domain' |
---|
59 | |
---|
60 | # Read in boundary from ordered sts file |
---|
61 | urs_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 |
---|
65 | landward_bounding_polygon = read_polygon(project.landward_dir) |
---|
66 | |
---|
67 | # Combine sts polyline with landward points |
---|
68 | bounding_polygon = urs_bounding_polygon + landward_bounding_polygon |
---|
69 | |
---|
70 | # Number of boundary segments |
---|
71 | N = len(urs_bounding_polygon)-1 |
---|
72 | |
---|
73 | # Boundary tags refer to project.landward 4 points equals 5 segments start at N |
---|
74 | boundary_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 |
---|
79 | domain = 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) |
---|
86 | print domain.statistics() |
---|
87 | |
---|
88 | domain.set_name(project.scenario_name) |
---|
89 | domain.set_datadir(project.output_run_time_dir) |
---|
90 | domain.set_minimum_storable_height(0.01) # Don't store depth less than 1cm |
---|
91 | |
---|
92 | #------------------------------------------------------------------------- |
---|
93 | # Setup initial conditions |
---|
94 | #------------------------------------------------------------------------- |
---|
95 | print 'Setup initial conditions' |
---|
96 | |
---|
97 | # Set the initial stage in the offcoast region only |
---|
98 | IC = Polygon_function([(project.poly_mainland, 0), |
---|
99 | (project.poly_marina, 0)], |
---|
100 | default=project.tide, |
---|
101 | geo_reference=domain.geo_reference) |
---|
102 | domain.set_quantity('stage', IC, use_cache=True, verbose=True) |
---|
103 | domain.set_quantity('friction', project.friction) |
---|
104 | domain.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 | #------------------------------------------------------------------------- |
---|
114 | print 'Set boundary - available tags:', domain.get_boundary_tags() |
---|
115 | |
---|
116 | Br = Reflective_boundary(domain) |
---|
117 | Bd = Dirichlet_boundary([project.tide,0,0]) |
---|
118 | Bf = 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 | |
---|
126 | domain.set_boundary({'back': Br, |
---|
127 | 'side': Bd, |
---|
128 | 'ocean': Bf}) |
---|
129 | |
---|
130 | |
---|
131 | #------------------------------------------------------------------------- |
---|
132 | # Evolve system through time |
---|
133 | #------------------------------------------------------------------------- |
---|
134 | t0 = time.time() |
---|
135 | for 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 | |
---|
141 | print 'Simulation took %.2f seconds' %(time.time()-t0) |
---|
142 | |
---|
143 | |
---|
144 | |
---|
145 | |
---|
146 | |
---|
147 | |
---|