How to efficiently collect large sparse matrices in python / scipy

I am working on a FEM project using Scipy. Now my problem is that the assembly of sparse matrices is too slow. I calculate the contribution of each element to dense small matrices (one for each element). To build global matrices, I iterate over all small dense matrices and set the matrix entries as follows:

[i,j] = someList[k][l]
Mglobal[i,j] = Mglobal[i,j] + Mlocal[k,l]

Mglobalis lil_matrice of the appropriate size, someListdisplays indexing variables.

Of course, it is rather slow and consumes most of the matrix assembly time. Is there a better way to assemble a large sparse matrix from many small dense matrices? I tried scipy.weave but it doesn't seem to work with sparse matrices

+3
source share
1

; , , .

IJV. , - , . ( , ) ( ).

scipy coo_matrix; . (CSR os CSC) .

-

size = number_of_elements * number_of_basis_functions**2

, 2D-, , , number_of_elements * 36. , , , : , IJV. Scipy , , .

+4

All Articles