[6291] | 1 | """Run a tsunami inundation scenario for Busselton, WA, Australia. |
---|
| 2 | |
---|
| 3 | The scenario is defined by a triangular mesh created from project.polygon, the |
---|
| 4 | elevation data is compiled into a pts file through build_elevation.py and a |
---|
| 5 | 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_elevation.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 |
---|
[6342] | 33 | from file_length import file_length |
---|
[6291] | 34 | |
---|
| 35 | from anuga.shallow_water.data_manager import start_screen_catcher |
---|
| 36 | from anuga.shallow_water.data_manager import copy_code_files |
---|
| 37 | from anuga.utilities.polygon import read_polygon, Polygon_function |
---|
| 38 | |
---|
| 39 | # Application specific imports |
---|
| 40 | import project # Definition of file names and polygons |
---|
| 41 | |
---|
| 42 | |
---|
| 43 | #------------------------------------------------------------------------------ |
---|
| 44 | # Copy scripts to time stamped output directory and capture screen |
---|
| 45 | # output to file. Copy script must be before screen_catcher |
---|
| 46 | #------------------------------------------------------------------------------ |
---|
| 47 | copy_code_files(project.output_run, __file__, |
---|
| 48 | os.path.dirname(project.__file__)+os.sep+\ |
---|
| 49 | project.__name__+'.py' ) |
---|
| 50 | start_screen_catcher(project.output_run, 0, 1) |
---|
| 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 | event_sts = create_sts_boundary(project.event_sts) |
---|
| 62 | |
---|
| 63 | # Reading the landward defined points, this incorporates the original clipping |
---|
| 64 | # polygon minus the 100m contour |
---|
| 65 | landward_boundary = read_polygon(project.landward_boundary) |
---|
| 66 | |
---|
| 67 | # Combine sts polyline with landward points |
---|
| 68 | bounding_polygon_sts = event_sts + landward_boundary |
---|
| 69 | |
---|
| 70 | # Number of boundary segments |
---|
| 71 | N = len(event_sts)-1 |
---|
[6342] | 72 | # Number of landward_boundary points |
---|
| 73 | M = file_length(project.landward_boundary) |
---|
[6291] | 74 | |
---|
| 75 | # Boundary tags refer to project.landward_boundary |
---|
| 76 | # 4 points equals 5 segments start at N |
---|
[6342] | 77 | boundary_tags={'back': range(N+1,N+M), |
---|
| 78 | 'side': [N,N+M], |
---|
[6291] | 79 | 'ocean': range(N)} |
---|
| 80 | |
---|
| 81 | # Build mesh and domain |
---|
| 82 | domain = create_domain_from_regions(bounding_polygon_sts, |
---|
| 83 | boundary_tags=boundary_tags, |
---|
| 84 | maximum_triangle_area=project.bounding_maxarea, |
---|
| 85 | interior_regions=project.interior_regions, |
---|
| 86 | mesh_filename=project.meshes, |
---|
| 87 | use_cache=True, |
---|
| 88 | verbose=True) |
---|
| 89 | print domain.statistics() |
---|
| 90 | |
---|
| 91 | domain.set_name(project.scenario_name) |
---|
| 92 | domain.set_datadir(project.output_run) |
---|
| 93 | domain.set_minimum_storable_height(0.01) # Don't store depth less than 1cm |
---|
| 94 | |
---|
| 95 | |
---|
| 96 | #------------------------------------------------------------------------------ |
---|
| 97 | # Setup initial conditions |
---|
| 98 | #------------------------------------------------------------------------------ |
---|
| 99 | print 'Setup initial conditions' |
---|
| 100 | |
---|
| 101 | # Set the initial stage in the offcoast region only |
---|
| 102 | IC = Polygon_function(project.land_initial_conditions, |
---|
| 103 | default=project.tide, |
---|
| 104 | geo_reference=domain.geo_reference) |
---|
[6342] | 105 | domain.set_quantity('stage', 0, use_cache=True, verbose=True) |
---|
[6291] | 106 | domain.set_quantity('friction', project.friction) |
---|
| 107 | domain.set_quantity('elevation', |
---|
| 108 | filename=project.combined_elevation+'.pts', |
---|
| 109 | use_cache=True, |
---|
| 110 | verbose=True, |
---|
| 111 | alpha=project.alpha) |
---|
| 112 | |
---|
| 113 | |
---|
| 114 | #------------------------------------------------------------------------------ |
---|
| 115 | # Setup boundary conditions |
---|
| 116 | #------------------------------------------------------------------------------ |
---|
| 117 | print 'Set boundary - available tags:', domain.get_boundary_tags() |
---|
| 118 | |
---|
| 119 | Br = Reflective_boundary(domain) |
---|
[6342] | 120 | Bd = Dirichlet_boundary([project.tide,0,0]) |
---|
[6291] | 121 | Bf = Field_boundary(project.event_sts+'.sts', |
---|
| 122 | domain, mean_stage=project.tide, |
---|
| 123 | time_thinning=1, |
---|
| 124 | default_boundary=Bd, |
---|
| 125 | boundary_polygon=bounding_polygon_sts, |
---|
| 126 | use_cache=True, |
---|
| 127 | verbose=True) |
---|
| 128 | |
---|
[6342] | 129 | |
---|
[6291] | 130 | domain.set_boundary({'back': Br, |
---|
[6342] | 131 | 'side': Bd, |
---|
[6291] | 132 | 'ocean': Bf}) |
---|
| 133 | |
---|
| 134 | |
---|
| 135 | #------------------------------------------------------------------------------ |
---|
| 136 | # Evolve system through time |
---|
| 137 | #------------------------------------------------------------------------------ |
---|
| 138 | t0 = time.time() |
---|
| 139 | for 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 | |
---|
| 145 | print 'Simulation took %.2f seconds' %(time.time()-t0) |
---|