Eigenvalue problem with a mesh-independent input space

Hello everyone,

I would like to solve an eigenvalue problem in the form of sigma^2 B x = A x using PETSc The matrices A and B are symmetric and positive definite. The catch is that I would like the vector ‘x’ be independent of the mesh size, lets say a size (3,1) vector. I can specify the action of the matrices B and A using the ‘‘‘func’’’ feature of FreeFEM; but to do that I need a PETSc Mat of the same size. The issue is that I want the (3,1) input vector to be the same on all processes, but naturally if I define a B matrix with size (3,1) each process will have its separate unknowns. I think defining a (3,1) vector on rank 0 would resolve the issue but I cannot seem to have zero size matrices on the other processes (I cannot seem to create a PETSc MAT from a FreeFEM Mat that way). Any suggestions are welcome how to resolve this issue!

Your notation are not consistent, what is a size (3,1) vector and how can you have both this and a B matrix with size (3,1)? Anyway, here is how to define a Mat of size m \times n, exclusively stored on rank p:

load "PETSc"

int p = 0;
int m = 4;
int n = 3;
Mat A(mpirank == p ? m : 0, mpirank == p ? n : 0);