def _index2ijk(index, mesh):
    """
    Transform the index of a cell in mesh to a 3-dimensional (i,j,k) index.
    """
    nz, ny, nx = mesh.shape
    k = index//(nx*ny)
    j = (index - k*(nx*ny))//nx
    i = (index - k*(nx*ny) - j*nx)
    return i, j, k