How to create a rectangle matrix to link two state vectors about different dof?

Dear all,
These days I met a problem to create the matrx P to link two state vectors q1 and q2, where q1 includes the degree of freedom about the velocity and pressure, while q2 only the degree of freedom about the velocity. The rectangle matrix P can remove the pressure-related dof in the q1.

c66a843b292a9a64467117bf39646aa

How could I make the matrix P and output it from the FreeFem++?
Thanks very much !

cat  forum226.edp
matrix a,b;
a=[ [1,0],[0,1],[0,0]];
cout<<a;
int[int] r=[0,0,1,1,2,2];
int[int] c=[0,1,0,1,0,1];
real[int] v=[1,0,0,1,0,0];
b=[r,c,v];
cout<<b;

Thanks for your reply, but I want to do flow instability analysis A(q1)=(omega)B(q1), and I get matrix A and B for the lineariszed NS equation with defined ‘varf’. But now I want to do A(q1)=(omega)B(q1)+(P’)(q2), so l need the matrix for P. It seems that I can not define a ‘varf’ with two different fespace…

And I can’t define a rectangle matrix with only 0 and 1, because I think P includes the mass matrix of fem… or I need to define both P and M(mass matrix of fem) so that A(q1)=(omega)B(q1)+(P’)(M)(q2), so that P only includes 0 and 1. But I don’t know how to only set the dof of pressure is 0, because I don’t know how the dof is ordered in the vectro q1.

Is this what you are looking for?

mesh Th;
fespace Xh(Th, [P2, P2]);
fespace XMh(Th, [P2, P2, P1]);
Xh<complex> [q2X, q2Y];
XMh<complex> [q1X, q1Y, q1p];
varf vP([q2X, q2Y], [q1X, q1Y, q1p]) = int2d(Th)( q2X*q1X + q2Y*q1Y );
matrix<complex> P = vP(Xh, XMh);

Thanks ~ I make it in your way!

1 Like