Changeset 7400 for anuga_core/source/anuga_parallel/build_commun.py
- Timestamp:
- Aug 21, 2009, 2:02:46 PM (15 years ago)
- File:
-
- 1 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()
Note: See TracChangeset
for help on using the changeset viewer.