taichi-dev / taichi

Productive, portable, and performant GPU programming in Python.
https://taichi-lang.org
Apache License 2.0
25.36k stars 2.27k forks source link

interacting between sparse field and external arrays #2827

Closed yjhp1016 closed 3 years ago

yjhp1016 commented 3 years ago

Is there a similar function like to_numpy for sparse field, so we can easily interact between sparse field and external numpy arrays? Thanks!

yjhp1016 commented 3 years ago

I use to_numpy to export the data (3D and 4D tensor) into a numpy array, the output doesn't look quite right. I only change the way of field definition from dense to sparse, the results went wrong... I'm developing a 3D multi-relaxation-time (MRT) lattice Boltzmann code to simulate single phase flow in porous medium. I attached the code, the output are paraview files :-) Thank you! lbm_3d_sparse.zip

yjhp1016 commented 3 years ago

I found it's because the sparse matrix I made is actually slightly larger than the dense matrix. So I made some mistakes in the size of matrix. Problem solved, due to my own mistake...