1 | """Script for running a tsunami inundation scenario for Onslow, WA, 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 project.outputtimedir |
---|
6 | |
---|
7 | The scenario is defined by a triangular mesh created from project.polygon, |
---|
8 | the elevation data and a simulated submarine landslide. |
---|
9 | |
---|
10 | Ole Nielsen and Duncan Gray, GA - 2005 and Nick Bartzis, GA - 2006 |
---|
11 | """ |
---|
12 | |
---|
13 | |
---|
14 | #-------------------------------------------------------------------------------# Import necessary modules |
---|
15 | #------------------------------------------------------------------------------- |
---|
16 | |
---|
17 | # Standard modules |
---|
18 | import time |
---|
19 | import sys |
---|
20 | from shutil import copy |
---|
21 | from os import mkdir, access, F_OK |
---|
22 | |
---|
23 | # Related major packages |
---|
24 | from pyvolution.shallow_water import Domain, Reflective_boundary, \ |
---|
25 | Dirichlet_boundary, Time_boundary, File_boundary |
---|
26 | from pyvolution.util import Screen_Catcher |
---|
27 | from pyvolution.region import Set_region |
---|
28 | |
---|
29 | # Application specific imports |
---|
30 | import project # Definition of file names and polygons |
---|
31 | import create_mesh |
---|
32 | |
---|
33 | |
---|
34 | #------------------------------------------------------------------------------- |
---|
35 | # Setup archiving of simulations |
---|
36 | #------------------------------------------------------------------------------- |
---|
37 | |
---|
38 | copy (project.codedirname, project.outputtimedir + 'project.py') |
---|
39 | copy (project.codedir + 'run_dam.py', project.outputtimedir + 'run_dam.py') |
---|
40 | copy (project.codedir + 'create_mesh.py', project.outputtimedir + 'create_mesh.py') |
---|
41 | print'output dir', project.outputtimedir |
---|
42 | |
---|
43 | #normal screen output is stored in |
---|
44 | screen_output_name = project.outputtimedir + "screen_output.txt" |
---|
45 | screen_error_name = project.outputtimedir + "screen_error.txt" |
---|
46 | |
---|
47 | #------------------------------------------------------------------------------- |
---|
48 | # Create the triangular mesh |
---|
49 | #------------------------------------------------------------------------------- |
---|
50 | |
---|
51 | create_mesh.generate() # this creates the mesh |
---|
52 | |
---|
53 | #------------------------------------------------------------------------------- |
---|
54 | # Setup computational domain |
---|
55 | #------------------------------------------------------------------------------- |
---|
56 | domain = Domain(project.mesh_filename, use_cache = False, verbose = True) |
---|
57 | |
---|
58 | |
---|
59 | print 'Number of triangles = ', len(domain) |
---|
60 | print 'The extent is ', domain.get_extent() |
---|
61 | print domain.statistics() |
---|
62 | |
---|
63 | domain.set_name(project.basename) |
---|
64 | domain.set_datadir(project.outputtimedir) |
---|
65 | domain.set_quantities_to_be_stored(['stage', 'xmomentum', 'ymomentum']) |
---|
66 | |
---|
67 | #------------------------------------------------------------------------------- |
---|
68 | # Setup initial conditions |
---|
69 | #------------------------------------------------------------------------------- |
---|
70 | |
---|
71 | tide = 0.0 |
---|
72 | |
---|
73 | def elevation_tilt(x, y): |
---|
74 | return -x*0.15 |
---|
75 | |
---|
76 | domain.set_quantity('stage', elevation_tilt) |
---|
77 | domain.set_quantity('friction', 0.03) |
---|
78 | domain.set_quantity('elevation',elevation_tilt) |
---|
79 | |
---|
80 | print 'Available boundary tags', domain.get_boundary_tags() |
---|
81 | |
---|
82 | domain.set_region(Set_region('dam','stage',0.4,location = 'unique vertices')) |
---|
83 | |
---|
84 | Br = Reflective_boundary(domain) |
---|
85 | Bd = Dirichlet_boundary([tide,0,0]) |
---|
86 | |
---|
87 | #domain.set_boundary( {'wall': Br, 'wave': Bw} ) |
---|
88 | domain.set_boundary( {'wall': Br, 'wave': Br} ) |
---|
89 | |
---|
90 | #------------------------------------------------------------------------------- |
---|
91 | # Evolve system through time |
---|
92 | #------------------------------------------------------------------------------- |
---|
93 | import time |
---|
94 | t0 = time.time() |
---|
95 | |
---|
96 | for t in domain.evolve(yieldstep = 0.1, finaltime = 5): |
---|
97 | domain.write_time() |
---|
98 | |
---|
99 | print 'That took %.2f seconds' %(time.time()-t0) |
---|
100 | |
---|
101 | print 'finished' |
---|