[8317] | 1 | """Script for running a tsunami inundation scenario for Cairns, QLD Australia. |
---|
| 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 directory named after the scenario, i.e |
---|
| 6 | slide or fixed_wave. |
---|
| 7 | |
---|
| 8 | The scenario is defined by a triangular mesh created from project.polygon, |
---|
| 9 | the elevation data and a tsunami wave generated by a submarine mass failure. |
---|
| 10 | |
---|
| 11 | Geoscience Australia, 2004-present |
---|
| 12 | """ |
---|
| 13 | |
---|
| 14 | #------------------------------------------------------------------------------ |
---|
| 15 | # Import necessary modules |
---|
| 16 | #------------------------------------------------------------------------------ |
---|
| 17 | # Standard modules |
---|
| 18 | import os |
---|
| 19 | import time |
---|
| 20 | import sys |
---|
| 21 | import liststore |
---|
| 22 | |
---|
| 23 | # Related major packages |
---|
| 24 | import anuga |
---|
| 25 | from anuga_parallel import distribute, myid |
---|
| 26 | from anuga.abstract_2d_finite_volumes.util import add_directories |
---|
| 27 | from anuga.utilities import system_tools, log |
---|
| 28 | |
---|
| 29 | |
---|
| 30 | home2 = os.getenv('INUNDATIONHOME') |
---|
| 31 | |
---|
| 32 | scenariodir2 = add_directories(home2, ["data", "mem_time_test", "triangles", "area"]) |
---|
| 33 | |
---|
| 34 | h = 'CAIRNS.msh' |
---|
| 35 | file_pathh = os.path.join(scenariodir2, h) |
---|
| 36 | store ='store.txt' |
---|
| 37 | file_path_store = os.path.join(scenariodir2, store) |
---|
| 38 | storen ='storen.txt' |
---|
| 39 | file_path_storen = os.path.join(scenariodir2, storen) |
---|
| 40 | storel = 'storel.txt' |
---|
| 41 | file_path_storel = os.path.join(scenariodir2, storel) |
---|
| 42 | storea = 'storea.txt' |
---|
| 43 | file_path_storea = os.path.join(scenariodir2, storea) |
---|
| 44 | |
---|
| 45 | f = open(file_path_storel,'r+') # SQRT extent this is set |
---|
| 46 | length = float(f.readline()) |
---|
| 47 | f.close() |
---|
| 48 | |
---|
| 49 | f = open(file_path_storea,'r+') #maxarea this is set |
---|
| 50 | area = float(f.readline()) |
---|
| 51 | f.close() |
---|
| 52 | |
---|
| 53 | system_tools.MemoryUpdate() |
---|
| 54 | #------------------------------------------------------------------------------ |
---|
| 55 | # Create the triangular mesh and domain based on |
---|
| 56 | # overall clipping polygon with a tagged |
---|
| 57 | # boundary and interior regions as defined in project.py |
---|
| 58 | #------------------------------------------------------------------------------ |
---|
| 59 | if myid == 0: |
---|
| 60 | domain = anuga.create_domain_from_regions([(0.0,0.0),(length,length),(0.0,length),(length,0.0)], |
---|
| 61 | boundary_tags={'top': [0], |
---|
| 62 | 'right': [1], |
---|
| 63 | 'bottom': [2], |
---|
| 64 | 'left': [3]}, |
---|
| 65 | maximum_triangle_area=area, |
---|
| 66 | mesh_filename=file_pathh |
---|
| 67 | #,interior_regions=INTERIORREGIONS#, |
---|
| 68 | #use_cache=True, |
---|
| 69 | #verbose=True) |
---|
| 70 | ) |
---|
| 71 | |
---|
| 72 | n = len(domain) |
---|
| 73 | else: |
---|
| 74 | domain = None |
---|
| 75 | |
---|
| 76 | domain = distribute(domain) |
---|
| 77 | |
---|
| 78 | #------------------------------------------------------------------------------ |
---|
| 79 | # Setup parameters of computational domain |
---|
| 80 | #------------------------------------------------------------------------------ |
---|
| 81 | domain.set_name('CAIRNS.sww') # Name of sww file |
---|
| 82 | domain.set_datadir(scenariodir2) # Store sww output here |
---|
| 83 | |
---|
| 84 | #------------------------------------------------------------------------------ |
---|
| 85 | # Setup initial conditions |
---|
| 86 | #------------------------------------------------------------------------------ |
---|
| 87 | |
---|
| 88 | def topography(x,y): |
---|
| 89 | return 0.0 |
---|
| 90 | |
---|
| 91 | tide = 100.0 |
---|
| 92 | friction = 0.0 |
---|
| 93 | domain.set_quantity('stage', tide) |
---|
| 94 | domain.set_quantity('friction', friction) |
---|
| 95 | domain.set_quantity('elevation',topography,alpha=0.1) |
---|
| 96 | |
---|
| 97 | |
---|
| 98 | |
---|
| 99 | #------------------------------------------------------------------------------ |
---|
| 100 | # Setup boundary conditions |
---|
| 101 | #------------------------------------------------------------------------------ |
---|
| 102 | |
---|
| 103 | Bi = anuga.Dirichlet_boundary([tide, 0, 0]) # inflow |
---|
| 104 | Bo = anuga.Dirichlet_boundary([-tide,0, 0]) # inflow |
---|
| 105 | Bs = anuga.Transmissive_stage_zero_momentum_boundary(domain) # Neutral boundary |
---|
| 106 | Br = anuga.Reflective_boundary(domain) |
---|
| 107 | #Bw = anuga.Time_boundary(domain=domain,function=lambda t: [(60<t<3660)*50, 0, 0]) |
---|
| 108 | domain.set_boundary({'right': Bo, |
---|
| 109 | 'bottom': Br, |
---|
| 110 | 'left': Bi, |
---|
| 111 | 'top': Br}) |
---|
| 112 | |
---|
| 113 | |
---|
| 114 | #------------------------------------------------------------------------------ |
---|
| 115 | # Evolve system through time |
---|
| 116 | #------------------------------------------------------------------------------ |
---|
| 117 | |
---|
| 118 | # Save every two mins leading up to wave approaching land |
---|
| 119 | for t in domain.evolve(yieldstep=500, finaltime=2000): |
---|
| 120 | print domain.timestepping_statistics() |
---|
| 121 | |
---|
| 122 | |
---|
| 123 | liststore.store[myid] = system_tools.MemoryUpdate()[0] |
---|
| 124 | a = sum(liststore.store) |
---|
| 125 | |
---|
| 126 | v = open(file_path_store, 'r+') |
---|
| 127 | v.write(str(a)) |
---|
| 128 | |
---|
| 129 | i = open(file_path_storen, 'r+') |
---|
| 130 | i.write(str(n)) |
---|
| 131 | |
---|
| 132 | |
---|