[2437] | 1 | """Script for running a tsunami inundation scenario for Onslow, WA, Australia. |
---|
[2436] | 2 | |
---|
| 3 | Source data such as elevation and boundary data is assumed to be available in |
---|
| 4 | directories specified by project.py |
---|
| 5 | The output sww file is stored in project.outputdir |
---|
| 6 | |
---|
| 7 | The scenario is defined by a triangular mesh created from project.polygon, |
---|
| 8 | the elevation data and a simulated submarine landslide. |
---|
| 9 | |
---|
[2437] | 10 | Ole Nielsen and Duncan Gray, GA - 2005 and Nick Bartzis, GA - 2006 |
---|
[2436] | 11 | """ |
---|
| 12 | |
---|
| 13 | |
---|
| 14 | #-------------------------------------------------------------------------------# Import necessary modules |
---|
| 15 | #------------------------------------------------------------------------------- |
---|
| 16 | |
---|
| 17 | # Standard modules |
---|
| 18 | import os |
---|
| 19 | import time |
---|
| 20 | |
---|
| 21 | # Related major packages |
---|
| 22 | from pyvolution.shallow_water import Domain, Reflective_boundary |
---|
[2437] | 23 | from pyvolution.shallow_water import Domain, Time_boundary |
---|
[2436] | 24 | from pyvolution.data_manager import convert_dem_from_ascii2netcdf, dem2pts |
---|
| 25 | from pyvolution.combine_pts import combine_rectangular_points_files |
---|
| 26 | from pyvolution.pmesh2domain import pmesh_to_domain_instance |
---|
| 27 | |
---|
| 28 | # Application specific imports |
---|
| 29 | import project # Definition of file names and polygons |
---|
| 30 | from smf import slump_tsunami # Function for submarine mudslide |
---|
| 31 | |
---|
| 32 | |
---|
| 33 | #------------------------------------------------------------------------------- |
---|
| 34 | # Preparation of topographic data |
---|
| 35 | # |
---|
| 36 | # Convert ASC 2 DEM 2 PTS using source data and store result in source data |
---|
| 37 | # Do for coarse and fine data |
---|
| 38 | # Fine pts file to be clipped to area of interest |
---|
| 39 | #------------------------------------------------------------------------------- |
---|
| 40 | ''' |
---|
| 41 | # filenames |
---|
| 42 | coarsedemname = project.coarsedemname |
---|
| 43 | #finedemname = project.finedemname |
---|
| 44 | ''' |
---|
| 45 | meshname = project.meshname+'.msh' |
---|
| 46 | ''' |
---|
| 47 | # coarse data |
---|
| 48 | convert_dem_from_ascii2netcdf(coarsedemname, use_cache=True, verbose=True) |
---|
| 49 | dem2pts(coarsedemname, use_cache=True, verbose=True) |
---|
| 50 | |
---|
| 51 | # fine data (clipping the points file to smaller area) |
---|
| 52 | convert_dem_from_ascii2netcdf(finedemname, use_cache=True, verbose=True) |
---|
| 53 | dem2pts(finedemname, |
---|
| 54 | easting_min=project.eastingmin, |
---|
| 55 | easting_max=project.eastingmax, |
---|
| 56 | northing_min=project.northingmin, |
---|
| 57 | northing_max= project.northingmax, |
---|
| 58 | use_cache=True, |
---|
| 59 | verbose=True) |
---|
| 60 | |
---|
| 61 | |
---|
| 62 | # combining the coarse and fine data |
---|
| 63 | combine_rectangular_points_files(project.finedemname + '.pts', |
---|
| 64 | project.coarsedemname + '.pts', |
---|
| 65 | project.combineddemname + '.pts') |
---|
| 66 | ''' |
---|
| 67 | |
---|
| 68 | #------------------------------------------------------------------------------- |
---|
| 69 | # Create the triangular mesh based on overall clipping polygon with a tagged |
---|
| 70 | # boundary and interior regions defined in project.py along with |
---|
| 71 | # resolutions (maximal area of per triangle) for each polygon |
---|
| 72 | #------------------------------------------------------------------------------- |
---|
| 73 | |
---|
| 74 | from pmesh.create_mesh import create_mesh_from_regions |
---|
| 75 | |
---|
| 76 | # original |
---|
| 77 | interior_res = 5000 |
---|
[2441] | 78 | interior_regions = [[project.poly_onslow, interior_res], |
---|
| 79 | [project.poly_thevenard, interior_res], |
---|
| 80 | [project.poly_direction, interior_res]] |
---|
[2436] | 81 | |
---|
| 82 | #FIXME: Fix caching of this one once the mesh_interface is ready |
---|
| 83 | from caching import cache |
---|
| 84 | _ = cache(create_mesh_from_regions, |
---|
| 85 | project.polyAll, |
---|
| 86 | {'boundary_tags': {'top': [0], 'topleft': [1], |
---|
| 87 | 'left': [2], 'bottom': [3], |
---|
| 88 | 'bottomright': [4], 'topright': [5]}, |
---|
| 89 | 'resolution': 100000, |
---|
| 90 | 'filename': meshname, |
---|
| 91 | 'interior_regions': interior_regions, |
---|
| 92 | 'UTM': True, |
---|
| 93 | 'refzone': project.refzone}, |
---|
| 94 | verbose = True) |
---|
| 95 | |
---|
| 96 | |
---|
| 97 | #------------------------------------------------------------------------------- |
---|
| 98 | # Setup computational domain |
---|
| 99 | #------------------------------------------------------------------------------- |
---|
| 100 | |
---|
| 101 | domain = pmesh_to_domain_instance(meshname, Domain, |
---|
| 102 | use_cache = True, |
---|
| 103 | verbose = True) |
---|
| 104 | |
---|
| 105 | print 'Number of triangles = ', len(domain) |
---|
| 106 | print 'The extent is ', domain.get_extent() |
---|
| 107 | |
---|
| 108 | domain.set_name(project.basename) |
---|
| 109 | domain.set_datadir(project.outputdir) |
---|
| 110 | domain.set_quantities_to_be_stored(['stage', 'xmomentum', 'ymomentum']) |
---|
| 111 | |
---|
| 112 | |
---|
| 113 | #------------------------------------------------------------------------------- |
---|
| 114 | # Set up scenario (tsunami_source is a callable object used with set_quantity) |
---|
| 115 | #------------------------------------------------------------------------------- |
---|
| 116 | ''' |
---|
| 117 | tsunami_source = slump_tsunami(length=30000.0, |
---|
| 118 | depth=400.0, |
---|
| 119 | slope=6.0, |
---|
| 120 | thickness=176.0, |
---|
| 121 | radius=3330, |
---|
| 122 | dphi=0.23, |
---|
| 123 | x0=project.slump_origin[0], |
---|
| 124 | y0=project.slump_origin[1], |
---|
| 125 | alpha=0.0, |
---|
| 126 | domain=domain) |
---|
| 127 | |
---|
| 128 | ''' |
---|
| 129 | #------------------------------------------------------------------------------- |
---|
| 130 | # Setup initial conditions |
---|
| 131 | #------------------------------------------------------------------------------- |
---|
| 132 | |
---|
| 133 | domain.set_quantity('stage', 0.) |
---|
| 134 | domain.set_quantity('friction', 0.0) |
---|
| 135 | domain.set_quantity('elevation', 0. |
---|
| 136 | # filename = project.combineddemname + '.pts', |
---|
| 137 | # filename = project.coarsedemname + '.pts', |
---|
| 138 | # use_cache = True, |
---|
| 139 | # verbose = True |
---|
| 140 | ) |
---|
| 141 | |
---|
| 142 | |
---|
| 143 | #------------------------------------------------------------------------------- |
---|
| 144 | # Setup boundary conditions (all reflective) |
---|
| 145 | #------------------------------------------------------------------------------- |
---|
| 146 | |
---|
| 147 | print 'Available boundary tags', domain.get_boundary_tags() |
---|
| 148 | |
---|
| 149 | Br = Reflective_boundary(domain) |
---|
| 150 | # 10 min square wave starting at 1 min, 6m high |
---|
[2437] | 151 | Bw = Time_boundary(domain = domain, |
---|
[2436] | 152 | f=lambda t: [(20<t<200)*6, 0, 0]) |
---|
[2437] | 153 | |
---|
[2441] | 154 | domain.set_boundary( {'top': Br, 'topleft': Br, |
---|
[2436] | 155 | 'left': Br, 'bottom': Br, |
---|
| 156 | 'bottomright': Br, 'topright': Br} ) |
---|
| 157 | |
---|
| 158 | |
---|
| 159 | #------------------------------------------------------------------------------- |
---|
| 160 | # Evolve system through time |
---|
| 161 | #------------------------------------------------------------------------------- |
---|
| 162 | |
---|
| 163 | import time |
---|
| 164 | t0 = time.time() |
---|
| 165 | |
---|
[2441] | 166 | for t in domain.evolve(yieldstep = 10, finaltime = 20): |
---|
[2436] | 167 | domain.write_time() |
---|
| 168 | domain.write_boundary_statistics(tags = 'top') |
---|
| 169 | |
---|
| 170 | print 'That took %.2f seconds' %(time.time()-t0) |
---|