1 | """Script for running tsunami inundation scenario for Dampier, 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.output_run_time_dir |
---|
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 Jane Sexton, Nick Bartzis, GA - 2006 |
---|
11 | """ |
---|
12 | |
---|
13 | #------------------------------------------------------------------------------ |
---|
14 | # Import necessary modules |
---|
15 | #------------------------------------------------------------------------------ |
---|
16 | |
---|
17 | # Standard modules |
---|
18 | from os import sep |
---|
19 | from os.path import dirname, basename |
---|
20 | from os import mkdir, access, F_OK |
---|
21 | from shutil import copy |
---|
22 | import time |
---|
23 | import sys |
---|
24 | |
---|
25 | |
---|
26 | # Related major packages |
---|
27 | from anuga.shallow_water import Domain |
---|
28 | from anuga.shallow_water import Dirichlet_boundary |
---|
29 | from anuga.shallow_water import File_boundary |
---|
30 | from anuga.shallow_water import Reflective_boundary |
---|
31 | |
---|
32 | from anuga.pmesh.mesh_interface import create_mesh_from_regions |
---|
33 | |
---|
34 | from anuga.geospatial_data.geospatial_data import * |
---|
35 | from anuga.abstract_2d_finite_volumes.util import Screen_Catcher |
---|
36 | from anuga_parallel.parallel_api import distribute, numprocs, myid |
---|
37 | |
---|
38 | # Application specific imports |
---|
39 | import project # Definition of file names and polygons |
---|
40 | |
---|
41 | |
---|
42 | |
---|
43 | #------------------------------------------------------------------------------ |
---|
44 | # Copy scripts to time stamped output directory and capture screen |
---|
45 | # output to file |
---|
46 | #------------------------------------------------------------------------------ |
---|
47 | |
---|
48 | # filenames |
---|
49 | |
---|
50 | build_time = '20061025_113524_build' |
---|
51 | boundaries_name = project.boundaries_name |
---|
52 | meshes_dir_name = project.meshes_dir_name+'.msh' |
---|
53 | #source_dir = project.boundarydir |
---|
54 | boundaries_time_dir_name = project.boundaries_dir + build_time + sep + boundaries_name |
---|
55 | |
---|
56 | |
---|
57 | #------------------------------------------------------------------------- |
---|
58 | # Setup computational domain |
---|
59 | #------------------------------------------------------------------------- |
---|
60 | print 'Setup computational domain' |
---|
61 | domain = Domain(meshes_dir_name, use_cache=True, verbose=True) |
---|
62 | print domain.statistics() |
---|
63 | |
---|
64 | |
---|
65 | #------------------------------------------------------------------------- |
---|
66 | # Setup initial conditions |
---|
67 | #------------------------------------------------------------------------- |
---|
68 | tide = project.tide |
---|
69 | domain.set_quantity('stage', tide) |
---|
70 | domain.set_quantity('friction', 0.0) |
---|
71 | #combined_time_dir_name = project.topographies_dir+build_time+project.combined_name |
---|
72 | domain.set_quantity('elevation', |
---|
73 | filename = project.topographies_dir + build_time + sep + project.combined_name + '.pts', |
---|
74 | use_cache = True, |
---|
75 | verbose = True, |
---|
76 | alpha = 0.1) |
---|
77 | |
---|
78 | |
---|
79 | #------------------------------------------------------ |
---|
80 | # Distribute domain to implement parallelism !!! |
---|
81 | #------------------------------------------------------ |
---|
82 | |
---|
83 | if numprocs > 1: |
---|
84 | domain=distribute(domain) |
---|
85 | |
---|
86 | |
---|
87 | #------------------------------------------------------ |
---|
88 | # Set domain parameters |
---|
89 | #------------------------------------------------------ |
---|
90 | |
---|
91 | domain.set_name(project.scenario_name) |
---|
92 | domain.set_datadir(project.output_run_time_dir) |
---|
93 | domain.set_default_order(2) #associate to the spatial order of the triangle |
---|
94 | domain.set_minimum_storable_height(0.01) # Don't store anything less than 1cm |
---|
95 | |
---|
96 | |
---|
97 | #------------------------------------------------------------------------- |
---|
98 | # Setup boundary conditions |
---|
99 | #------------------------------------------------------------------------- |
---|
100 | |
---|
101 | |
---|
102 | print 'Available boundary tags', domain.get_boundary_tags() |
---|
103 | |
---|
104 | |
---|
105 | Bf = File_boundary(boundaries_time_dir_name + '.sww', |
---|
106 | domain, verbose = True) |
---|
107 | Br = Reflective_boundary(domain) |
---|
108 | Bd = Dirichlet_boundary([tide,0,0]) |
---|
109 | domain.set_boundary({'back': Br, |
---|
110 | 'side': Bd, |
---|
111 | 'ocean': Bf}) |
---|
112 | |
---|
113 | #---------------------------------------------------------------------------- |
---|
114 | # Evolve system through time |
---|
115 | #---------------------------------------------------------------------------- |
---|
116 | import time |
---|
117 | t0 = time.time() |
---|
118 | |
---|
119 | for t in domain.evolve(yieldstep = 120, finaltime = 28800): |
---|
120 | domain.write_time() |
---|
121 | domain.write_boundary_statistics(tags = 'ocean') |
---|
122 | |
---|
123 | print 'That took %.2f seconds' %(time.time()-t0) |
---|
124 | |
---|