我在程序中定义了四个taichi的向量
self.particle_positions = ti.Vector.field(2 dtype=ti.f32)
self.particle_velocity = ti.Vector.field(2, dtype=ti.f32)
self.particle_pressure = ti.Vector.field(1, dtype=ti.f32)
self.particle_density = ti.Vector.field(1, dtype=ti.f32)
并且希望将外部的文件数据读入,我是这样操作的
arr_position=np.loadtxt(path_position)
arr_velocity=np.loadtxt(path_velocity)
arr_density=np.loadtxt(path_density)
arr_pressure=np.loadtxt(path_pressure)
self.particle_velocity.from_numpy(arr_velocity)
self.particle_positions.from_numpy(arr_position)
self.particle_pressure.from_numpy(arr_pressure)
self.particle_density.from_numpy(arr_density)
path_position,path_velocity在文本中是一个两列的数据,path_density,path_pressure在文本中是一个一列的数据。
于是我现在遇见了这个问题,当我尝试读入两列的文本数据时,程序可以正常读入,但是我想将一列的文本数据进行转换时,会报这个错误:
assert len(ndarray.shape) == len(self.loop_range().shape) + 2
这个是因为什么呢QAQ