Background
In solid fem, we often solve $$\mathbf{Ku}=\mathbf{p}$$ where $\mathbf{K}$ is global stiffness matrix, $\mathbf{u}$ is displacement, $\mathbf{p}$ is global load vector.
If displacement not be constrained, equation above can not be solved, because the system can have rigid body motion.
In 2D case, the rigid body motion is the translation along $x$ axis, the translation along $y$ axis and the rotation. In order to let problem be solved, at least 3 constrains must be applied.
In 3D case, the rigid body motion is the translation along $x,y,z$ axis, and rotation along $x,y,z$ axis. In order to let problem be solved, at least 6 constrains must be applied.
In matlab, we can constrain $i$ dof to zero by
K(i,:)=0;
K(:,i)=0;
K(i,i)=1;
P(i)=0;
My problem
If now, I obtain a matrix $\mathbf{K}$, it may constrained, or not constrained, or not fully constrained. How can I determine which constrain I need to apply to the system to make problem solved? Or how can I dertermine which rigid body constrain I should apply to the system?
For example: In 2D case, suppose the $\mathbf{K}$ is constrained $x,y$ translation, how can I find that I should constrain the rotation?
My understanding
I know calculate the rank of matrix can used to determine if the problem can be solved, but it can not be used to determine which kind of constrain it lack.
I am using C++, I am using pardiso, eigen to solve the linear system. If the method can be easy implement will be great.
Any suggestion will be great help. Thanks for your time.