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 | |
---|
22 | # Related major packages |
---|
23 | import anuga |
---|
24 | |
---|
25 | from anuga_parallel import distribute, myid |
---|
26 | import liststore |
---|
27 | from anuga.abstract_2d_finite_volumes.util import add_directories |
---|
28 | from anuga.utilities import system_tools, log |
---|
29 | |
---|
30 | |
---|
31 | home2 = os.getenv('INUNDATIONHOME') |
---|
32 | |
---|
33 | scenariodir2 = add_directories(home2, ["data", "mem_time_test", "triangles", "area"]) |
---|
34 | |
---|
35 | store ='store.txt' |
---|
36 | file_path_store = os.path.join(scenariodir2, store) |
---|
37 | h = 'cairnsmesh.msh' |
---|
38 | file_pathh = os.path.join(scenariodir2, h) |
---|
39 | |
---|
40 | |
---|
41 | system_tools.MemoryUpdate() |
---|
42 | #------------------------------------------------------------------------------ |
---|
43 | # Create the triangular mesh and domain based on |
---|
44 | # overall clipping polygon with a tagged |
---|
45 | # boundary and interior regions as defined in project.py |
---|
46 | #------------------------------------------------------------------------------ |
---|
47 | if myid == 0: |
---|
48 | domain = anuga.create_domain_from_regions([(0.0,0.0),(10000.0,10000.0),(0.0,10000.0),(10000.0,0.0)], |
---|
49 | boundary_tags={'top': [0], |
---|
50 | 'right': [1], |
---|
51 | 'bottom': [2], |
---|
52 | 'left': [3]}, |
---|
53 | maximum_triangle_area=100.0, |
---|
54 | mesh_filename=file_pathh |
---|
55 | #,interior_regions=INTERIORREGIONS#, |
---|
56 | #use_cache=True, |
---|
57 | #verbose=True) |
---|
58 | ) |
---|
59 | |
---|
60 | # Print some stats about mesh and domain |
---|
61 | #print 'Number of triangles = ', len(domain) |
---|
62 | #print 'The extent is ', domain.get_extent() |
---|
63 | #print domain.statistics() |
---|
64 | else: |
---|
65 | domain = None |
---|
66 | |
---|
67 | domain = distribute(domain) |
---|
68 | |
---|
69 | #------------------------------------------------------------------------------ |
---|
70 | # Setup parameters of computational domain |
---|
71 | #------------------------------------------------------------------------------ |
---|
72 | domain.set_name('CAIRNS') # Name of sww file |
---|
73 | domain.set_datadir(scenariodir2) # Store sww output here |
---|
74 | |
---|
75 | #------------------------------------------------------------------------------ |
---|
76 | # Setup initial conditions |
---|
77 | #------------------------------------------------------------------------------ |
---|
78 | |
---|
79 | def topography(x,y): |
---|
80 | return 0.0 |
---|
81 | |
---|
82 | tide = 100.0 |
---|
83 | friction = 0.0 |
---|
84 | domain.set_quantity('stage', tide) |
---|
85 | domain.set_quantity('friction', friction) |
---|
86 | domain.set_quantity('elevation',topography,alpha=0.1) |
---|
87 | |
---|
88 | |
---|
89 | |
---|
90 | #------------------------------------------------------------------------------ |
---|
91 | # Setup boundary conditions |
---|
92 | #------------------------------------------------------------------------------ |
---|
93 | |
---|
94 | Bi = anuga.Dirichlet_boundary([tide, 223.52, 0]) # inflow |
---|
95 | Bo = anuga.Dirichlet_boundary([-tide, 223.52, 0]) # inflow |
---|
96 | Bs = anuga.Transmissive_stage_zero_momentum_boundary(domain) # Neutral boundary |
---|
97 | Br = anuga.Reflective_boundary(domain) |
---|
98 | #Bw = anuga.Time_boundary(domain=domain,function=lambda t: [(60<t<3660)*50, 0, 0]) |
---|
99 | domain.set_boundary({'right': Bo, |
---|
100 | 'bottom': Br, |
---|
101 | 'left': Bi, |
---|
102 | 'top': Br}) |
---|
103 | |
---|
104 | #------------------------------------------------------------------------------ |
---|
105 | # Evolve system through time |
---|
106 | #------------------------------------------------------------------------------ |
---|
107 | |
---|
108 | # Save every two mins leading up to wave approaching land |
---|
109 | for t in domain.evolve(yieldstep=120, finaltime=2000): |
---|
110 | print domain.timestepping_statistics() |
---|
111 | |
---|
112 | |
---|
113 | liststore.spacelist[myid] = system_tools.MemoryUpdate()[0] |
---|
114 | a = sum(liststore.spacelist) |
---|
115 | print liststore.spacelist |
---|
116 | |
---|
117 | f = open(file_path_store, 'r+') |
---|
118 | f.write(str(a)) |
---|
119 | |
---|