[4547] | 1 | """Script for running a tsunami inundation scenario for Southwest coast, |
---|
| 2 | Sri Lanka. |
---|
| 3 | |
---|
| 4 | Source data such as elevation and boundary data is assumed to be available in |
---|
| 5 | directories specified by project.py |
---|
| 6 | The output sww file is stored in directory named after the scenario, i.e |
---|
| 7 | slide or fixed_wave. |
---|
| 8 | |
---|
| 9 | The scenario is defined by a triangular mesh created from project.polygon, |
---|
| 10 | the elevation data and a tsunami wave generated by a submarine mass failure. |
---|
| 11 | |
---|
| 12 | Ole Nielsen and Duncan Gray, GA - 2005 and Jane Sexton and |
---|
| 13 | Nick Bartzis, GA - 2006 |
---|
| 14 | """ |
---|
| 15 | |
---|
| 16 | #------------------------------------------------------------------------------ |
---|
| 17 | # Import necessary modules |
---|
| 18 | #------------------------------------------------------------------------------ |
---|
| 19 | |
---|
| 20 | # Standard modules |
---|
| 21 | import os |
---|
| 22 | import time |
---|
| 23 | import sys |
---|
| 24 | from os.path import dirname, basename |
---|
| 25 | |
---|
| 26 | # Related major packages |
---|
| 27 | from anuga.shallow_water import Domain |
---|
| 28 | from anuga.shallow_water import Reflective_boundary |
---|
| 29 | from anuga.shallow_water import Dirichlet_boundary |
---|
| 30 | from anuga.shallow_water import Time_boundary |
---|
| 31 | from anuga.shallow_water import File_boundary |
---|
| 32 | from anuga.shallow_water import Field_boundary |
---|
| 33 | |
---|
| 34 | from anuga.pmesh.mesh_interface import create_mesh_from_regions |
---|
| 35 | from anuga.shallow_water.data_manager import convert_dem_from_ascii2netcdf |
---|
| 36 | from anuga.abstract_2d_finite_volumes.util import start_screen_catcher, copy_code_files |
---|
| 37 | from anuga.shallow_water.data_manager import dem2pts |
---|
| 38 | from anuga.geospatial_data.geospatial_data import * |
---|
| 39 | from os import sep |
---|
| 40 | from anuga.utilities.polygon import read_polygon, Polygon_function |
---|
| 41 | |
---|
| 42 | # Application specific imports |
---|
| 43 | import project # Definition of file names and polygons |
---|
| 44 | |
---|
| 45 | copy_code_files(project.output_run_time_dir,__file__, |
---|
| 46 | dirname(project.__file__)+sep+ project.__name__+'.py' ) |
---|
| 47 | |
---|
| 48 | start_screen_catcher(project.output_run_time_dir) |
---|
| 49 | |
---|
| 50 | #------------------------------------------------------------------------------ |
---|
| 51 | # Create the triangular mesh based on overall clipping polygon with a tagged |
---|
| 52 | # boundary and interior regions defined in project.py along with |
---|
| 53 | # resolutions (maximal area of per triangle) for each polygon |
---|
| 54 | #------------------------------------------------------------------------------ |
---|
| 55 | |
---|
| 56 | create_mesh_from_regions(project.bounding_polygon, |
---|
| 57 | boundary_tags={'back': [3,4,5,6], 'side': [0,2], |
---|
| 58 | 'ocean': [1]}, |
---|
| 59 | maximum_triangle_area=project.regional_res, |
---|
| 60 | filename=project.meshes_dir_name+'.msh', |
---|
| 61 | interior_regions=project.interior_regions, |
---|
| 62 | use_cache=False, |
---|
| 63 | verbose=True) |
---|
| 64 | |
---|
| 65 | |
---|
| 66 | #------------------------------------------------------------------------------ |
---|
| 67 | # Setup computational domain |
---|
| 68 | #------------------------------------------------------------------------------ |
---|
| 69 | |
---|
| 70 | domain = Domain(project.meshes_dir_name+'.msh', use_cache=False, verbose=True) |
---|
| 71 | |
---|
| 72 | print domain.statistics() |
---|
| 73 | |
---|
| 74 | domain.set_name(project.scenario_name) |
---|
| 75 | domain.set_datadir(project.output_run_time_dir) |
---|
| 76 | domain.set_default_order(2) # Apply second order scheme |
---|
| 77 | domain.set_minimum_storable_height(0.01) # Don't store anything less than 1cm |
---|
| 78 | domain.set_store_vertices_uniquely(False) |
---|
| 79 | domain.set_quantities_to_be_stored(['stage', 'xmomentum', 'ymomentum']) |
---|
| 80 | domain.set_maximum_allowed_speed(0.1) # Allow a little runoff (0.1 is OK) |
---|
| 81 | domain.beta_h = 0 # Use first order near bathymetry (faster) |
---|
| 82 | |
---|
| 83 | #------------------------------------------------------------------------------ |
---|
| 84 | # Setup initial conditions |
---|
| 85 | #------------------------------------------------------------------------------ |
---|
| 86 | |
---|
| 87 | |
---|
| 88 | IC = Polygon_function( [(project.poly_mainland, -1.0)], default = project.tide, |
---|
| 89 | geo_reference = domain.geo_reference) |
---|
| 90 | domain.set_quantity('stage', IC) |
---|
| 91 | domain.set_quantity('friction', 0.01) |
---|
| 92 | print'start set elevation quantity' |
---|
| 93 | domain.set_quantity('elevation', |
---|
| 94 | # filename=project.combined_dem_name + '.txt', |
---|
| 95 | filename=project.combined_canal_fort_dem_name + '.txt', |
---|
| 96 | # filename=project.combined_canal_dem_name + '.txt', |
---|
| 97 | # filename=project.combined_dem_name + '.pts', |
---|
| 98 | use_cache=True, |
---|
| 99 | verbose=True, |
---|
| 100 | alpha=0.1) |
---|
| 101 | print'finish set elevation quantity' |
---|
| 102 | #------------------------------------------------------------------------------ |
---|
| 103 | # Setup boundary conditions |
---|
| 104 | #------------------------------------------------------------------------------ |
---|
| 105 | |
---|
| 106 | #print 'Available boundary tags', domain.get_boundary_tags() |
---|
| 107 | |
---|
| 108 | Br = Reflective_boundary(domain) |
---|
| 109 | Bd = Dirichlet_boundary([project.tide,0,0]) |
---|
| 110 | |
---|
| 111 | Bf = Field_boundary(project.boundaries_dir_name+'.sww', |
---|
| 112 | domain, time_thinning=2, mean_stage=project.tide, |
---|
| 113 | use_cache=True, verbose=True) |
---|
| 114 | |
---|
| 115 | # 60 min square wave starting at 1 min, 50m high |
---|
| 116 | #if scenario == 'fixed_wave': |
---|
| 117 | |
---|
| 118 | Bw = Time_boundary(domain = domain, |
---|
| 119 | f=lambda t: [(60<t<300)*3, 0, 0]) |
---|
| 120 | |
---|
| 121 | domain.set_boundary({'back': Br, |
---|
| 122 | 'side': Bd, |
---|
| 123 | # 'ocean': Bw} |
---|
| 124 | 'ocean': Bf} |
---|
| 125 | ) |
---|
| 126 | |
---|
| 127 | |
---|
| 128 | #------------------------------------------------------------------------------ |
---|
| 129 | # Evolve system through time |
---|
| 130 | #------------------------------------------------------------------------------ |
---|
| 131 | |
---|
| 132 | t0 = time.time() |
---|
| 133 | |
---|
| 134 | from anuga.abstract_2d_finite_volumes.quantity import Quantity |
---|
| 135 | |
---|
| 136 | for t in domain.evolve(yieldstep = 60, finaltime = 30000): |
---|
| 137 | domain.write_time() |
---|
| 138 | domain.write_boundary_statistics(tags = 'ocean') |
---|
| 139 | |
---|
| 140 | print 'That took %.2f seconds' %(time.time()-t0) |
---|