box = ((0.0, 0.0, 0.0), (boxsize, boxsize, boxsize)) nx = ds.domain_dimensions[0] ## set voxelization options order = 1 tol = 1000 subgrid = (subgridsize, subgridsize, subgridsize) window = box fields = {'m': None} ## chunk through Lagrangian patches mtot = 0.0 tstart = time.time() for pos, vel, mass, block, nblocks in psi.elementBlocksFromGrid(pos, vel, order=order, periodic=True): ## make periodic and voxelize it psi.voxelize(fields, pos, vel, mass, tol=tol, window=window, \ grid=subgrid, periodic=True, box=box) ## bookkeeping mtot += np.sum(mass) tend = time.time() sys.stdout.write("\rVoxelized block %d of %d. Time = %.1f s" % (block, nblocks, tend-tstart)) sys.stdout.flush() print '\nGlobal error = %.10e' % np.abs(np.sum(fields['m'])/mtot-1.0) # save density data to file f = tables.open_file("density%04d_64.h5" % i, mode = 'w') f.create_array(f.root, "density", fields['m']) f.close() i += 1