You can also compute eigenvalues without removing the dirichlet DOFs by setting the diagonal value for the Dirichlet DOFs accordingly (see the answer here https://scicomp.stackexchange.com/questions/14429/applying-dirichlet-b-c-to-the-eigenvalue-problem). If Au=\lambda u is the eigenvalue problem you are solving, you can decompose A (from FENICS) into parts corresponding to the dirichlet DOFs and the actual solved ones as:
\begin{bmatrix}
\hat{A} &0 \\
0 & \beta I
\end{bmatrix}
\begin{bmatrix}
u \\ u_\mathrm{dirichlet}
\end{bmatrix}
= \alpha \begin{bmatrix} u \\ u_\mathrm{dirichlet}\end{bmatrix},
where \hat{A} is the portion of the matrix solving the actual problem.
By setting the value of \beta you can control the eigenvalues associated with the dirichlet DOFs (they should be equal to \beta). If you set them to be outside the range of eigenvalues you want to solve for, then you can use SLEPc to find the eigenvalues/vecs for physical DOFs you’re interested in.
You can set the diagonal value corresponding to dirichlet DOFS using zero
and zero_columns
methods on the boundary condition object. They will zero out rows and columns to form a diagonal. I’m not sure if they are implemented in DolfinX though.