Changeset 8482
- Timestamp:
- Jul 30, 2012, 9:52:58 AM (13 years ago)
- Location:
- trunk/anuga_core/source/anuga/operators
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/anuga_core/source/anuga/operators/erosion_operators.py
r8481 r8482 84 84 self.indices = indices 85 85 86 #------------------------------------------ 87 # Need to turn off this optimization as it 88 # doesn't fixup the relationship between 89 # bed and stage vertex values in dry region 90 #------------------------------------------ 91 self.domain.optimise_dry_cells = 0 86 92 87 93 #------------------------------------------ 88 94 # Find vertex nodes 89 95 #------------------------------------------ 90 node_id = set()96 node_ids = set() 91 97 92 98 for ind in self.indices: 93 99 for k in [0,1,2]: 94 node_id .add(self.domain.triangles[ind,k])95 96 self.node_id = [ id for id in node_id]100 node_ids.add(self.domain.triangles[ind,k]) 101 102 self.node_ids = [ id for id in node_ids ] 97 103 98 104 … … 100 106 101 107 k = 0 102 node_index[0] = self.domain.number_of_triangles_per_node[0]108 node_index[0] = 0 103 109 for i in range(self.domain.number_of_nodes): 104 if i == 0: 105 continue 106 107 node_index[i] = node_index[i-1] + self.domain.number_of_triangles_per_node[i] 108 109 n0 = self.node_id[0] 110 i0 = node_index[n0] # index of first vertex associated to node 111 i1 = i0 + self.domain.number_of_triangles_per_node[i] # index of last vertex associated to node 112 113 print node_index 114 print n0,i0,i1 115 print len(node_index),self.domain.number_of_nodes 116 117 118 print self.node_id 119 110 node_index[i+1] = node_index[i] + self.domain.number_of_triangles_per_node[i] 111 112 self.node_index = node_index 113 114 vertex_ids =[] 115 for nid in self.node_ids: 116 print nid,self.domain.number_of_triangles_per_node[nid] 117 for vid in range(node_index[nid], node_index[nid+1]): 118 vidd = self.domain.vertex_value_indices[vid] 119 vertex_ids.append(vidd) 120 print ' ',nid, vid, vidd, vidd/3, vidd%3 121 122 self.vol_ids = num.array(vertex_ids,dtype=num.int)/3 123 self.vols = num.array(list(set(self.vol_ids)), dtype=num.int) 124 self.vert_ids = num.array(vertex_ids,dtype=num.int)%3 125 126 print 'noe', self.domain.number_of_elements 127 print 'non', self.domain.number_of_nodes 128 #print self.vols 129 #print self.domain.vertex_value_indic 130 #print self.domain.number_of_triangles_per_node 131 #print self.node_index 132 133 print 'self.node_ids' 134 print self.node_ids 135 136 print 'self.indices' 137 print self.indices 138 #print self.domain.triangles[self.indices] 139 #print self.vertex_ids 140 141 self.dump_triangulation() 120 142 121 143 def __call__(self): … … 167 189 #-------------------------------------------- 168 190 169 if t < 1 5.0 and t > 10.0:191 if t < 10.0 and t > 7.0: 170 192 if self.indices is None: 171 193 self.elev_v[:] = self.elev_v + 0.0 … … 174 196 175 197 176 for nid in self.node_id: 177 print 'nid ', nid 178 print 'vvi ', self.domain.vertex_value_indices[nid] 198 #self.elev_v[self.vol_ids, self.vert_ids] = \ 199 # num.maximum(self.elev_v[self.vol_ids, self.vert_ids] - 0.1*dt, 0.0) 200 201 #self.elev_c[self.vols] = num.mean(self.elev_v[self.vols],axis=1) 202 203 #for nid in self.node_id: 204 # print 'nid ', nid 205 # print 'vvi ', self.domain.vertex_value_indices[nid] 179 206 180 207 … … 202 229 203 230 204 old_flag = self.domain.optimise_dry_cells205 self.domain.optimise_dry_cells = 0206 self.domain.distribute_to_vertices_and_edges()207 self.domain.optimise_dry_cells = old_flag231 #old_flag = self.domain.optimise_dry_cells 232 #self.domain.optimise_dry_cells = 0 233 #self.domain.distribute_to_vertices_and_edges() 234 #self.domain.optimise_dry_cells = old_flag 208 235 209 236 #stage_elev_info(self.domain) … … 231 258 232 259 260 def dump_triangulation(self): 261 # Get vertex coordinates, partition full and ghost triangles based on self.tri_full_flag 262 263 try: 264 import matplotlib 265 matplotlib.use('Agg') 266 import matplotlib.pyplot as plt 267 import matplotlib.tri as tri 268 except: 269 print "Couldn't import module from matplotlib, probably you need to update matplotlib" 270 raise 271 272 domain = self.domain 273 274 vertices = domain.get_vertex_coordinates() 275 #vertices = vertices.reshape((480,3,2)) 276 nodes = domain.get_nodes() 277 Z = domain.get_quantity('elevation').get_values(location='unique vertices') 278 #stage.shape = (1200, ) 279 280 fx = nodes[:,0] 281 fy = nodes[:,1] 282 #gx = vertices[ghost_mask,0] 283 #gy = vertices[ghost_mask,1] 284 285 286 287 ## Plot full triangles 288 n = int(len(fx)/3) 289 #triang = num.array(range(0,3*n)) 290 triang = domain.get_triangles() 291 #triang.shape = (n, 3) 292 293 print triang.shape 294 print fx.shape 295 print Z.shape 296 297 #plt.tricontourf(fx, fy, triang, Z) 298 plt.triplot(fx, fy, triang) 299 300 # now plot indices 301 302 #plt.tricontourf(fx, fy, triang, Z) 303 #plt.triplot(fx, fy, triang) 304 #plt.colorbar() 305 #plt.tricontour(fx, fy, triang, Z, colors='k') 306 #tripcolor 307 308 309 #full_mask = num.repeat(self.tri_full_flag == 1, 3) 310 #ghost_mask = num.repeat(self.tri_full_flag == 0, 3) 311 312 noe = self.domain.number_of_elements 313 314 fx = vertices[:,0].reshape(noe,3) 315 fy = vertices[:,1].reshape(noe,3) 316 317 318 fx = fx[self.indices].flatten() 319 fy = fy[self.indices].flatten() 320 321 print 'fx', fx.shape 322 323 print self.indices 324 #gx = vertices[ghost_mask,0] 325 #gy = vertices[ghost_mask,1] 326 327 328 ## Plot full triangles 329 n = int(len(fx)/3) 330 331 Z = num.ones((3*n,),dtype=num.float) 332 print Z.shape 333 334 triang = num.array(range(0,3*n)) 335 triang.shape = (n, 3) 336 print triang 337 plt.triplot(fx, fy, triang, 'o-') 338 plt.tripcolor(fx,fy, triang, Z) 339 340 ## Plot ghost triangles 341 #n = int(len(gx)/3) 342 #if n > 0: 343 #triang = num.array(range(0,3*n)) 344 #triang.shape = (n, 3) 345 #plt.triplot(gx, gy, triang, 'b--') 346 347 # Save triangulation to location pointed by filename 348 plt.savefig('dump.svg') 349 350 plt.draw() 351 plt.show() 352 353 354 355 233 356 234 357 … … 329 452 330 453 331 332 333 334 335 454 -
trunk/anuga_core/source/anuga/operators/run_polygon_erosion.py
r8481 r8482 20 20 length = 24. 21 21 width = 5. 22 dx = dy = 0.5#.1 # Resolution: Length of subdivisions on both axes22 dx = dy = 1.0 #.1 # Resolution: Length of subdivisions on both axes 23 23 24 24 points, vertices, boundary = rectangular_cross(int(length/dx), int(width/dy), … … 66 66 # Setup boundary conditions 67 67 #------------------------------------------------------------------------------ 68 Bi = Dirichlet_boundary([0. 4, 0, 0]) # Inflow68 Bi = Dirichlet_boundary([0.5, 0, 0]) # Inflow 69 69 Br = Reflective_boundary(domain) # Solid reflective wall 70 70 Bo = Dirichlet_boundary([-5, 0, 0]) # Outflow … … 76 76 #------------------------------------------------------------------------------ 77 77 78 polygon1 = [ [12. 0, 2.0], [13.0, 2.0], [13.0, 3.0], [12.0, 3.0] ]78 polygon1 = [ [12., 2.0], [13., 2.0], [13., 3.0], [12., 3.0] ] 79 79 op1 = Polygonal_erosion_operator(domain, threshold=0.0, polygon=polygon1) 80 80 … … 84 84 #------------------------------------------------------------------------------ 85 85 86 for t in domain.evolve(yieldstep=0.2, finaltime=2 0.0):86 for t in domain.evolve(yieldstep=0.2, finaltime=2.0): 87 87 domain.print_timestepping_statistics() 88 88 domain.print_operator_timestepping_statistics() … … 106 106 107 107 108
Note: See TracChangeset
for help on using the changeset viewer.