@@ -1224,20 +1224,60 @@ def dict_to_h5group(dict_, group):
1224
1224
group [k ] = v
1225
1225
1226
1226
1227
+ def dd_mergetally (mcdc , data ):
1228
+ """
1229
+ Performs tally recombination on domain-decomposed mesh tallies.
1230
+ Gathers and re-organizes tally data into a single array as it
1231
+ would appear in a non-decomposed simulation.
1232
+ """
1233
+
1234
+ tally = data [TALLY ]
1235
+ # create bin for recomposed tallies
1236
+ d_Nx = input_deck .technique ["dd_mesh" ]["x" ].size - 1
1237
+ d_Ny = input_deck .technique ["dd_mesh" ]["y" ].size - 1
1238
+ d_Nz = input_deck .technique ["dd_mesh" ]["z" ].size - 1
1239
+
1240
+ # capture tally lengths for reorganizing later
1241
+ xlen = len (mcdc ["mesh_tallies" ][0 ]["filter" ]["x" ]) - 1
1242
+ ylen = len (mcdc ["mesh_tallies" ][0 ]["filter" ]["y" ]) - 1
1243
+ zlen = len (mcdc ["mesh_tallies" ][0 ]["filter" ]["z" ]) - 1
1244
+
1245
+ dd_tally = np .zeros ((tally .shape [0 ], tally .shape [1 ] * d_Nx * d_Ny * d_Nz ))
1246
+ # gather tallies
1247
+ for i , t in enumerate (tally ):
1248
+ MPI .COMM_WORLD .Gather (tally [i ], dd_tally [i ], root = 0 )
1249
+ if mcdc ["mpi_master" ]:
1250
+ buff = np .zeros_like (dd_tally )
1251
+ # reorganize tally data
1252
+ # TODO: find/develop a more efficient algorithm for this
1253
+ tally_idx = 0
1254
+ for di in range (0 , d_Nx * d_Ny * d_Nz ):
1255
+ dz = di // (d_Nx * d_Ny )
1256
+ dy = (di % (d_Nx * d_Ny )) // d_Nx
1257
+ dx = di % d_Nx
1258
+ for xi in range (0 , xlen ):
1259
+ for yi in range (0 , ylen ):
1260
+ for zi in range (0 , zlen ):
1261
+ # calculate reorganized index
1262
+ ind_x = xi * (ylen * d_Ny * zlen * d_Nz ) + dx * (
1263
+ xlen * ylen * d_Ny * zlen * d_Nz
1264
+ )
1265
+ ind_y = yi * (xlen * d_Nx ) + dy * (ylen * xlen * d_Nx )
1266
+ ind_z = zi + dz * zlen
1267
+ buff_idx = ind_x + ind_y + ind_z
1268
+ # place tally value in correct position
1269
+ buff [:, buff_idx ] = dd_tally [:, tally_idx ]
1270
+ tally_idx += 1
1271
+ # replace old tally with reorganized tally
1272
+ dd_tally = buff
1273
+
1274
+ return dd_tally
1275
+
1276
+
1227
1277
def generate_hdf5 (data , mcdc ):
1228
1278
1229
- # recombine tallies before output processing
1230
1279
if mcdc ["technique" ]["domain_decomposition" ]:
1231
- tally = data [TALLY ]
1232
- # create bin for recomposed tallies
1233
- d_Nx = input_deck .technique ["dd_mesh" ]["x" ].size - 1
1234
- d_Ny = input_deck .technique ["dd_mesh" ]["y" ].size - 1
1235
- d_Nz = input_deck .technique ["dd_mesh" ]["z" ].size - 1
1236
- dd_tally = np .zeros ((tally .shape [0 ], tally .shape [1 ] * d_Nx * d_Ny * d_Nz ))
1237
- # gather tallies
1238
- MPI .COMM_WORLD .Gather (tally [0 ], dd_tally [0 ], root = 0 )
1239
- MPI .COMM_WORLD .Gather (tally [1 ], dd_tally [1 ], root = 0 )
1240
- MPI .COMM_WORLD .Gather (tally [2 ], dd_tally [2 ], root = 0 )
1280
+ dd_tally = dd_mergetally (mcdc , data )
1241
1281
1242
1282
if mcdc ["mpi_master" ]:
1243
1283
if mcdc ["setting" ]["progress_bar" ]:
0 commit comments