예제 #1
0
def test_get_morton_points():
    from yt.utilities.lib.geometry_utils import get_morton_points

    mi = np.array([10, 229], dtype=np.uint64)
    li_ans = np.arange(6, dtype=np.uint64).reshape((2, 3))
    li_out = get_morton_points(mi)
    assert_array_equal(li_out, li_ans)
예제 #2
0
def fake_decomp_morton(npart,
                       nfiles,
                       ifile,
                       DLE,
                       DRE,
                       buff=0.0,
                       order=6,
                       verbose=False):
    np.random.seed(int(0x4D3D3D3) + ifile)
    DW = DRE - DLE
    dim_morton = 1 << order
    nH = dim_morton**3
    if nH < nfiles:
        raise Exception("Fewer morton cells than files.")
    nHPF = nH / nfiles
    rHPF = nH % nfiles
    nPH = npart / nH
    nRH = npart % nH
    hind = np.arange(nH, dtype="uint64")
    hpos = get_morton_points(hind)
    hdiv = DW / dim_morton
    if ifile == 0:
        hlist = range(0, nHPF + rHPF)
        nptot = nPH * len(hlist) + nRH
    else:
        hlist = range(ifile * nHPF + rHPF, (ifile + 1) * nHPF + rHPF)
        nptot = nPH * len(hlist)
    pos = np.empty((nptot, 3), dtype="float")
    pc = 0
    for i in hlist:
        iLE = DLE + hdiv * hpos[i, :]
        iRE = iLE + hdiv
        for k in range(3):  # Don't add buffer past domain bounds
            if hpos[i, k] != 0:
                iLE[k] -= buff * hdiv[k]
            if hpos[i, k] != (dim_morton - 1):
                iRE[k] += buff * hdiv[k]
        inp = nPH
        if (ifile == 0) and (i == 0):
            inp += nRH
        for k in range(3):
            pos[pc:(pc + inp), k] = np.random.uniform(iLE[k], iRE[k], inp)
        pc += inp
    return pos