Composite eigenvectors with SLEPc

Hi FF developers,

I am solving an eigenvalue problem for a composite system using SLEPc where the problem is defined on several different FE spaces. The matrices can be built straightforwardly using blocks. However, because the eigenvectors are defined on multiple FE spaces, I can’t build an array of FE functions with the correct dimension to pass to EPSsolve for the eigenvectors. How should I initialize the array for the eigenvectors in such a problem?

load "PETSc-complex"
load "SLEPc-complex" 
fespace Vh1(Th, P1), Vh2(Th, P1);
complex[int] val(0);
Vh1<complex>[int] def(vec1)(1); 
Vh2<complex>[int] def(vec2)(1);
complex[int][int] vec; // How do I initialize this properly?
// Obviously, "vec = [vec1, vec2];" does not work.
Mat<complex> A(Vh1.ndof + Vh2.ndof);
Mat<complex> B(Vh1.ndof + Vh2.ndof);
int k = EPSSolve(A, B, vectors = vec, values = val, sparams = sparams);

Thanks!

Hi Chris :slight_smile:
The vectors parameter is for eigenvectors defined on a fespace. You are thus right it cannot be used in this case. You have to switch to the named parameter array, which, instead of a Vh<complex>[int], will use as input a complex[int, int], of dimension (Vh1.ndof + Vh2.ndof, nev).

1 Like

Helpful as always! Thank you, @prj!