I am solving Biot equation with sparse matrix in MATLAB. I have no problem with global sparse matrices assembly, but when I assign Dirichlet boundary condition, it is so slow.
From this topic, How to efficiently implement Dirichlet boundary conditions in global sparse finite element stiffnes matrices, @James also mentioned that it is so slow if global matrix is modified. My matrix is 25000x25000, and it took around 100s to assign boundary conditon.
In MATLAB, many authors state that, by using
setdiff function, only free nodes are considered when solving the equation. Only right hand vector is modified when applying dirichlet boundary condition and global matrix is kept unchanged.
Hier is the code in MATLAB:
% Dirichlet conditions u = sparse(size(coordinates,1),1); u(unique(dirichlet)) = u_d(coordinates(unique(dirichlet),:)); b = b - A * u; % Computation of the solution u(FreeNodes) = A(FreeNodes,FreeNodes) \ b(FreeNodes);
What is the difference between two approaches? And is there any similar function as
setdiff in MATLAB in C++?