Dear Prof Bangerth,
Thanks for your reply. Aye, you are absolutely correct!
I checked my global mass matrix and confirmed that it is indeed singular. Then, I found out that my local mass matrices are also singular, which explains the issue. After printing out the local matrices, I realised I had made a dumb mistake in the assembly process. The pattern for this 3D problem I obtained was:
AAABBB...
AAABBB
AAABBB
BBBCCC
BBBCCC
BBBCCC
which is clearly incorrect and is of course singular... The pattern is supposed to be:
A00B00...
0A00B0
00A00B
B00C00
0B00C0
00B00C
The reason is that I mistakenly used the same approach in step-36 to assemble my mass matrix,
cell_mass_matrix(i, j) += rho * fe_values.shape_value(i, q_point) * fe_values.shape_value(j, q_point) * fe_values.JxW(q_point);
and this needs to be modified in the 3D dynamic problem as follows:
cell_mass_matrix(i, j) += ((i % dim == j % dim)?
rho * fe_values.shape_value(i, q_point) * fe_values.shape_value(j, q_point) * fe_values.JxW(q_point):
0);
Now my code is running well, and all 6 rigid body modes correctly identified. Tbh, my way is not wise, but hope it is helpful to others encountering the same issue.
Best regards,
Yuchen Liu