I noticed this post, where spalloc
and sparse
are recommended for efficient assembly in Matlab. I personally use sparse assembling for simple cases.
However, when it comes to the case of coupled PDE, say, 3-PDE coupled, then the scalar unknown becomes a $3\times 3$ tensor. In this case, I can't figure out a way to exploit sparse()
, and have to use for
-loops to assemble.
When the final assembled sparse matrix is as large as $30\text{k}\times 30\text{k}$(on PC), the assembling process becomes really slow (~10min), while the final matrix solving step is still fast(~less than 3 seconds).
Is there any suggestion? Any generic solution is appreciated (not necessarily Matlab)
sparse()
. You do this in for-loops. So you should be able to replace your existing for-loops with ones that generate the indices and then pass the whole group tosparse()
. $\endgroup$