Assemble a series of sparse matrices using two gathering matrices. For more information about assembling routines, see, for example, [F. Cuvelier, C. Japhet and G. Scarella, An efficient way to assemble finite element matrices in vector languages, 2016].
⭕ To access the source code, click on the [source] button at the right
side or click on
Dependence may exist. In case of error, check import and install required
packages or download required scripts. © mathischeap.com
- assembly.assemble(Ms, Gr, Gc=None)[source]¶
A (not very fast) routine for assembling matrices and vectors.
Ms – The matrices/vectors to be assembled.
Ms[i]refers to the ith (for example, in element No. i) matrix/vector. The matrices/vectors need to be sparse matrices/vectors. A sparse vector is a csc_matrix of shape .
Gr (np.array) – The row gathering matrix.
Gc (None, np.array) – (default:
None) The column gathering matrix. When it is
None, it means we are assembling vectors. Therefore we will only need the row gathering matrix,
A csc matrix representing the assembled matrix/vector.
>>> from crazy_mesh import CrazyMeshGlobalNumbering >>> from scipy import sparse as spspa >>> K = 2 >>> N = 3 >>> GM = CrazyMeshGlobalNumbering(K, N) >>> GM_F = GM.FP >>> GM_V = GM.VP >>> Ms = [spspa.random(N**3, 3*(N+1)*N**2, 0.1, 'csc') ... for _ in range(K**3)] # generate a series of sparse matrices >>> M = assemble(Ms, GM_V, GM_F) # assemble matrices >>> M.shape (216, 756) >>> Vs = [spspa.random(N**3, 1, 0.5, 'csc') ... for _ in range(K**3)] # generate a series of sparse vectors >>> V = assemble(Vs, GM_V) >>> V.shape (216, 1)
↩️ Back to Ph.D. thesis complements (ptc).