for x, y in self.barrier:
if self.barrier[x, y] == 1:
# no_slip
self.rho_star[x, y] = 1.0
self.u_star[x, y] = ti.Vector([0., 0.])
else:
self.rho_star[x, y] = 0.
self.u_star[x, y] = ti.Vector([0., 0.])
for i in ti.static(range(9)):
ix = (x - self.c[i][0]) % self.width
iy = y - self.c[i][1]
if iy == -1:
iy = 0
ik = self.bounce[i]
else:
iy = iy % self.height
ik = i
ieq = self.feq(ik, self.rho[ix, iy], self.u[ix, iy])
self.rho_star[x, y] += ieq
self.u_star[x, y] += self.c[ik]*ieq
self.u_star[x, y] /= self.rho_star[x, y]
背景为LBM模拟中我想要使用镜面反弹边界。
使用gpu并行,报错在:使用局部变量ik时提示未被定义。
ieq = self.feq(ik, self.rho[ix, iy], self.u[ix, iy])
^^
Name "ik" is not defined
是使用if,else语句的问题还是我忽略了taichi的某些特性?