I am trying to solve an equation by a meshfree method. Shape functions (and their derivatives) have a compact support domain. So, over a given integration cell used for numerical integration, only a small number of shape functions will have nonzero values. At the same time, for each integration point belonging to a cell, the number and indexes of the nonzero shape functions may be different. Hence, I could not construct local stiffness matrices as in typical FEM codes, because the size of them are unknown. And it is not possible to construct some arrays and then use sparse command for assembling. I used sparse command to define stiffness matrix $K$, as follows:
K=sparse(NDOF,NDOF)
and then tried to find each element $K_{ij}$ during of computation.
for j=1:ngauss
//subroutint to "find v" here
[fi, fix, fiy]=shape(xg,yg,v);
for i=1:length(fi)
sub_K=fiy*fiy(i)+fix*fix(i));
K(v(i),v(:))=K(v(i),v(:))+sparse(weight(j)*areaj*sub_K);
end
end
where v
is the array of indices of nonzero shape functions. But this kind of using sparse command is too slow. Are there any suggestions or any other way for that?
sparse(i,j,v)
form (mathworks.com/help/matlab/ref/sparse.html#bul62_1), constructing the matrix more directly? $\endgroup$