在调用 ti.kernel
为 sparse matrix builder
填充的时候,程序报错
***********************************
* Taichi Compiler Stack Traceback *
***********************************
/home/yiliao/anaconda3/envs/py3.8/lib/python3.8/site-packages/taichi/_lib/core/taichi_python.cpython-38-x86_64-linux-gnu.so(+0x46f6f7d) [0x7fcb94006f7d]
/home/yiliao/anaconda3/envs/py3.8/lib/python3.8/site-packages/taichi/_lib/core/taichi_python.cpython-38-x86_64-linux-gnu.so(+0x1b1c5ff) [0x7fcb9142c5ff]
/lib/x86_64-linux-gnu/libc.so.6(+0x43090) [0x7fcbd2621090]
[0x7fcaec8f6e5d]
Internal error occurred. Check out this page for possible solutions:
https:docs.taichi-lang.org/docs/install
[E 07/27/23 17:09:47.936 1548753] Received signal 11 (Segmentation fault)
Process finished with exit code 255
源代码如下:
@ti.kernel
def precomputation(self, lhs_t:ti.types.sparse_matrix_builder()):
ELE_NUM = self.ELE_NUM
dim = self.dim
for i in range(self. NODE_NUM):
for d in ti.static(range(2)):
lhs_t[i*dim + d, i*dim + d] += self.node_mass[i]/self.dt**2
""" 这一段与错误无关
for i in range(self. ELE_NUM):
B_i = self. B[i]
a = B_i[0, 0]
b = B_i[0, 1]
c = B_i[1, 0]
d = B_i[1, 1]
for t in range(2):
self.A[t*ELE_NUM + i][0, 0] = -a - c
self.A[t*ELE_NUM + i][0, 2] = a
self.A[t*ELE_NUM + i][0, 4] = c
self.A[t*ELE_NUM + i][1, 0] = -b - d
self.A[t*ELE_NUM + i][1, 2] = b
self.A[t*ELE_NUM + i][1, 4] = d
self.A[t*ELE_NUM + i][2, 1] = -a - c
self.A[t*ELE_NUM + i][2, 3] = a
self.A[t*ELE_NUM + i][2, 5] = c
self.A[t*ELE_NUM + i][3, 1] = -b - d
self.A[t*ELE_NUM + i][3, 3] = b
self.A[t*ELE_NUM + i][3, 5] = d
"""
for ele_idx in range(self. ELE_NUM):
ia, ib, ic = self.element[ele_idx]
ia_x, ia_y = it's * dim, it's * dim + 1
ib_x, ib_y = ib * dim, ib * dim + 1
ic_x, ic_y = ic * dim, ic * dim + 1
q_idx_vec = Tue. Vector([ia_x, ia_y, ib_x, ib_y, ic_x, ic_y])
for t in range(2):
A_i = self. A[t*ELE_NUM + ele_idx]
for A_row_idx, A_col_idx in ti.static(ti.ndrange(6,6)):
lhs_row_idx = q_idx_vec[A_row_idx]
lhs_col_idx = q_idx_vec[A_col_idx]
matrix_temp = ti.f64(0.)
for idx in range(dim**2):
weight = ti.f64(0.)
if t == 0:
weight = self.strain_weight[ele_idx]
else:
weight = self.vol_weight[ele_idx]
lhs_t[lhs_row_idx, lhs_col_idx] += weight * A_i[idx, A_row_idx] * A_i[idx, A_col_idx]