Changeset 7400
- Timestamp:
- Aug 21, 2009, 2:02:46 PM (15 years ago)
- Location:
- anuga_core/source/anuga_parallel
- Files:
-
- 11 edited
Legend:
- Unmodified
- Added
- Removed
-
anuga_core/source/anuga_parallel/build_commun.py
r3926 r7400 13 13 # Author: Linda Stals, June 2005 14 14 # Modified: Linda Stals, Nov 2005 (optimise python code) 15 # 16 # 17 ######################################################### 18 19 from Numeric import array, Int, Float, zeros 15 # Steve Roberts, Aug 2009 (update to numpy) 16 # 17 # 18 ######################################################### 19 20 #from Numeric import array, Int, Float, zeros 21 22 import numpy as num 23 20 24 import logging, logging.config 21 25 logger = logging.getLogger('parallel') … … 30 34 31 35 import pypar 36 32 37 33 38 from build_local import build_local_mesh … … 65 70 tagmap[bkey] = counter 66 71 counter = counter+1 72 67 73 pypar.send(tagmap, p) 68 74 69 75 # send the quantities key information 70 76 71 77 pypar.send(submesh["full_quan"].keys(), p) 72 78 73 79 # send the number of triangles per processor 74 80 75 pypar.send(triangles_per_proc, p , use_buffer=True)81 pypar.send(triangles_per_proc, p) 76 82 77 83 # compress full_commun … … 82 88 for i in range(len(submesh["full_commun"][p][c])): 83 89 flat_full_commun.append([c,submesh["full_commun"][p][c][i]]) 90 91 print 'flat_full_commun', flat_full_commun 84 92 85 93 # send the array sizes so memory can be allocated … … 95 103 setup_array[7] = len(flat_full_commun) 96 104 97 pypar.send( setup_array, p)105 pypar.send(num.array(setup_array, num.int), p) 98 106 99 107 # send the nodes 100 101 pypar.send( submesh["full_nodes"][p], p, use_buffer=True)102 pypar.send( submesh["ghost_nodes"][p], p, use_buffer=True)108 109 pypar.send(num.array(submesh["full_nodes"][p], num.float), p) 110 pypar.send(num.array(submesh["ghost_nodes"][p], num.float),p) 103 111 104 112 # send the triangles 105 113 106 pypar.send( array(submesh["full_triangles"][p], Int), p, use_buffer=True)107 pypar.send( submesh["ghost_triangles"][p], p, use_buffer=True)114 pypar.send(num.array(submesh["full_triangles"][p], num.int), p) 115 pypar.send(num.array(submesh["ghost_triangles"][p], num.int), p) 108 116 109 117 # send the boundary … … 112 120 for b in submesh["full_boundary"][p]: 113 121 bc.append([b[0], b[1], tagmap[submesh["full_boundary"][p][b]]]) 114 pypar.send(bc, p, use_buffer=True) 122 123 124 pypar.send(num.array(bc, num.int), p) 125 115 126 bc = [] 116 127 for b in submesh["ghost_boundary"][p]: 117 128 bc.append([b[0], b[1], tagmap[submesh["ghost_boundary"][p][b]]]) 118 pypar.send(bc, p, use_buffer=True) 129 130 pypar.send(num.array(bc, num.int), p) 119 131 120 132 # send the communication pattern 121 133 122 pypar.send(submesh["ghost_commun"][p], p, use_buffer=True) 123 pypar.send(flat_full_commun, p, use_buffer=True) 134 pypar.send(submesh["ghost_commun"][p], p) 135 136 pypar.send(num.array(flat_full_commun, num.int), p) 124 137 125 138 # send the quantities 126 139 127 140 for k in submesh["full_quan"]: 128 pypar.send( submesh["full_quan"][k][p], p, use_buffer=True)141 pypar.send(num.array(submesh["full_quan"][k][p], num.float), p) 129 142 130 143 for k in submesh["ghost_quan"]: 131 pypar.send( submesh["ghost_quan"][k][p], p, use_buffer=True)144 pypar.send(num.array(submesh["ghost_quan"][k][p], num.float),p) 132 145 133 146 … … 150 163 151 164 def rec_submesh_flat(p): 152 165 153 166 numproc = pypar.size() 154 167 myid = pypar.rank() … … 161 174 162 175 tagmap = pypar.receive(p) 176 163 177 itagmap = {} 164 178 for t in tagmap: … … 166 180 167 181 # receive the quantities key information 168 182 169 183 qkeys = pypar.receive(p) 170 184 171 185 # receive the number of triangles per processor 172 186 173 triangles_per_proc = [] 174 for i in range(numproc): 175 triangles_per_proc.append([0]) 176 177 triangles_per_proc = pypar.receive(p, triangles_per_proc) 187 triangles_per_proc = pypar.receive(p) 178 188 179 189 # recieve information about the array sizes 180 190 181 setup_array = [0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0] 182 setup_array = pypar.receive(p, setup_array) 183 191 setup_array = pypar.receive(p) 192 193 no_full_nodes = setup_array[0] 194 no_ghost_nodes = setup_array[1] 195 no_full_triangles = setup_array[2] 196 no_ghost_triangles = setup_array[3] 197 no_full_boundary = setup_array[4] 198 no_ghost_boundary = setup_array[5] 199 no_ghost_commun = setup_array[6] 200 no_full_commun = setup_array[7] 201 no_quantities = len(qkeys) 202 184 203 # receive the full nodes 185 204 186 no_full_nodes = setup_array[0] 187 full_nodes = zeros((no_full_nodes, 3), Float) 188 submesh_cell["full_nodes"] = pypar.receive(p, full_nodes) 189 205 submesh_cell["full_nodes"] = pypar.receive(p) 206 190 207 # receive the ghost nodes 191 208 192 no_ghost_nodes = setup_array[1] 193 ghost_nodes = zeros((no_ghost_nodes, 3), Float) 194 submesh_cell["ghost_nodes"] = pypar.receive(p, ghost_nodes) 195 209 submesh_cell["ghost_nodes"] = pypar.receive(p) 196 210 197 211 # receive the full triangles 198 212 199 no_full_triangles = setup_array[2] 200 full_triangles = zeros((no_full_triangles, 3), Int) 201 submesh_cell["full_triangles"] = pypar.receive(p, full_triangles) 213 submesh_cell["full_triangles"] = pypar.receive(p) 202 214 203 215 # receive the ghost triangles 204 216 205 no_ghost_triangles = setup_array[3] 206 ghost_triangles = zeros((no_ghost_triangles, 4), Int) 207 submesh_cell["ghost_triangles"] = pypar.receive(p, ghost_triangles) 208 217 submesh_cell["ghost_triangles"] = pypar.receive(p) 218 209 219 # receive the full boundary 210 220 211 no_full_boundary = setup_array[4] 212 bc = [] 213 for i in range(no_full_boundary): 214 bc.append([0.0, 0.0, 0.0]) 215 bnd_c = pypar.receive(p, bc) 221 bnd_c = pypar.receive(p) 216 222 217 223 submesh_cell["full_boundary"] = {} … … 221 227 # receive the ghost boundary 222 228 223 no_ghost_boundary = setup_array[5] 224 bc = [] 225 for i in range(no_ghost_boundary): 226 bc.append([0.0, 0.0, 0.0]) 227 bnd_c = pypar.receive(p, bc) 229 bnd_c = pypar.receive(p) 228 230 229 231 submesh_cell["ghost_boundary"] = {} … … 233 235 # receive the ghost communication pattern 234 236 235 no_ghost_commun = setup_array[6] 236 ghost_commun = zeros((no_ghost_commun, 2), Int) 237 submesh_cell["ghost_commun"] = pypar.receive(p, ghost_commun) 237 submesh_cell["ghost_commun"] = pypar.receive(p) 238 238 239 239 # receive the full communication pattern 240 240 241 no_full_commun = setup_array[7] 242 full_commun = [] 243 for i in range(no_full_commun): 244 full_commun.append([0.0, 0.0]) 245 246 full_commun = pypar.receive(p, full_commun) 241 full_commun = pypar.receive(p) 247 242 248 243 submesh_cell["full_commun"] = {} … … 254 249 # receive the quantities 255 250 256 no_quantities = len(qkeys)257 new_quan = zeros((no_full_triangles, 3), Float)258 251 submesh_cell["full_quan"]={} 259 252 260 253 for i in range(no_quantities): 261 tmp = pypar.receive(p , new_quan)262 submesh_cell["full_quan"][qkeys[i]]= zeros((no_full_triangles,3), Float)254 tmp = pypar.receive(p) 255 submesh_cell["full_quan"][qkeys[i]]=num.zeros((no_full_triangles,3), num.float) 263 256 submesh_cell["full_quan"][qkeys[i]][:] = tmp[:] 264 257 265 new_quan = zeros((no_ghost_triangles, 3), Float)266 258 submesh_cell["ghost_quan"]={} 267 259 for i in range(no_quantities): 268 tmp = pypar.receive(p , new_quan)269 submesh_cell["ghost_quan"][qkeys[i]]= zeros((no_ghost_triangles,3), Float)260 tmp = pypar.receive(p) 261 submesh_cell["ghost_quan"][qkeys[i]]= num.zeros((no_ghost_triangles,3), num.float) 270 262 submesh_cell["ghost_quan"][qkeys[i]][:] = tmp[:] 271 263 … … 293 285 294 286 def rec_submesh(p): 295 287 296 288 numproc = pypar.size() 297 289 myid = pypar.rank() -
anuga_core/source/anuga_parallel/build_local.py
r3579 r7400 14 14 # Authors: Linda Stals and Matthew Hardy, June 2005 15 15 # Modified: Linda Stals, Nov 2005 (optimise python code) 16 # 17 # 18 ######################################################### 19 20 from Numeric import zeros, Float, Int, concatenate, \ 21 take, arrayrange, put, sort, compress, equal 22 23 16 # Steve Roberts, Aug 2009 (updating to numpy) 17 # 18 # 19 ######################################################### 20 21 #from Numeric import zeros, Float, Int, concatenate, \ 22 # take, arrayrange, put, sort, compress, equal 23 24 25 import numpy as num 26 24 27 ######################################################### 25 28 # Convert the format of the data to that used by ANUGA … … 46 49 # Extract the nodes (using the local ID) 47 50 48 GAnodes = take(nodes, (1, 2), 1)51 GAnodes = num.take(nodes, (1, 2), 1) 49 52 50 53 # Build a global ID to local ID mapping … … 54 57 if nodes[i][0] > NGlobal: 55 58 NGlobal = nodes[i][0] 56 index = zeros(int(NGlobal)+1, Int)57 put(index, take(nodes, (0,), 1).astype(Int), \58 arrayrange(Nnodes))59 index = num.zeros(int(NGlobal)+1, num.int) 60 num.put(index, num.take(nodes, (0,), 1).astype(num.int), \ 61 num.arange(Nnodes)) 59 62 60 63 # Change the global IDs in the triangles to the local IDs 61 64 62 GAtriangles = zeros((Ntriangles, 3), Int)63 GAtriangles[:,0] = take(index, triangles[:,0])64 GAtriangles[:,1] = take(index, triangles[:,1])65 GAtriangles[:,2] = take(index, triangles[:,2])65 GAtriangles = num.zeros((Ntriangles, 3), num.int) 66 GAtriangles[:,0] = num.take(index, triangles[:,0]) 67 GAtriangles[:,1] = num.take(index, triangles[:,1]) 68 GAtriangles[:,2] = num.take(index, triangles[:,2]) 66 69 67 70 # Change the triangle numbering in the boundaries … … 109 112 # information by the global numbering) 110 113 111 ghostc = sort(ghostc, 0)114 ghostc = num.sort(ghostc, 0) 112 115 113 116 for c in range(nproc): 114 117 s = ghostc[:,0] 115 d = compress(equal(ghostc[:,1],c), s)118 d = num.compress(num.equal(ghostc[:,1],c), s) 116 119 if len(d) > 0: 117 120 ghost_recv[c] = [0, 0] 118 121 ghost_recv[c][1] = d 119 ghost_recv[c][0] = take(index, d)122 ghost_recv[c][0] = num.take(index, d) 120 123 121 124 # Build a temporary copy of the full_send dictionary … … 136 139 137 140 for neigh in tmp_send: 138 neigh_commun = sort(tmp_send[neigh], 0)141 neigh_commun = num.sort(tmp_send[neigh], 0) 139 142 full_send[neigh] = [0, 0] 140 143 full_send[neigh][0] = neigh_commun[:,1] … … 167 170 # Combine the full nodes and ghost nodes 168 171 169 nodes = concatenate((submesh["full_nodes"], \172 nodes = num.concatenate((submesh["full_nodes"], \ 170 173 submesh["ghost_nodes"])) 171 174 172 175 # Combine the full triangles and ghost triangles 173 176 174 gtri = take(submesh["ghost_triangles"],(1, 2, 3),1)175 triangles = concatenate((submesh["full_triangles"], gtri))177 gtri = num.take(submesh["ghost_triangles"],(1, 2, 3),1) 178 triangles = num.concatenate((submesh["full_triangles"], gtri)) 176 179 177 180 # Combine the full boundaries and ghost boundaries … … 189 192 if id > NGlobal: 190 193 NGlobal = id 191 index = zeros(int(NGlobal)+1, Int)192 index[lower_t:upper_t]= arrayrange(upper_t-lower_t)194 index = num.zeros(int(NGlobal)+1, num.int) 195 index[lower_t:upper_t]=num.arange(upper_t-lower_t) 193 196 for i in range(len(submesh["ghost_triangles"])): 194 197 index[submesh["ghost_triangles"][i][0]] = i+upper_t-lower_t … … 205 208 Nf = len(submesh["full_quan"][k]) 206 209 Ng = len(submesh["ghost_quan"][k]) 207 quantities[k] = zeros((Nf+Ng, 3), Float)210 quantities[k] = num.zeros((Nf+Ng, 3), num.float) 208 211 quantities[k][0:Nf] = submesh["full_quan"][k] 209 212 quantities[k][Nf:Nf+Ng] = submesh["ghost_quan"][k] … … 223 226 return GAnodes, GAtriangles, GAboundary, quantities, ghost_rec, \ 224 227 full_send 228 -
anuga_core/source/anuga_parallel/build_submesh.py
r7389 r7400 1 1 ######################################################### 2 2 # 3 # Subdivide the GAdomain. This module is primarily3 # Subdivide the domain. This module is primarily 4 4 # responsible for building the ghost layer and 5 5 # communication pattern … … 8 8 # Author: Linda Stals, June 2005 9 9 # Modified: Linda Stals, Nov 2005 (optimise python code) 10 # Steve Roberts, Aug 2009 (convert to numpy) 10 11 # 11 12 # … … 14 15 import sys 15 16 16 from Numeric import zeros, Float, Int, concatenate, \ 17 reshape, arrayrange, take, nonzero 17 #from Numeric import zeros, Float, Int, concatenate, \ 18 # reshape, arrayrange, take, nonzero 19 20 import numpy as num 18 21 19 22 from anuga.abstract_2d_finite_volumes.neighbour_mesh import Mesh … … 55 58 boundary_list = [] 56 59 submesh = {} 57 node_range = reshape(arrayrange(nnodes),(nnodes,1)) 58 tsubnodes = concatenate((node_range, nodes), 1) 60 node_range = num.reshape(num.arange(nnodes),(nnodes,1)) 61 62 #print node_range 63 tsubnodes = num.concatenate((node_range, nodes), 1) 64 59 65 60 66 # Loop over processors … … 78 84 # Find nodes in processor p 79 85 80 nodemap = zeros(nnodes, 'i')86 nodemap = num.zeros(nnodes, 'i') 81 87 for t in subtriangles: 82 88 nodemap[t[0]]=1 … … 84 90 nodemap[t[2]]=1 85 91 86 node_list.append(take(tsubnodes,nonzero(nodemap))) 92 93 node_list.append(tsubnodes.take(num.flatnonzero(nodemap),axis=0)) 87 94 88 95 # Move to the next processor … … 134 141 # Find the first layer of boundary triangles 135 142 136 trianglemap = zeros(ntriangles, 'i')143 trianglemap = num.zeros(ntriangles, 'i') 137 144 for t in range(tlower, tupper): 138 145 139 146 n = mesh.neighbours[t, 0] 147 140 148 if n >= 0: 141 149 if n < tlower or n >= tupper: … … 169 177 # Build the triangle list and make note of the vertices 170 178 171 nodemap = zeros(ncoord, 'i')179 nodemap = num.zeros(ncoord, 'i') 172 180 fullnodes = submesh["full_nodes"][p] 173 181 … … 180 188 nodemap[t[2]] = 1 181 189 182 trilist = reshape(arrayrange(ntriangles),(ntriangles,1)) 183 tsubtriangles = concatenate((trilist, mesh.triangles), 1) 184 subtriangles = take(tsubtriangles, nonzero(trianglemap)) 185 190 trilist = num.reshape(num.arange(ntriangles),(ntriangles,1)) 191 tsubtriangles = num.concatenate((trilist, mesh.triangles), 1) 192 subtriangles = tsubtriangles.take(num.flatnonzero(trianglemap),axis=0) 193 194 186 195 # Keep a record of the triangle vertices, if they are not already there 187 196 … … 190 199 nodemap[int(n[0])] = 0 191 200 192 nodelist = reshape(arrayrange(ncoord),(ncoord,1))193 tsubnodes = concatenate((nodelist, mesh.get_nodes()), 1)194 subnodes = t ake(tsubnodes, nonzero(nodemap))201 nodelist = num.reshape(num.arange(ncoord),(ncoord,1)) 202 tsubnodes = num.concatenate((nodelist, mesh.get_nodes()), 1) 203 subnodes = tsubnodes.take(num.flatnonzero(nodemap),axis=0) 195 204 196 205 # Clean up before exiting … … 234 243 ######################################################### 235 244 def is_in_processor(ghost_list, tlower, tupper, n): 236 return (n in ghost_list) or (tlower <= n and tupper > n) 245 246 return num.equal(ghost_list,n).any() or (tlower <= n and tupper > n) 247 237 248 238 249 def ghost_bnd_layer(ghosttri, tlower, tupper, mesh, p): … … 240 251 ghost_list = [] 241 252 subboundary = {} 242 253 254 243 255 for t in ghosttri: 244 256 ghost_list.append(t[0]) 245 257 246 258 for t in ghosttri: 259 247 260 n = mesh.neighbours[t[0], 0] 248 261 if not is_in_processor(ghost_list, tlower, tupper, n): … … 279 292 # Loop over the ghost triangles 280 293 281 ghost_commun = zeros((len(subtri), 2), Int)294 ghost_commun = num.zeros((len(subtri), 2), num.int) 282 295 283 296 for i in range(len(subtri)): … … 410 423 ghost_nodes.append(subnodes) 411 424 425 412 426 # Find the boundary layer formed by the ghost triangles 413 427 … … 492 506 for k in quantities: 493 507 submesh["full_quan"][k].append(quantities[k][lower:upper]) 494 submesh["ghost_quan"][k].append( zeros( (M,3) , Float))508 submesh["ghost_quan"][k].append(num.zeros( (M,3) , num.float)) 495 509 for j in range(M): 496 510 submesh["ghost_quan"][k][p][j] = \ -
anuga_core/source/anuga_parallel/parallel_advection.py
r5763 r7400 23 23 24 24 from anuga.advection import * 25 from Numeric import zeros, Float, Int, ones, allclose, array 25 26 27 #from Numeric import zeros, Float, Int, ones, allclose, array 28 import numpy as num 29 26 30 import pypar 27 31 … … 78 82 # For some reason it looks like pypar only reduces numeric arrays 79 83 # hence we need to create some dummy arrays for communication 80 ltimestep = ones( 1, Float )84 ltimestep = num.ones( 1, num.float ) 81 85 ltimestep[0] = self.flux_timestep 82 gtimestep = zeros( 1, Float) # Buffer for results 83 84 pypar.raw_reduce(ltimestep, gtimestep, pypar.MIN, 0) 86 gtimestep = num.zeros( 1, num.float ) # Buffer for results 87 88 #ltimestep = self.flux_timeste 89 90 #print self.processor, ltimestep, gtimestep 91 92 pypar.reduce(ltimestep, pypar.MIN, 0, buffer=gtimestep) 93 94 #print self.processor, ltimestep, gtimestep 95 85 96 pypar.broadcast(gtimestep,0) 97 98 #print self.processor, ltimestep, gtimestep 86 99 87 100 self.flux_timestep = gtimestep[0] … … 102 115 # the separate processors 103 116 104 from Numeric import take,put 117 #from Numeric import take,put 118 import numpy as num 105 119 import time 106 120 t0 = time.time() … … 122 136 #for i in range(N): 123 137 # Xout[i,0] = stage_cv[Idf[i]] 124 Xout[:,0] = take(stage_cv, Idf)138 Xout[:,0] = num.take(stage_cv, Idf) 125 139 126 140 pypar.send(Xout,send_proc) … … 139 153 N = len(Idg) 140 154 141 put(stage_cv, Idg, X[:,0])155 num.put(stage_cv, Idg, X[:,0]) 142 156 #for i in range(N): 143 157 # stage_cv[Idg[i]] = X[i,0] … … 162 176 # stage_cv[Idg[i]] = stage_cv[Idf[i]] 163 177 164 put(stage_cv, Idg,take(stage_cv, Idf))178 num.put(stage_cv, Idg, num.take(stage_cv, Idf)) 165 179 166 180 -
anuga_core/source/anuga_parallel/parallel_api.py
r6721 r7400 4 4 """ 5 5 6 from Numeric import zeros 6 7 7 8 8 # The abstract Python-MPI interface … … 168 168 169 169 170 171 170 172 # Build the mesh that should be assigned to each processor, 171 173 # this includes ghost nodes and the communication pattern -
anuga_core/source/anuga_parallel/parallel_meshes.py
r6721 r7400 15 15 16 16 import sys 17 from Numeric import array, zeros, Float, Int, ones, sum 18 17 #from Numeric import array, zeros, Float, Int, ones, sum 18 19 import numpy as num 19 20 import pypar 20 21 … … 86 87 E = EIndex(n,m) 87 88 88 points = zeros( (Np,2), Float)89 points = num.zeros( (Np,2), num.float) 89 90 90 91 for i in range(m+1): … … 98 99 99 100 100 elements = zeros( (Nt,3), Int)101 elements = num.zeros( (Nt,3), num.int) 101 102 boundary = {} 102 103 Idgl = [] … … 170 171 print Idgr 171 172 172 Idfl = array(Idfl,Int)173 Idgr = array(Idgr,Int)173 Idfl = num.array(Idfl,num.int) 174 Idgr = num.array(Idgr,num.int) 174 175 175 176 print Idfl … … 184 185 Idfl.extend(Idfr) 185 186 Idgr.extend(Idgl) 186 Idfl = array(Idfl,Int)187 Idgr = array(Idgr,Int)187 Idfl = num.array(Idfl,num.int) 188 Idgr = num.array(Idgr,num.int) 188 189 full_send_dict[(processor-1)%numproc] = [Idfl, Idfl] 189 190 ghost_recv_dict[(processor-1)%numproc] = [Idgr, Idgr] 190 191 else: 191 Idfl = array(Idfl,Int)192 Idgl = array(Idgl,Int)193 194 Idfr = array(Idfr,Int)195 Idgr = array(Idgr,Int)192 Idfl = num.array(Idfl,num.int) 193 Idgl = num.array(Idgl,num.int) 194 195 Idfr = num.array(Idfr,num.int) 196 Idgr = num.array(Idgr,num.int) 196 197 197 198 full_send_dict[(processor-1)%numproc] = [Idfl, Idfl] … … 252 253 E = EIndex(n,m) 253 254 254 points = zeros( (Np,2), Float)255 points = num.zeros( (Np,2), num.float) 255 256 256 257 for i in range(m+1): … … 264 265 265 266 266 elements = zeros( (Nt,3), Int)267 elements = num.zeros( (Nt,3), num.int) 267 268 boundary = {} 268 269 ghosts = {} … … 389 390 E = EIndex(n,m) 390 391 391 points = zeros( (Np,2), Float)392 points = num.zeros( (Np,2), num.float) 392 393 393 394 for i in range(m+1): … … 401 402 402 403 403 elements = zeros( (Nt,3), Int)404 elements = num.zeros( (Nt,3), num.int) 404 405 boundary = {} 405 406 ghosts = {} -
anuga_core/source/anuga_parallel/parallel_shallow_water.py
r5763 r7400 23 23 24 24 from anuga.shallow_water.shallow_water_domain import * 25 from Numeric import zeros, Float, Int, ones, allclose, array 25 26 27 import numpy as num 26 28 27 29 import pypar … … 57 59 # for key in full_send_dict: 58 60 # buffer_shape = full_send_dict[key][0].shape[0] 59 # full_send_dict[key].append( zeros( (buffer_shape,self.nsys) ,Float))61 # full_send_dict[key].append(num.zeros( (buffer_shape,self.nsys) ,num.loat)) 60 62 # 61 63 # 62 64 # for key in ghost_recv_dict: 63 65 # buffer_shape = ghost_recv_dict[key][0].shape[0] 64 # ghost_recv_dict[key].append( zeros( (buffer_shape,self.nsys) ,Float))66 # ghost_recv_dict[key].append(num.zeros( (buffer_shape,self.nsys) ,num.float)) 65 67 # 66 68 # self.full_send_dict = full_send_dict … … 68 70 69 71 # Buffers for synchronisation of timesteps 70 self.local_timestep = zeros(1, Float)71 self.global_timestep = zeros(1, Float)72 73 self.local_timesteps = zeros(self.numproc, Float)72 self.local_timestep = num.zeros(1, num.float) 73 self.global_timestep = num.zeros(1, num.float) 74 75 self.local_timesteps = num.zeros(self.numproc, num.loat) 74 76 75 77 -
anuga_core/source/anuga_parallel/pmesh_divide.py
r6721 r7400 12 12 # Modified: Linda Stals, Nov 2005 13 13 # Jack Kelly, Nov 2005 14 # Steve Roberts, Aug 2009 (updating to numpy) 14 15 # 15 16 # … … 20 21 from math import floor 21 22 22 from Numeric import zeros, Float, Int, reshape, argsort, ArrayType 23 23 import numpy as num 24 #import zeros, float, Int, reshape, argsort, ArrayType 24 25 25 26 ######################################################### … … 49 50 # Temporary storage area 50 51 51 index = zeros(N, Int)52 index = num.zeros(N, num.int) 52 53 q_reord = {} 53 54 … … 62 63 63 64 for k in quantities: 64 q_reord[k] = zeros((N, 3), Float)65 q_reord[k] = num.zeros((N, 3), num.float) 65 66 for i in range(N): 66 67 q_reord[k][index[i]]=quantities[k].vertex_values[i] … … 88 89 89 90 try: 90 91 91 from pymetis.metis import partMeshNodal 92 92 except ImportError: … … 96 96 print "***************************************************" 97 97 raise ImportError 98 98 99 def pmesh_divide_metis(domain, n_procs): 99 100 … … 121 122 n_vert = domain.get_number_of_nodes() 122 123 t_list = domain.triangles.copy() 123 t_list = reshape(t_list, (-1,))124 t_list = num.reshape(t_list, (-1,)) 124 125 125 126 # The 1 here is for triangular mesh elements. … … 133 134 # Sometimes (usu. on x86_64), partMeshNodal returnes an array of zero 134 135 # dimensional arrays. Correct this. 135 if type(epart[0]) == ArrayType:136 epart_new = zeros(len(epart), Int)136 if type(epart[0]) == num.ndarray: 137 epart_new = num.zeros(len(epart), num.int) 137 138 for i in range(len(epart)): 138 139 epart_new[i] = epart[i][0] … … 184 185 quantities = {} 185 186 for k in domain.quantities: 186 quantities[k] = zeros((n_tri, 3), Float)187 quantities[k] = num.zeros((n_tri, 3), num.float) 187 188 for i in range(n_tri): 188 189 quantities[k][i] = domain.quantities[k].vertex_values[i] … … 195 196 # this helps with the communication 196 197 197 ttriangles = zeros((len(triangles), 3), Int)198 ttriangles = num.zeros((len(triangles), 3), num.int) 198 199 for i in range(len(triangles)): 199 200 ttriangles[i] = triangles[i] -
anuga_core/source/anuga_parallel/run_advection.py
r5763 r7400 4 4 #======================================================================== 5 5 from anuga.config import g, epsilon 6 from Numeric import allclose, array, zeros, ones, Float 6 7 #from Numeric import allclose, array, zeros, ones, Float 8 7 9 from anuga.advection import Domain, Transmissive_boundary, Dirichlet_boundary 8 from Numeric import array 10 11 #from Numeric import array 12 import numpy as num 9 13 10 14 11 from mesh_factory import rectangular15 from anuga.interface import rectangular_cross 12 16 13 17 #points, vertices, boundary = rectangular(60, 60) 14 points, vertices, boundary = rectangular (10, 10)18 points, vertices, boundary = rectangular_cross(10, 10) 15 19 16 20 #Create advection domain with direction (1,-1) … … 26 30 #Boundaries 27 31 T = Transmissive_boundary(domain) 28 D = Dirichlet_boundary( array([1.0]))32 D = Dirichlet_boundary(num.array([1.0])) 29 33 30 34 #turn on the visualisation 31 35 rect = [0.0, 0.0, 1.0, 1.0] 32 36 #domain.initialise_visualiser(rect=rect) 33 domain.visualise = True37 domain.visualise = False 34 38 35 39 -
anuga_core/source/anuga_parallel/run_parallel_advection.py
r6721 r7400 48 48 numprocs = pypar.size() 49 49 myid = pypar.rank() 50 processor_name = pypar. Get_processor_name()50 processor_name = pypar.get_processor_name() 51 51 52 52 N = 5 53 53 M = 2 54 55 N = 10 56 M = 5 54 57 55 58 ####################### … … 121 124 # Let processor 0 output some timing information 122 125 123 visualise = True126 visualise = False 124 127 if visualise: 125 128 from anuga.visualiser import RealtimeVisualiser … … 137 140 t0 = time.time() 138 141 139 for t in domain.evolve(yieldstep = 0.1, finaltime = 3 .0):142 for t in domain.evolve(yieldstep = 0.1, finaltime = 30.0): 140 143 if myid == 0: 141 144 domain.write_time() -
anuga_core/source/anuga_parallel/test_parallel_sw_runup.py
r6721 r7400 15 15 #------------------------------------------------------------------------------ 16 16 17 from Numeric import allclose 17 import numpy as num 18 18 19 19 from anuga.pmesh.mesh_interface import create_mesh_from_regions 20 from anuga.abstract_2d_finite_volumes.mesh_factory import rectangular_cross 20 21 21 from anuga.utilities.numerical_tools import ensure_numeric 22 22 from anuga.utilities.polygon import is_inside_polygon 23 23 24 from anuga.shallow_water import Domain 25 from anuga.shallow_water import Reflective_boundary 26 from anuga.shallow_water import Dirichlet_boundary 27 from anuga.shallow_water import Time_boundary 28 from anuga.shallow_water import Transmissive_boundary 24 from anuga.interface import Domain 25 from anuga.interface import Reflective_boundary 26 from anuga.interface import Dirichlet_boundary 27 from anuga.interface import Time_boundary 28 from anuga.interface import Transmissive_boundary 29 30 from anuga.interface import rectangular_cross 29 31 30 32 from parallel_api import distribute, myid, numprocs … … 161 163 if tri_ids[i] > -1: 162 164 #print 'myid = %g, allclose(gauge_values[%g], G%g) = %g' % (myid, i,i, allclose(gauge_values[i], G[i])) 163 success = success and allclose(gauge_values[i], G[i])165 success = success and num.allclose(gauge_values[i], G[i]) 164 166 165 167
Note: See TracChangeset
for help on using the changeset viewer.