当前位置:网站首页>The initial arrangement of particles in SPH (solved by two pictures)

The initial arrangement of particles in SPH (solved by two pictures)

2022-07-04 23:08:00 beidou111

 Insert picture description here

 Insert picture description here

Therefore, the corresponding code is ( Change from Tai Chi k-ye Of pbf2d.py)

def init():
    init_pos = ti.Vector([0.2,0.3,0.2])
    cube_size = 0.4
    spacing = 0.02
    num_per_row = (int) (cube_size // spacing)
    num_per_floor = num_per_row * num_per_row
    for i in range(num_particles):
        floor = i // (num_per_floor) 
        row = (i % num_per_floor) // num_per_row
        col = (i % num_per_floor) % num_per_row
        positions[i] = ti.Vector([row*spacing, floor*spacing, col*spacing]) + init_pos
原网站

版权声明
本文为[beidou111]所创,转载请带上原文链接,感谢
https://yzsam.com/2022/185/202207042236595580.html