Changeset 8544
- Timestamp:
- Aug 30, 2012, 7:00:09 PM (13 years ago)
- Location:
- trunk/anuga_core/source
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/anuga_core/source/anuga/file_conversion/sww2dem.py
r8541 r8544 34 34 cellsize=10, 35 35 number_of_decimal_places=None, 36 NODATA_value=-9999 ,36 NODATA_value=-9999.0, 37 37 easting_min=None, 38 38 easting_max=None, … … 332 332 outside_indices = interp.get_outside_poly_indices() 333 333 334 #print outside_indices 335 334 336 if verbose: 335 337 log.critical('Interpolated values are in [%f, %f]' … … 342 344 343 345 for i in outside_indices: 346 #print 'change grid_value',NODATA_value 344 347 grid_values[i] = NODATA_value 345 348 -
trunk/anuga_core/source/anuga_parallel/distribute_mesh.py
r8543 r8544 1134 1134 1135 1135 i=0 1136 i +=1 ; print 'send', i 1137 protocol(num.array(setup_array, num.int))1138 pypar.send( setup_array, p, bypass=True)1136 1137 x = num.array(setup_array, num.int) 1138 pypar.send(x, p, bypass=True) 1139 1139 1140 1140 1141 1141 # ghost layer width 1142 i +=1 ; print 'send', i 1143 protocol(num.array(submesh["ghost_layer_width"][p], num.int)) 1144 pypar.send(num.array(submesh["ghost_layer_width"][p], num.int), p, bypass=True) 1142 x = num.array(submesh["ghost_layer_width"][p], num.int) 1143 pypar.send(x, p, bypass=True) 1145 1144 1146 1145 1147 1146 # send the number of triangles per processor 1148 i +=1 ; print 'send', i 1149 protocol(num.array(triangles_per_proc)) 1150 pypar.send(num.array(triangles_per_proc), p, bypass=True) 1147 x = num.array(triangles_per_proc) 1148 pypar.send(x, p, bypass=True) 1151 1149 1152 1150 # send the nodes 1153 i +=1 ; print 'send', i 1154 protocol(num.array(submesh["full_nodes"][p], num.float)) 1155 #pypar.send(num.array(submesh["full_nodes"][p], num.float), p, bypass=False) 1156 pypar.send(num.array(submesh["full_nodes"][p], num.float), p) 1157 1158 1159 i +=1 ; print 'send', i 1160 protocol(num.array(submesh["ghost_nodes"][p], num.float)) 1161 pypar.send(num.array(submesh["ghost_nodes"][p], num.float),p, bypass=False) 1151 x = num.array(submesh["full_nodes"][p], num.float) 1152 pypar.send(x, p, bypass=True) 1153 1154 x = num.array(submesh["ghost_nodes"][p], num.float) 1155 pypar.send(x, p, bypass=True) 1162 1156 1163 1157 # send the triangles 1164 1165 i +=1 ; print 'send', i1166 protocol(num.array(submesh["full_triangles"][p], num.int)) 1167 pypar.send(num.array(submesh["full_triangles"][p], num.int), p, bypass=False)1168 i +=1 ; print 'send', i1169 p rotocol(num.array(submesh["ghost_triangles"][p], num.int))1170 pypar.send(num.array(submesh["ghost_triangles"][p], num.int), p, bypass=False) 1158 x = num.array(submesh["full_triangles"][p], num.int) 1159 pypar.send(x, p, bypass=True) 1160 1161 # send ghost triangles 1162 x = num.array(submesh["ghost_triangles"][p], num.int) 1163 pypar.send(x, p, bypass=True) 1164 1171 1165 1172 1166 # send the boundary 1173 1174 1167 bc = [] 1175 1168 for b in submesh["full_boundary"][p]: 1176 1169 bc.append([b[0], b[1], tagmap[submesh["full_boundary"][p][b]]]) 1177 1170 1178 i +=1 ; print 'send', i1179 p rotocol(num.array(bc, num.int))1180 pypar.send(num.array(bc, num.int), p, bypass=False) 1171 x = num.array(bc, num.int) 1172 pypar.send(x, p, bypass=True) 1173 1181 1174 1182 1175 bc = [] … … 1184 1177 bc.append([b[0], b[1], tagmap[submesh["ghost_boundary"][p][b]]]) 1185 1178 1186 i +=1 ; print 'send', i 1187 protocol(num.array(bc, num.int)) 1188 pypar.send(num.array(bc, num.int), p, bypass=False) 1179 x = num.array(bc, num.int) 1180 pypar.send(x, p, bypass=True) 1181 1182 1189 1183 1190 1184 # send the communication pattern 1191 1192 # submesh["ghost_commun"][p] is numpy array 1193 i +=1 ; print 'send', i 1194 protocol(submesh["ghost_commun"][p]) 1195 pypar.send(submesh["ghost_commun"][p], p, bypass=False) 1196 1197 i +=1 ; print 'send', i 1198 protocol(num.array(flat_full_commun, num.int)) 1199 pypar.send(num.array(flat_full_commun, num.int), p, bypass=False) 1185 x = submesh["ghost_commun"][p] 1186 pypar.send(x, p, bypass=True) 1187 1188 1189 x = num.array(flat_full_commun, num.int) 1190 pypar.send(x, p, bypass=True) 1191 1200 1192 1201 1193 # send the quantities 1202 1203 1204 1194 for k in submesh["full_quan"]: 1205 print 'send full', ++i, k 1206 protocol(num.array(submesh["full_quan"][k][p], num.float)) 1207 pypar.send(num.array(submesh["full_quan"][k][p], num.float), p, bypass=False) 1195 x = num.array(submesh["full_quan"][k][p], num.float) 1196 pypar.send(x, p, bypass=True) 1208 1197 1209 1198 for k in submesh["ghost_quan"]: 1210 print 'send ghost', ++i, k 1211 protocol(num.array(submesh["ghost_quan"][k][p], num.float)) 1212 pypar.send(num.array(submesh["ghost_quan"][k][p], num.float),p, bypass=False) 1199 x = num.array(submesh["ghost_quan"][k][p], num.float) 1200 pypar.send(x,p, bypass=True) 1213 1201 1214 1202 … … 1271 1259 1272 1260 1261 1262 print 'setup_array', setup_array 1263 1273 1264 # ghost layer width 1274 1265 x = num.zeros((1,),num.int) … … 1283 1274 1284 1275 # receive the full nodes 1285 # x = num.zeros((no_full_nodes,),num.int) 1286 # pypar.receive(p, buffer=x, bypass=True) 1287 # submesh_cell["full_nodes"] = x 1288 1289 1290 submesh_cell["full_nodes"] = pypar.receive(p) 1276 x = num.zeros((no_full_nodes,3),num.float) 1277 pypar.receive(p, buffer=x, bypass=True) 1278 submesh_cell["full_nodes"] = x 1279 1280 1291 1281 # receive the ghost nodes 1292 1293 submesh_cell["ghost_nodes"] = pypar.receive(p, bypass=False) 1282 x = num.zeros((no_ghost_nodes,3),num.float) 1283 pypar.receive(p, buffer=x, bypass=True) 1284 submesh_cell["ghost_nodes"] = x 1294 1285 1295 1286 # receive the full triangles 1296 1297 submesh_cell["full_triangles"] = pypar.receive(p, bypass=False) 1287 x = num.zeros((no_full_triangles,3),num.int) 1288 pypar.receive(p, buffer=x, bypass=True) 1289 submesh_cell["full_triangles"] = x 1290 1298 1291 1299 1292 # receive the ghost triangles 1300 1301 submesh_cell["ghost_triangles"] = pypar.receive(p, bypass=False) 1293 x = num.zeros((no_ghost_triangles,4),num.int) 1294 pypar.receive(p, buffer=x, bypass=True) 1295 submesh_cell["ghost_triangles"] = x 1296 1297 1302 1298 1303 1299 # receive the full boundary 1304 1305 bnd_c = pypar.receive(p, bypass=False) 1300 x = num.zeros((no_full_boundary,3),num.int) 1301 pypar.receive(p, buffer=x, bypass=True) 1302 bnd_c = x 1306 1303 1307 1304 submesh_cell["full_boundary"] = {} … … 1309 1306 submesh_cell["full_boundary"][b[0],b[1]]=itagmap[b[2]] 1310 1307 1308 1311 1309 # receive the ghost boundary 1312 1313 bnd_c = pypar.receive(p, bypass=False) 1310 x = num.zeros((no_ghost_boundary,3),num.int) 1311 pypar.receive(p, buffer=x, bypass=True) 1312 bnd_c = x 1314 1313 1315 1314 submesh_cell["ghost_boundary"] = {} … … 1318 1317 1319 1318 # receive the ghost communication pattern 1320 1321 submesh_cell["ghost_commun"] = pypar.receive(p, bypass=False) 1319 x = num.zeros((no_ghost_commun,2),num.int) 1320 pypar.receive(p, buffer=x, bypass=True) 1321 submesh_cell["ghost_commun"] = x 1322 1322 1323 1323 # receive the full communication pattern 1324 1325 full_commun = pypar.receive(p, bypass=False) 1324 x = num.zeros((no_full_commun,2),num.int) 1325 pypar.receive(p, buffer=x, bypass=True) 1326 full_commun = x 1326 1327 1327 1328 submesh_cell["full_commun"] = {} … … 1334 1335 1335 1336 submesh_cell["full_quan"]={} 1336 1337 1337 for i in range(no_quantities): 1338 tmp = pypar.receive(p, bypass=False)1339 submesh_cell["full_quan"][qkeys[i]]=num.zeros((no_full_triangles,3), num.float)1340 submesh_cell["full_quan"][qkeys[i]] [:] = tmp[:]1338 x = num.zeros((no_full_triangles,3), num.float) 1339 pypar.receive(p, buffer=x, bypass=True) 1340 submesh_cell["full_quan"][qkeys[i]]= x 1341 1341 1342 1342 submesh_cell["ghost_quan"]={} 1343 1343 for i in range(no_quantities): 1344 tmp = pypar.receive(p, bypass=False)1345 submesh_cell["ghost_quan"][qkeys[i]]= num.zeros((no_ghost_triangles,3), num.float)1346 submesh_cell["ghost_quan"][qkeys[i]] [:] = tmp[:]1344 x = num.zeros((no_ghost_triangles,3), num.float) 1345 pypar.receive(p, buffer=x, bypass=True) 1346 submesh_cell["ghost_quan"][qkeys[i]]= x 1347 1347 1348 1348 return submesh_cell, triangles_per_proc,\ -
trunk/anuga_core/source/anuga_parallel/parallel_api.py
r8543 r8544 4 4 """ 5 5 6 6 import numpy as num 7 7 8 8 # The abstract Python-MPI interface … … 93 93 boundary_map = domain.boundary_map 94 94 for p in range(1, numprocs): 95 # FIXME SR: Creates cPickle dump 95 96 send(boundary_map, p) 96 97 else: … … 127 128 print 'p2s_map', p2s_map 128 129 130 131 def protocol(x): 132 vanilla=False 133 import pypar 134 control_info, x = pypar.create_control_info(x, vanilla, return_object=True) 135 print 'protocol', control_info[0] 136 129 137 # Send serial to parallel (s2p) and parallel to serial (p2s) triangle mapping to proc 1 .. numprocs 130 138 for p in range(1, numprocs): 131 139 # FIXME SR: Creates cPickle dump 132 send(s2p_map, p) 140 141 print '*** s2p' 142 protocol(s2p_map) 143 144 n = len(s2p_map) 145 s2p_map_keys_flat = num.reshape(num.array(s2p_map.keys(),num.int), (n,1) ) 146 147 print s2p_map_keys_flat.shape 148 149 s2p_map_values_flat = num.array(s2p_map.values(),num.int) 150 print s2p_map_values_flat.shape 151 152 s2p_map_flat = num.concatenate( (s2p_map_keys_flat, s2p_map_values_flat), axis=1 ) 153 #print s2p_map_keys_flat 154 #print s2p_map_values_flat 155 #print s2p_map_flat 156 157 send(s2p_map_flat, p) 133 158 # FIXME SR: Creates cPickle dump 159 #print p2s_map 134 160 send(p2s_map, p) 135 161 … … 153 179 154 180 # Recieve serial to parallel (s2p) and parallel to serial (p2s) triangle mapping 155 s2p_map = receive(0) 181 s2p_map_flat = receive(0) 182 s2p_map = dict.fromkeys(s2p_map_flat[:,0], s2p_map_flat[:,1:2]) 183 156 184 p2s_map = receive(0) 157 185
Note: See TracChangeset
for help on using the changeset viewer.