1 | |
---|
2 | |
---|
3 | from anuga.geospatial_data.geospatial_data import * |
---|
4 | from anuga.pmesh.mesh_interface import create_mesh_from_regions |
---|
5 | from anuga.shallow_water import Domain |
---|
6 | from anuga.shallow_water import Reflective_boundary |
---|
7 | from anuga.shallow_water.data_manager import export_grid |
---|
8 | from math import sqrt |
---|
9 | |
---|
10 | data_dir='/d/ehn/4/ehn/tsunami/data/bathymetry/Cocos/bathymetry/' |
---|
11 | data_dir_name = data_dir + 'new_edited_cocos_final' |
---|
12 | |
---|
13 | data_dir_name_small=data_dir_name+'_small' |
---|
14 | data_dir_name_smaller=data_dir_name+'_smaller' |
---|
15 | data_dir_name_small_clip=data_dir_name+'_small_clip' |
---|
16 | data_dir_name_clip=data_dir_name+'_clip' |
---|
17 | #print'create Geospatial data2 objects from coast' |
---|
18 | #G = Geospatial_data(file_name = data_dir_name + '.txt') |
---|
19 | #print'start split' |
---|
20 | #G_small, G_other = G.split(factor=0.1, verbose=True) |
---|
21 | #print'start export' |
---|
22 | #G_small.export_points_file(data_dir_name_smaller + '.txt') |
---|
23 | |
---|
24 | mesh_file=data_dir+'cocos.msh' |
---|
25 | sww_file='test_final' |
---|
26 | |
---|
27 | #grid1_north_max=8783110.00 |
---|
28 | #grid1_north_min=8565314.80 |
---|
29 | #grid1_east_max=439850.00 |
---|
30 | #grid1_east_min=156494.00 |
---|
31 | # |
---|
32 | #grid2_north_max=8713178.04 |
---|
33 | #grid2_north_min=8625096.92 |
---|
34 | #grid2_east_max=294652.80 |
---|
35 | #grid2_east_min=224424.96 |
---|
36 | # |
---|
37 | #grid3_north_max=274295.91 |
---|
38 | #grid3_north_min=266767.44 |
---|
39 | #grid3_east_max=8665112.56 |
---|
40 | #grid3_east_min=8657346.91 |
---|
41 | # |
---|
42 | #grid4_north_max=270900.24 |
---|
43 | #grid4_north_min=269701.45 |
---|
44 | #grid4_east_max=8659120.05 |
---|
45 | #grid4_east_min=8659120.05 |
---|
46 | |
---|
47 | poly1 = [[439850.00,8565314.80],[439850.00, 8783110.00], |
---|
48 | [156494.00,8783110.00],[156494.00,8565314.80]] |
---|
49 | # 68450m2 |
---|
50 | |
---|
51 | poly2 = [[294652.80,8625096.92],[294652.80,8713178.04], |
---|
52 | [224424.96,8713178.04],[224424.96,8625096.92]] |
---|
53 | # 2738m2 |
---|
54 | |
---|
55 | poly3 = [[274295.91,8657346.91],[274295.91,8665112.56], |
---|
56 | [266767.44,8665112.56],[266767.44,8657346.91]] |
---|
57 | # 110m2 |
---|
58 | |
---|
59 | poly4 = [[270900.24,8659120.05],[270900.24,8660170.84], |
---|
60 | [269701.45,8660170.84],[269701.45,8659120.05]] |
---|
61 | # 4.3m2 |
---|
62 | |
---|
63 | res = 1 |
---|
64 | #G = Geospatial_data(file_name = data_dir_name + '.txt') |
---|
65 | #G1=G.clip(poly1) |
---|
66 | #G1.export_points_file(data_dir_name_clip + '.txt') |
---|
67 | |
---|
68 | |
---|
69 | interior_polys = [[poly2,2740*res],[poly3,110*res],[poly4,4.3*res]] |
---|
70 | #interior_polys = [[poly4,4.3*res]] |
---|
71 | |
---|
72 | #create_mesh_from_regions(poly1, |
---|
73 | # boundary_tags={'side': [0,1,2,3]}, |
---|
74 | # maximum_triangle_area=68500*res, |
---|
75 | # interior_regions=interior_polys, |
---|
76 | # filename=mesh_file, |
---|
77 | # use_cache=True, |
---|
78 | # verbose=True) |
---|
79 | create_mesh_from_regions(poly1, |
---|
80 | #create_mesh_from_regions(poly3, |
---|
81 | boundary_tags={'side': [0,1,2,3]}, |
---|
82 | maximum_triangle_area=68500*res, |
---|
83 | # maximum_triangle_area=110*res, |
---|
84 | interior_regions=interior_polys, |
---|
85 | filename=mesh_file, |
---|
86 | use_cache=True, |
---|
87 | verbose=True) |
---|
88 | |
---|
89 | |
---|
90 | value, alpha = find_optimal_smoothing_parameter(data_file=data_dir_name_clip + '.txt', |
---|
91 | alpha_list=[0.0001,0.001,0.01,0.1,1.0], |
---|
92 | # alpha_list=[0.01], |
---|
93 | boundary_poly=poly3, |
---|
94 | mesh_file=mesh_file, |
---|
95 | plot_name=None, |
---|
96 | cache=True, |
---|
97 | verbose=True) |
---|
98 | |
---|
99 | print 'Setup computational domain', value, alpha |
---|
100 | |
---|
101 | #domain = cache(Domain, (meshes_dir_name), {'use_cache':True, 'verbose':True}, verbose=True) |
---|
102 | #above don't work |
---|
103 | domain = Domain(mesh_file, use_cache=True, verbose=True) |
---|
104 | |
---|
105 | print 'Start Set quantity' |
---|
106 | |
---|
107 | domain.set_quantity('elevation', |
---|
108 | filename = data_dir_name_clip + '.txt', |
---|
109 | use_cache = True, |
---|
110 | verbose = True, |
---|
111 | alpha = alpha) |
---|
112 | print 'Finished Set quantity' |
---|
113 | |
---|
114 | domain.set_name(sww_file) |
---|
115 | domain.set_datadir(data_dir) |
---|
116 | domain.set_default_order(2) # Apply second order scheme |
---|
117 | domain.set_minimum_storable_height(0.01) # Don't store anything less than 1cm |
---|
118 | domain.set_store_vertices_uniquely(False) |
---|
119 | domain.set_quantities_to_be_stored(['stage', 'xmomentum', 'ymomentum']) |
---|
120 | # domain.set_maximum_allowed_speed(0.1) # Allow a little runoff (0.1 is OK) |
---|
121 | domain.beta_h = 0 |
---|
122 | Br = Reflective_boundary(domain) |
---|
123 | |
---|
124 | |
---|
125 | domain.set_boundary({'side': Br}) |
---|
126 | |
---|
127 | for t in domain.evolve(yieldstep = 1,finaltime =1): |
---|
128 | domain.write_time() |
---|
129 | domain.write_boundary_statistics(tags = 'side') |
---|
130 | |
---|
131 | export_grid(data_dir+sww_file+".sww", extra_name_out = 'grid4', |
---|
132 | quantities = ['elevation'], # '(xmomentum**2 + ymomentum**2)**0.5' defaults to elevation |
---|
133 | timestep = None, |
---|
134 | reduction = max, |
---|
135 | cellsize = 2.96*sqrt(res), |
---|
136 | NODATA_value = -9999, |
---|
137 | easting_min = 269701.45, |
---|
138 | easting_max = 270900.24, |
---|
139 | northing_min = 8659120.05, |
---|
140 | northing_max = 8660170.84, |
---|
141 | verbose = True, |
---|
142 | origin = None, |
---|
143 | datum = 'WGS84', |
---|
144 | format = 'asc') |
---|
145 | |
---|
146 | export_grid(data_dir+sww_file+".sww", extra_name_out = 'grid3', |
---|
147 | quantities = ['elevation'], # '(xmomentum**2 + ymomentum**2)**0.5' defaults to elevation |
---|
148 | timestep = None, |
---|
149 | reduction = max, |
---|
150 | cellsize = 14.82*sqrt(res), |
---|
151 | NODATA_value = -9999, |
---|
152 | easting_min = 266767.44, |
---|
153 | easting_max = 274295.91, |
---|
154 | northing_min = 8657346.91, |
---|
155 | northing_max = 8665112.56, |
---|
156 | verbose = True, |
---|
157 | origin = None, |
---|
158 | datum = 'WGS84', |
---|
159 | format = 'asc') |
---|
160 | |
---|
161 | export_grid(data_dir+sww_file+".sww", extra_name_out = 'grid2', |
---|
162 | quantities = ['elevation'], # '(xmomentum**2 + ymomentum**2)**0.5' defaults to elevation |
---|
163 | timestep = None, |
---|
164 | reduction = max, |
---|
165 | cellsize = 74.08*sqrt(res), |
---|
166 | NODATA_value = -9999, |
---|
167 | easting_min = 224424.96, |
---|
168 | easting_max = 294652.80, |
---|
169 | northing_min = 8625096.92, |
---|
170 | northing_max = 8713178.04, |
---|
171 | verbose = True, |
---|
172 | origin = None, |
---|
173 | datum = 'WGS84', |
---|
174 | format = 'asc') |
---|
175 | |
---|
176 | export_grid(data_dir+sww_file+".sww", extra_name_out = 'grid1', |
---|
177 | quantities = ['elevation'], # '(xmomentum**2 + ymomentum**2)**0.5' defaults to elevation |
---|
178 | timestep = None, |
---|
179 | reduction = max, |
---|
180 | cellsize = 370.4*sqrt(res), |
---|
181 | NODATA_value = -9999, |
---|
182 | easting_min = 156494.00, |
---|
183 | easting_max = 439850.00, |
---|
184 | northing_min = 8565314.80, |
---|
185 | northing_max = 8783110.00, |
---|
186 | verbose = True, |
---|
187 | origin = None, |
---|
188 | datum = 'WGS84', |
---|
189 | format = 'asc') |
---|
190 | |
---|
191 | |
---|
192 | |
---|
193 | |
---|