[6263] | 1 | """Run a tsunami inundation scenario for Busselton, WA, Australia. |
---|
[6253] | 2 | |
---|
[6263] | 3 | The scenario is defined by a triangular mesh created from project.polygon, the |
---|
[6284] | 4 | elevation data is compiled into a pts file through build_elevation.py and a |
---|
[6263] | 5 | simulated tsunami is generated through an sts file from build_boundary.py. |
---|
[6253] | 6 | |
---|
| 7 | Input: sts file (build_boundary.py for respective event) |
---|
[6284] | 8 | pts file (build_elevation.py) |
---|
[6253] | 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 |
---|
[6343] | 24 | import os.path |
---|
[6253] | 25 | import time |
---|
[6343] | 26 | from time import localtime, strftime, gmtime |
---|
[6253] | 27 | |
---|
| 28 | # Related major packages |
---|
[6343] | 29 | from Scientific.IO.NetCDF import NetCDFFile |
---|
| 30 | import Numeric as num |
---|
| 31 | |
---|
[6259] | 32 | from anuga.interface import create_domain_from_regions |
---|
[6279] | 33 | from anuga.interface import Transmissive_stage_zero_momentum_boundary |
---|
[6259] | 34 | from anuga.interface import Dirichlet_boundary |
---|
| 35 | from anuga.interface import Reflective_boundary |
---|
| 36 | from anuga.interface import Field_boundary |
---|
| 37 | from anuga.interface import create_sts_boundary |
---|
| 38 | from anuga.interface import csv2building_polygons |
---|
[6328] | 39 | from file_length import file_length |
---|
[6259] | 40 | |
---|
| 41 | from anuga.shallow_water.data_manager import start_screen_catcher |
---|
| 42 | from anuga.shallow_water.data_manager import copy_code_files |
---|
[6343] | 43 | from anuga.shallow_water.data_manager import urs2sts |
---|
[6259] | 44 | from anuga.utilities.polygon import read_polygon, Polygon_function |
---|
[6343] | 45 | |
---|
[6253] | 46 | # Application specific imports |
---|
[6324] | 47 | from setup_model import project |
---|
[6369] | 48 | import build_urs_boundary as bub |
---|
[6253] | 49 | |
---|
[6343] | 50 | #------------------------------------------------------------------------------- |
---|
[6259] | 51 | # Copy scripts to time stamped output directory and capture screen |
---|
[6263] | 52 | # output to file. Copy script must be before screen_catcher |
---|
[6312] | 53 | #------------------------------------------------------------------------------- |
---|
| 54 | |
---|
[6279] | 55 | copy_code_files(project.output_run, __file__, |
---|
[6312] | 56 | os.path.join(os.path.dirname(project.__file__), |
---|
| 57 | project.__name__+'.py')) |
---|
[6279] | 58 | start_screen_catcher(project.output_run, 0, 1) |
---|
[6253] | 59 | |
---|
[6312] | 60 | #------------------------------------------------------------------------------- |
---|
[6259] | 61 | # Create the computational domain based on overall clipping polygon with |
---|
| 62 | # a tagged boundary and interior regions defined in project.py along with |
---|
| 63 | # resolutions (maximal area of per triangle) for each polygon |
---|
[6312] | 64 | #------------------------------------------------------------------------------- |
---|
| 65 | |
---|
[6259] | 66 | print 'Create computational domain' |
---|
[6253] | 67 | |
---|
[6312] | 68 | # Create the STS file |
---|
[6329] | 69 | print 'project.mux_data_folder=%s' % project.mux_data_folder |
---|
[6369] | 70 | if not os.path.exists(project.event_sts + '.sts'): |
---|
| 71 | bub.build_urs_boundary(project.mux_input_filename, project.event_sts) |
---|
[6312] | 72 | |
---|
[6259] | 73 | # Read in boundary from ordered sts file |
---|
[6279] | 74 | event_sts = create_sts_boundary(project.event_sts) |
---|
[6253] | 75 | |
---|
[6259] | 76 | # Reading the landward defined points, this incorporates the original clipping |
---|
| 77 | # polygon minus the 100m contour |
---|
[6279] | 78 | landward_boundary = read_polygon(project.landward_boundary) |
---|
[6253] | 79 | |
---|
[6259] | 80 | # Combine sts polyline with landward points |
---|
[6279] | 81 | bounding_polygon_sts = event_sts + landward_boundary |
---|
[6253] | 82 | |
---|
[6259] | 83 | # Number of boundary segments |
---|
[6329] | 84 | num_ocean_segments = len(event_sts) - 1 |
---|
[6328] | 85 | # Number of landward_boundary points |
---|
[6329] | 86 | num_land_points = file_length(project.landward_boundary) |
---|
[6253] | 87 | |
---|
[6281] | 88 | # Boundary tags refer to project.landward_boundary |
---|
| 89 | # 4 points equals 5 segments start at N |
---|
[6329] | 90 | boundary_tags={'back': range(num_ocean_segments+1, |
---|
| 91 | num_ocean_segments+num_land_points), |
---|
| 92 | 'side': [num_ocean_segments, |
---|
| 93 | num_ocean_segments+num_land_points], |
---|
| 94 | 'ocean': range(num_ocean_segments)} |
---|
[6253] | 95 | |
---|
[6259] | 96 | # Build mesh and domain |
---|
[6279] | 97 | domain = create_domain_from_regions(bounding_polygon_sts, |
---|
[6259] | 98 | boundary_tags=boundary_tags, |
---|
[6284] | 99 | maximum_triangle_area=project.bounding_maxarea, |
---|
[6259] | 100 | interior_regions=project.interior_regions, |
---|
[6279] | 101 | mesh_filename=project.meshes, |
---|
[6259] | 102 | use_cache=True, |
---|
| 103 | verbose=True) |
---|
| 104 | print domain.statistics() |
---|
[6253] | 105 | |
---|
[6259] | 106 | domain.set_name(project.scenario_name) |
---|
[6279] | 107 | domain.set_datadir(project.output_run) |
---|
[6259] | 108 | domain.set_minimum_storable_height(0.01) # Don't store depth less than 1cm |
---|
[6254] | 109 | |
---|
[6312] | 110 | #------------------------------------------------------------------------------- |
---|
| 111 | # Setup initial conditions |
---|
| 112 | #------------------------------------------------------------------------------- |
---|
[6263] | 113 | |
---|
[6259] | 114 | print 'Setup initial conditions' |
---|
[6253] | 115 | |
---|
[6259] | 116 | # Set the initial stage in the offcoast region only |
---|
[6369] | 117 | if project.land_initial_conditions: |
---|
| 118 | IC = Polygon_function(project.land_initial_conditions, |
---|
| 119 | default=project.tide, |
---|
| 120 | geo_reference=domain.geo_reference) |
---|
| 121 | else: |
---|
| 122 | IC = 0 |
---|
[6376] | 123 | domain.set_quantity('stage', IC, use_cache=True, verbose=True) |
---|
[6259] | 124 | domain.set_quantity('friction', project.friction) |
---|
| 125 | domain.set_quantity('elevation', |
---|
[6279] | 126 | filename=project.combined_elevation+'.pts', |
---|
[6259] | 127 | use_cache=True, |
---|
| 128 | verbose=True, |
---|
[6267] | 129 | alpha=project.alpha) |
---|
[6253] | 130 | |
---|
[6312] | 131 | #------------------------------------------------------------------------------- |
---|
| 132 | # Setup boundary conditions |
---|
| 133 | #------------------------------------------------------------------------------- |
---|
[6253] | 134 | |
---|
[6259] | 135 | print 'Set boundary - available tags:', domain.get_boundary_tags() |
---|
[6253] | 136 | |
---|
[6259] | 137 | Br = Reflective_boundary(domain) |
---|
[6279] | 138 | Bt = Transmissive_stage_zero_momentum_boundary(domain) |
---|
[6369] | 139 | Bd = Dirichlet_boundary([project.tide, 0, 0]) |
---|
[6279] | 140 | Bf = Field_boundary(project.event_sts+'.sts', |
---|
[6259] | 141 | domain, mean_stage=project.tide, |
---|
| 142 | time_thinning=1, |
---|
[6512] | 143 | default_boundary=Dirichlet_boundary([0, 0, 0]), |
---|
[6279] | 144 | boundary_polygon=bounding_polygon_sts, |
---|
[6259] | 145 | use_cache=True, |
---|
| 146 | verbose=True) |
---|
[6253] | 147 | |
---|
[6259] | 148 | domain.set_boundary({'back': Br, |
---|
[6369] | 149 | 'side': Bd, |
---|
[6259] | 150 | 'ocean': Bf}) |
---|
[6253] | 151 | |
---|
[6312] | 152 | #------------------------------------------------------------------------------- |
---|
| 153 | # Evolve system through time |
---|
| 154 | #------------------------------------------------------------------------------- |
---|
[6262] | 155 | |
---|
[6259] | 156 | t0 = time.time() |
---|
| 157 | for t in domain.evolve(yieldstep=project.yieldstep, |
---|
| 158 | finaltime=project.finaltime, |
---|
| 159 | skip_initial_step=False): |
---|
| 160 | print domain.timestepping_statistics() |
---|
| 161 | print domain.boundary_statistics(tags='ocean') |
---|
[6253] | 162 | |
---|
[6312] | 163 | print 'Simulation took %.2f seconds' % (time.time()-t0) |
---|