You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Describe the bug
Previously, I can run these code, but it doesn't work and get stuck at the init_pos() function. It looks like it is caused by this statement:
ti.Vector([i/N*0.4, j/W*0.2])
# sample code hereimporttaichiastiimportnumpyasnpimportpymesh# Used to create an obj mesh for pymesh, which is exactly same as the one used in PDJ demo3.# This mesh will be read into PN.N=20# internal of one edgeW=10NF=2*N*W# 2 * N ** 2 # number of facesNV= (N+1)*(W+1) # (N + 1) ** 2 # number of verticesdx=1/N# 0.05pos=ti.Vector.field(2, float, NV)
f2v=ti.Vector.field(3, int, NF) # ids of three vertices of each face# dirichlet_num = N + 1# dirichlet = ti.Vector.field(2, float, W + 1)# [i for i in range(11)]@ti.kerneldefinit_pos():
# i: col; j: row;fori, jinti.ndrange(N+1, W+1):
k=i*(W+1)+jpos[k] =ti.Vector([i/N*0.4, j/W*0.2]) +ti.Vector([0.2, 0.4]) # 0.2, 0.4 - 0.6,0.6 0.02*0.02@ti.kerneldefinit_mesh(): # generate two trianglesfori, jinti.ndrange(N, W):
k= (i*W+j) *2# tirangle index w 2 n 3a=i* (W+1) +j# 0 0 = 0b=a+1# 1c=a+W+2# 12d=a+W+1# 11f2v[k+0] = [a, d, c]
f2v[k+1] = [a, c, b]
init_pos()
init_mesh()
np_pos=pos.to_numpy()
np_f2v=f2v.to_numpy()
print(np.shape(np_pos))
print(np.shape(np_f2v))
f=open("demo3_mesh.obj", "w")
# Write all posfor [x, y] innp_pos:
f.write("v "+str(x) +" "+str(y) +" 0\n")
# Write all facesfor [i, j, k] innp_f2v:
f.write("f "+str(i+1) +"/"+str(i+1) +" "+str(j+1) +"/"+str(j+1) +" "+str(k+1) +"/"+str(k+1) +"\n")
f.close()
Thank for reporting! This is actually a known bug introduced by #1906.
Before that, we may add ti.init() to the first line of program to fix the problem.
Also btw, does ti.Vector([float(i)/float(N)*0.4, float(j)/float(W)*0.2]) depress the error? It seems the type promotion for division is broken.
Describe the bug
Previously, I can run these code, but it doesn't work and get stuck at the init_pos() function. It looks like it is caused by this statement:
The text was updated successfully, but these errors were encountered: