Changeset 1295
- Timestamp:
- May 8, 2005, 11:50:32 PM (20 years ago)
- Location:
- inundation/ga/storm_surge
- Files:
-
- 6 edited
Legend:
- Unmodified
- Added
- Removed
-
inundation/ga/storm_surge/Merimbula/run_merimbula_lake.py
r1292 r1295 4 4 Christopher Zoppou, Stephen Roberts, Ole Nielsen, Duncan Gray 5 5 Geoscience Australia, ANU 6 6 7 7 Specific methods pertaining to the 2D shallow water equation 8 8 are imported from shallow_water … … 25 25 from pmesh2domain import pmesh_to_domain_instance 26 26 from util import file_function, Polygon_function, read_polygon 27 from Numeric import zeros, Float 27 from Numeric import zeros, Float 28 28 29 29 #------- … … 36 36 37 37 #------------------------------------------ 38 # Reduction operation for get_vertex_values 38 # Reduction operation for get_vertex_values 39 39 from util import mean 40 domain.reduction = mean 40 domain.reduction = mean 41 41 42 42 #----------------- … … 176 176 # Initial water surface elevation 177 177 domain.set_quantity('stage', 0.0) 178 178 179 179 #---------------------------------------------------------- 180 180 # Decide which quantities are to be stored at each timestep … … 191 191 domain.default_order = 1 192 192 domain.visualise = True 193 domain.visualise_color_stage = True 194 domain.visualise_stage_range = 1.0 193 195 domain.smooth = True 194 196 195 197 #--------- 196 198 #Evolution … … 199 201 for t in domain.evolve(yieldstep = yieldstep, finaltime = finaltime): 200 202 domain.write_time() 201 203 202 204 print 'Done' 203 205 204 206 -
inundation/ga/storm_surge/pyvolution/netherlands.py
r1290 r1295 63 63 z[i] = -x[i]/20+0.4 64 64 65 if (x[i] - 0.72)**2 + (y[i] - 0.4)**2 < 0.05**2:# or\ 66 #x[i] > 0.75 and x[i] < 0.9 and y[i] > 0.35 and y[i] < 0.45: 67 z[i] = -x[i]/20+0.4 68 65 69 #Wall 66 70 if x[i] > 0.995: … … 79 83 N = 130 #size = 33800 80 84 N = 600 #Size = 720000 81 N = 3085 N = 40 82 86 83 87 #N = 15 … … 100 104 print "Number of triangles = ", len(domain) 101 105 106 #Set bed-slope and friction 107 inflow_stage = 0.4 108 manning = 0.02 109 Z = Weir(inflow_stage) 102 110 103 111 if N > 150: … … 112 120 else: 113 121 domain.visualise = True 122 domain.visualise_color_stage = True 123 domain.visualise_timer = True 114 124 domain.checkpoint = False 115 125 domain.store = False 116 126 117 118 #Set bed-slope and friction119 inflow_stage = 0.1120 manning = 0.02121 Z = Weir(inflow_stage)122 127 123 128 print 'Field values' … … 134 139 135 140 #Constant inflow 136 Bd = Dirichlet_boundary([ 2*inflow_stage, 0.0, 0.0])141 Bd = Dirichlet_boundary([inflow_stage, 0.0, 0.0]) 137 142 138 143 … … 151 156 t0 = time.time() 152 157 153 for t in domain.evolve(yieldstep = 0. 2, finaltime = 10.0):158 for t in domain.evolve(yieldstep = 0.05, finaltime = 10.0): 154 159 domain.write_time() 155 160 -
inundation/ga/storm_surge/pyvolution/realtime_visualisation.py
r773 r1295 11 11 #n = vector(0,0,0) 12 12 13 return n 13 return n 14 14 15 15 … … 20 20 21 21 #Outward normal 22 22 23 23 self.normal=normal(v1-v0, v2-v0) 24 24 25 25 self.panel = faces(frame = frame) 26 self.backpanel = faces(frame = frame) 26 self.backpanel = faces(frame = frame) 27 27 for v in (v0,v1,v2): 28 28 self.panel.append(pos=v, normal = self.normal, color=color) 29 29 30 30 for v in (v2,v1,v0): 31 self.backpanel.append(pos=v, normal = -self.normal, color=color) 32 33 31 self.backpanel.append(pos=v, normal = -self.normal, color=color) 32 33 34 34 def move(self,v): 35 35 """Move panel in direction given by vector v … … 37 37 38 38 for vertex in self.panel.pos: 39 vertex += v 39 vertex += v 40 40 41 41 def update_height(self,d,fix_baseline=False): … … 47 47 v0 = self.panel.pos[0] 48 48 v1 = self.panel.pos[1] 49 v2 = self.panel.pos[2] 50 49 v2 = self.panel.pos[2] 50 51 51 n = normal(v1-v0, self.normal) 52 52 … … 54 54 self.panel.pos[2] -= d*n 55 55 else: 56 self.panel.pos[:2] += d*n 56 self.panel.pos[:2] += d*n 57 57 58 58 def update_color(self, c): … … 61 61 62 62 self.panel.color = c 63 63 64 64 65 65 def set_vertexheights(self, heights, floor_heights = None): … … 70 70 floor_heights = zeros(heights.shape, Float) 71 71 72 all_vertices_below_threshold = True 72 all_vertices_below_threshold = True 73 73 for k in range(3): 74 74 w = heights[k] … … 77 77 if w-z >= hmin: 78 78 all_vertices_below_threshold = False 79 79 80 80 vertex = self.panel.pos[k] 81 81 vertex[2] = w … … 85 85 86 86 87 #Update color to visualise dry areas 88 if all_vertices_below_threshold: 87 #Update color to visualise dry areas 88 if all_vertices_below_threshold: 89 89 self.panel.color = self.bottom_color 90 self.backpanel.color = self.bottom_color 90 self.backpanel.color = self.bottom_color 91 91 else: 92 92 self.panel.color = self.top_color … … 94 94 95 95 96 #update normal 96 #update normal 97 97 v0 = self.panel.pos[0] 98 98 v1 = self.panel.pos[1] … … 104 104 self.backpanel.normal=-n 105 105 106 106 107 107 108 108 … … 120 120 except: 121 121 bed = False 122 122 123 123 N = Q.vertex_values.shape[0] 124 124 … … 128 128 z0 = Q.vertex_values[i, 0] 129 129 z1 = Q.vertex_values[i, 1] 130 z2 = Q.vertex_values[i, 2] 130 z2 = Q.vertex_values[i, 2] 131 131 132 132 x0, y0 = domain.get_vertex_coordinate(i,0) 133 133 x1, y1 = domain.get_vertex_coordinate(i,1) 134 x2, y2 = domain.get_vertex_coordinate(i,2) 135 134 x2, y2 = domain.get_vertex_coordinate(i,2) 135 136 136 V0 = vector(x0, y0, z0) 137 137 V1 = vector(x1, y1, z1) … … 149 149 150 150 col = (c0,c1,c2) 151 151 152 152 visual_top = Triangle(V0,V1,V2,color=col,frame=fr) 153 153 visual_top.top_color = col 154 154 155 155 156 156 #Bottom surface 157 157 #v0, v1, v2 = volume.vertices … … 168 168 V0 = vector(x0, y0, z0) 169 169 V1 = vector(x1, y1, z1) 170 V2 = vector(x2, y2, z2) 170 V2 = vector(x2, y2, z2) 171 171 172 172 c0 = 0.3 … … 176 176 c2 = 0.4*c2 #To show triangles in slightly different shades 177 177 178 col = (c0,c1,c2) 178 col = (c0,c1,c2) 179 179 visual_bottom = Triangle(V0, V1, V2, color=col,frame=fr) 180 180 visual_top.bottom_color=col 181 181 182 182 domain.visuals.append( (visual_top, visual_bottom) ) 183 183 184 184 update(domain) 185 #print 'Scale', scene.scale 186 187 188 def update(domain): 185 #print 'Scale', scene.scale 186 187 188 def update(domain): 189 189 """Update vertex heights. 190 The argument index refers to which conserved quantity to visualise. 190 The argument index refers to which conserved quantity to visualise. 191 191 If domain.smooth is set True, vertex values will be averaged 192 192 yielding a smoother surface. … … 198 198 Q = domain.quantities['stage'] 199 199 N = Q.vertex_values.shape[0] 200 200 201 201 #print scene.forward 202 202 #FIXME: Use smoother from pyvolution instead … … 218 218 219 219 220 for k in range(N): 220 for k in range(N): 221 221 if domain.smooth: 222 222 #The averages 223 223 x = zeros(3, Float) 224 for i in range(3): 224 for i in range(3): 225 225 vertex = domain.triangles[k, i] 226 226 A = array(vertex_heights[vertex]) 227 227 x[i] = sum(A)/len(A) 228 else: 228 else: 229 229 #The true values 230 230 x = [Q.vertex_values[k, 0], … … 232 232 Q.vertex_values[k, 2]] 233 233 234 234 235 235 #Do it 236 236 floor_heights = array([pos[2] for pos in domain.visuals[k][1].panel.pos]) 237 237 238 238 domain.visuals[k][0].set_vertexheights(x, floor_heights) 239 239 … … 246 246 #Original 247 247 scene.center = (0.5,0.5,0) 248 scene.forward = vector( -0.1, 0.5, -0.5)248 scene.forward = vector(0.0, 0.5, -0.5) 249 249 250 250 #Temporary (for bedslope) 251 #scene.forward = vector(0.0006, 0.7, -0.03) 251 #scene.forward = vector(0.0006, 0.7, -0.03) 252 252 253 253 … … 258 258 #Temporary for hackett - end 259 259 260 260 261 261 scene.ambient = 0.4 262 262 scene.lights = [(0.6, 0.3, 0.2), (0.1, -0.5, 0.4), (-0.1, 0.1, -0.4), … … 266 266 267 267 268 -
inundation/ga/storm_surge/pyvolution/realtime_visualisation_new.py
r1290 r1295 59 59 self.border_model = curve(frame = self.frame, 60 60 pos=[(0,0),(0,1),(1,1),(1,0),(0,0)]) 61 self.timer=label(pos=(0.75,0. 5,0.5),text='Time=%10.5e'%self.domain.time)61 self.timer=label(pos=(0.75,0.75,0.5),text='Time=%10.5e'%self.domain.time) 62 62 63 63 #scene.autoscale=0 … … 135 135 136 136 137 try:138 137 #try: 138 self.update_arrays_color(self.domain.quantities[qname].vertex_values, qcolor) 139 139 140 140 #print 'update bed image' 141 142 143 144 except:145 print 'Visualisation: Could not update quantity '+qname146 pass141 self.z_models[qname].pos = self.pos 142 self.z_models[qname].color = self.colour 143 self.z_models[qname].normal = self.normals 144 #except: 145 # print 'Visualisation: Could not update quantity '+qname 146 # pass 147 147 148 148 … … 189 189 colour = self.colour 190 190 191 try:192 update_arrays_color_weave(vertices,quantity,col,pos,normals,colour,N,191 #try: 192 update_arrays_color_python(vertices,quantity,col,pos,normals,colour,N, 193 193 min_x,min_y,range_xy,range_z,scale_z) 194 except:195 update_arrays_color_python(vertices,quantity,col,pos,normals,colour,N,196 min_x,min_y,range_xy,range_z,scale_z)194 #except: 195 # update_arrays_color_python(vertices,quantity,col,pos,normals,colour,N, 196 # min_x,min_y,range_xy,range_z,scale_z) 197 197 198 198 … … 359 359 pos[6*i+5,:] = v[1,:] 360 360 361 s = abs(v(2,j)) 362 363 colour[6*i ,:] = s*col 364 colour[6*i+1,:] = s*col 365 colour[6*i+2,:] = s*col 366 colour[6*i+3,:] = s*col 367 colour[6*i+4,:] = s*col 368 colour[6*i+5,:] = s*col 361 q0 = quantity[i,0]/0.4 362 q1 = quantity[i,1]/0.4 363 q2 = quantity[i,2]/0.4 364 365 q0r = min(q0,0.0) 366 q1r = min(q1,0.0) 367 q2r = min(q2,0.0) 368 q0b = max(q0,0.0) 369 q1b = max(q1,0.0) 370 q2b = max(q2,0.0) 371 372 373 colour[6*i ,:] = s*array([0.3 - q0r, 0.3 - q0, 0.3 + q0b]) 374 colour[6*i+1,:] = s*array([0.3 - q1r, 0.3 - q1, 0.3 + q1b]) 375 colour[6*i+2,:] = s*array([0.3 - q2r, 0.3 - q2, 0.3 + q2b]) 376 colour[6*i+3,:] = s*array([0.3 - q0r, 0.3 - q0, 0.3 + q0b]) 377 colour[6*i+4,:] = s*array([0.3 - q2r, 0.3 - q2, 0.3 + q2b]) 378 colour[6*i+5,:] = s*array([0.3 - q1r, 0.3 - q1, 0.3 + q1b]) 369 379 370 380 s = 15.0/8.0 - s … … 417 427 normal(2) = normal(2)/norm; 418 428 419 s = 0.2+fabs((v(0,2)+v(1,2)+v(2,2))/3.0); 429 420 430 421 431 for (int j=0; j<3; j++) { … … 427 437 pos(6*i+5,j) = v(1,j); 428 438 429 430 431 432 colour(6*i ,j) = s*col(j);433 colour(6*i+1,j) = s*col(j);434 colour(6*i+2,j) = s*col(j);435 colour(6*i+3,j) = s*col(j);436 colour(6*i+4,j) = s*col(j);437 colour(6*i+5,j) = s*col(j);438 439 439 normals(6*i ,j) = normal(j); 440 440 normals(6*i+1,j) = normal(j); … … 445 445 } 446 446 447 s = 0.2+fabs((v(0,2)+v(1,2)+v(2,2))/3.0); 448 for (int j=0; j<3; j++) { 449 colour(6*i ,j) = s*col(j); 450 colour(6*i+1,j) = s*col(j); 451 colour(6*i+2,j) = s*col(j); 452 colour(6*i+3,j) = s*col(j); 453 colour(6*i+4,j) = s*col(j); 454 colour(6*i+5,j) = s*col(j); 455 } 447 456 s = 15.0/8.0 - s; 448 457 } … … 459 468 #Original 460 469 scene.center = (0.5,0.5,0.0) 461 scene.forward = vector(-0. 1, 0.5, -0.5)470 scene.forward = vector(-0.0, 0.5, -0.8) 462 471 463 472 #Temporary (for bedslope) … … 492 501 493 502 surface = domain.surface 494 surface.update_quantity('stage') 495 surface.update_timer() 503 if domain.visualise_color_stage: 504 surface.update_quantity_color('stage') 505 else: 506 surface.update_quantity('stage') 507 508 if domain.visualise_timer: 509 surface.update_timer() -
inundation/ga/storm_surge/pyvolution/shallow_water.py
r1265 r1295 80 80 #Realtime visualisation 81 81 self.visualise = False 82 self.visualise_color_stage = False 83 self.visualise_stage_range = 1.0 84 self.visualise_timer = False 82 85 83 86 #Stored output
Note: See TracChangeset
for help on using the changeset viewer.