Problem when using static index in the loop

Hi, I got a problem when I tried to use a static vector values as 0th index of the matrix: this is the code:

def streaming1():
    for i,j,k in rho:
        if (solid[i,j,k] == 0):
            ci = ti.Vector([i,j,k])
            for s in ti.static(range(19)):
                ip = periodic_index(ci+e[s])
                if (solid[ip]==0):
                    F[ip][s] = f[ci][s]
                    F[ci][LR[s]] = f[ci][s]

The compiler said this line got problem: F[ci][LR[s]] = f[ci][s], the 0-th index should be compiler time constant, Actually I have defined LR as a compiler time constant vector using ti.static(LR), why I still got this message? If I still want the compiler to unroll the loop to gain performance, what should I do? Thank you very much!

cc @strongoier

Hi @yjhp1016. Could you show the definition of LR, or post the full code snippet if possible?

Thanks for your help! :grinning:

The full code can be found here: taichi_LBM3D/ at main · yjhp1016/taichi_LBM3D · GitHub

The compiler raised an error at line 229

If you need any other information, please feel free to give me a shout :wink: Thanks!

Do you actually mean taichi_LBM3D/ at main · yjhp1016/taichi_LBM3D · GitHub :slight_smile:

Could you try directly setting LR = [0,2,1,4,3,6,5,8,7,10,9,12,11,14,13,16,15,18,17]?

Hi @strongoier the solution is working well! Simple and solid! Thanks :+1: :+1: