I am considering an eigenvalue problem like this:
Let $V$ = { $(p_1,p_2) \in (H^1_0(\Omega))^2| d(p_1)/dy-d(p_2)/dx=0$ }.
Find $p=(p_1,p_2)$ from V and $\lambda$ s.t.
$$
(\nabla p_1, \nabla q_1) + (\nabla p_2, \nabla q_2) = \lambda (p,q), \forall q=(q_1,q_2) \in V
$$
I need to export the matrix from DOLFIN to MATLAB since the provided solver of DOLFIN gives error in computing. As the boundary condition removes the DOF of functions space,
when solving the eigenvalue problem Ax=lambda Mx, we can take sub-matrices of A and M to compute the eigenvalues with much smaller matrices.
The question is that how can I find the DOF on boundaries and then create sub-matrices of A and B using only the interior DOFs.
P.S.
In the code below, if the function space W is defined as W = ConfV (Of course, the eig-problem will change), then the columns and rows of matrix A and M corresponding to the DOFs on boundary should be zero. In this case, the sub-matrices are easily obtained by removing these zero columns and zero rows. But as below, W=ConfV*DG, the obtained matrices A and M have no zeros columns or rows. This seems little strange to me.
from dolfin import *
import scipy.io
import numpy as np
import sys
degree= 2
# Define mesh, function space
mesh = Mesh("domain.xml")
ConfV = VectorFunctionSpace(mesh, "CG", degree,2)
DG = FunctionSpace(mesh, "DG", degree-1)
W=ConfV*DG
(p,u) = TrialFunctions(W)
(q,v) = TestFunctions(W)
a = div(p)*div(q)*dx - (p[0].dx(1)-p[1].dx(0))*v*dx - u*(q[0].dx(1)-q[1].dx(0))*dx
b = inner( p, q )*dx
vec = inner( Constant((0,0)), q)*dx
def bdry(x, on_boundary): return on_boundary
bc1 = DirichletBC(ConfV.sub(0), Constant(0.0), bdry)
bc2 = DirichletBC(ConfV.sub(1), Constant(0.0), bdry)
A, _ = assemble_system(a,vec,[bc1,bc2])
M, _ = assemble_system(b,vec,[bc1,bc2])
bc1.zero(A); bc2.zero(A)
bc1.zero(M); bc2.zero(M)
A = as_backend_type(A);
M = as_backend_type(M);
## ------------------ Export Matrices --------------------------
scipy.io.savemat('matrix.mat', {'A': A.array(), 'M': M.array() }, oned_as="column" )