1 | """Anuga convergence study using a true-scale version of the Okushiri |
---|
2 | Island tsunami wavetank experiment |
---|
3 | |
---|
4 | This script runs a modified version of the Okushiri Island benchmark |
---|
5 | |
---|
6 | as published at |
---|
7 | |
---|
8 | THE THIRD INTERNATIONAL WORKSHOP ON LONG-WAVE RUNUP MODELS |
---|
9 | June 17-18 2004 |
---|
10 | Wrigley Marine Science Center |
---|
11 | Catalina Island, California |
---|
12 | http://www.cee.cornell.edu/longwave/ |
---|
13 | |
---|
14 | This version up-scales the original 1:400 scale wave-tank experiment, to |
---|
15 | "true-scale" with mesh defined using interior polygons. The resolution is then |
---|
16 | varied by a factor of 2 to investigate convergence behaviour (refer to script |
---|
17 | project_truescale.py for details). |
---|
18 | |
---|
19 | The original validation data is available at |
---|
20 | http://www.cee.cornell.edu/longwave/index.cfm?page=benchmark&problem=2 |
---|
21 | where a detailed description of the problem is also available. |
---|
22 | |
---|
23 | Run create_okushiri_truescale.py to convert bathymetry and input boundary |
---|
24 | condition into NetCDF format. |
---|
25 | |
---|
26 | """ |
---|
27 | #---------------------------------------- |
---|
28 | # Import necessary modules |
---|
29 | #---------------------------------------- |
---|
30 | |
---|
31 | # Standard modules |
---|
32 | from os import sep,umask |
---|
33 | from os.path import dirname, basename |
---|
34 | from os import mkdir, access, F_OK |
---|
35 | from shutil import copy |
---|
36 | import time |
---|
37 | import sys |
---|
38 | |
---|
39 | # Related major packages |
---|
40 | from anuga.shallow_water import Domain |
---|
41 | from anuga.shallow_water import Reflective_boundary |
---|
42 | from anuga.shallow_water import Transmissive_Momentum_Set_Stage_boundary |
---|
43 | from anuga.abstract_2d_finite_volumes.util import file_function |
---|
44 | from anuga.shallow_water.data_manager import copy_code_files, start_screen_catcher |
---|
45 | from anuga.pmesh.mesh_interface import create_mesh_from_regions |
---|
46 | |
---|
47 | |
---|
48 | import project_truescale # Definition of filenames and interior polygons |
---|
49 | |
---|
50 | copy_code_files(project_truescale.output_run_time_dir,'run_okushiri_truescale.py', |
---|
51 | 'project_truescale.py' ) |
---|
52 | myid = 0 |
---|
53 | numprocs = 1 |
---|
54 | start_screen_catcher(project_truescale.output_run_time_dir, myid, numprocs) |
---|
55 | |
---|
56 | #-------------------------------------------------------------------------- |
---|
57 | # Create the triangular mesh based on overall bounding polygon with a |
---|
58 | # tagged boundary and interior regions defined in project_truescale.py |
---|
59 | # along with resolutions (maximal area of per triangle) for each polygon |
---|
60 | #-------------------------------------------------------------------------- |
---|
61 | |
---|
62 | create_mesh_from_regions(project_truescale.poly_all, |
---|
63 | boundary_tags={'wall': [0, 1, 3],'wave': [2]}, |
---|
64 | maximum_triangle_area=project_truescale.res_poly_all, |
---|
65 | interior_regions=project_truescale.interior_regions, # comment out when not using interior polygon definitions |
---|
66 | filename=project_truescale.mesh_name+'.msh', |
---|
67 | verbose=True) |
---|
68 | |
---|
69 | #------------------------------ |
---|
70 | # Create Domain from mesh |
---|
71 | #------------------------------ |
---|
72 | domain = Domain(project_truescale.mesh_name+'.msh', use_cache=True, verbose=True) |
---|
73 | print domain.statistics() |
---|
74 | |
---|
75 | z = domain.get_vertex_coordinates() |
---|
76 | |
---|
77 | # Write vertex coordinates to file |
---|
78 | filename=project_truescale.vertex_filename |
---|
79 | fid=open(filename,'w') |
---|
80 | fid.write('x (m), y (m)\n') |
---|
81 | for i in range(len(z)): |
---|
82 | pt=z[i] |
---|
83 | x=pt[0] |
---|
84 | y=pt[1] |
---|
85 | fid.write('%.6f, %.6f\n' %(x, y)) |
---|
86 | |
---|
87 | #------------------------- |
---|
88 | # Initial Conditions |
---|
89 | #------------------------- |
---|
90 | domain.set_quantity('friction', 0.0) |
---|
91 | domain.set_quantity('stage', 0.0) |
---|
92 | domain.set_quantity('elevation', |
---|
93 | filename=project_truescale.bathymetry_filename, |
---|
94 | alpha=0.02, |
---|
95 | verbose=True, |
---|
96 | use_cache=True) |
---|
97 | |
---|
98 | |
---|
99 | #------------------------- |
---|
100 | # Set simulation parameters |
---|
101 | #------------------------- |
---|
102 | domain.set_name(project_truescale.output_filename) # Name of output sww file |
---|
103 | domain.set_datadir(project_truescale.output_run_time_dir) # Name of output directory |
---|
104 | domain.set_default_order(2) # Apply second order scheme |
---|
105 | domain.set_all_limiters(0.9) # Max second order scheme (old lim) |
---|
106 | domain.set_minimum_storable_height(0.1) # Don't store h < 0.1m |
---|
107 | |
---|
108 | |
---|
109 | #------------------------- |
---|
110 | # Boundary Conditions |
---|
111 | #------------------------- |
---|
112 | |
---|
113 | # Create boundary function from timeseries provided in file |
---|
114 | function = file_function(project_truescale.boundary_filename, |
---|
115 | domain, verbose=True) |
---|
116 | |
---|
117 | # Create and assign boundary objects |
---|
118 | Bts = Transmissive_Momentum_Set_Stage_boundary(domain, function) |
---|
119 | Br = Reflective_boundary(domain) |
---|
120 | domain.set_boundary({'wave': Bts, 'wall': Br}) |
---|
121 | |
---|
122 | |
---|
123 | # Select triangle containing ch5 for diagnostic output |
---|
124 | # around known gauge |
---|
125 | triangle_id = domain.get_triangle_containing_point([1808.4, 478.4]) |
---|
126 | # This should get triangle id 32833 with centroid (4.5244, 1.1972) |
---|
127 | |
---|
128 | |
---|
129 | #------------------------- |
---|
130 | # Evolve through time |
---|
131 | #------------------------- |
---|
132 | import time |
---|
133 | t0 = time.time() |
---|
134 | |
---|
135 | for t in domain.evolve(yieldstep=project_truescale.yieldstep, finaltime = 450): |
---|
136 | print domain.timestepping_statistics(track_speeds=False, |
---|
137 | triangle_id=triangle_id) |
---|
138 | print domain.boundary_statistics() |
---|
139 | |
---|
140 | print 'That took %.2f seconds' %(time.time()-t0) |
---|