# Mixed finite element(PETSc),how to solve

Hello, I have seen the following example of mixed finite element. In fact, there are two unknowns, u and p, but this example does not solve p,

varf vMixedLaplace([u1, u2, p], [v1, v2, q]) = int2d(Th)(u1 * v1 + u2 * v2 + p*(dx(v1) +
dy(v2)) + (dx(u1) + dy(u2))q)
+ int2d(Th)(q)
- int1d(Th, 1, 2, 3)(v1
N.x + v2*N.y)
+ on(4, u1 = 1.0, u2 = 1.0);

real[int] rhs = vMixedLaplace(0, Wh, tgv = -1);
Mat A(Wh.ndof, intersection, D);
A = vMixedLaplace(Wh, Wh, tgv = -1);
set(A, sparams =“-pc_type lu”);
Wh def(u);
u = A^-1 * rhs;
laplace-RT-2d-PETSc.edp (2.6 KB)

It does solve u, v, and p at the same time.

Thank you for your answer. The command u = A ^ - 1 * rhs. Is u here an unknown quantity or an array of u, v and p? Or p = A ^ - 1 * rhs?

Using `u[]` or `p[]` will result in the same thing. Please read the documentation to understand how to handle mixed finite elements in FreeFEM and how to retrieve a single component.

Hello, I read FreeFem Documentation Release 4.8. On page 539, I read Poisson with mixed finite, but the mixed finite element solution uses problem, and I can’t find the mixed finite element solution using varf.

.

Just look at the examples, e.g., FreeFem-sources/natural-convection-fieldsplit-2d-PETSc.edp at master · FreeFem/FreeFem-sources · GitHub.