# The saddle point system of the mixed finite element

**URL:** https://community.freefem.org/t/the-saddle-point-system-of-the-mixed-finite-element/3400
**Category:** General Discussion
**Created:** [July 16, 2024, 6:32pm UTC](https://community.freefem.org/t/the-saddle-point-system-of-the-mixed-finite-element/3400 "2024-07-16T18:32:36Z")
**Posts on this page:** 7
**Page:** 1

<div class="post-metadata">

### Author: ![mohamed](https://avatars.discourse-cdn.com/v4/letter/m/d78d45/32.png) [@mohamed](https://community.freefem.org/u/mohamed)
#### Post date: [July 16, 2024, 6:32pm UTC](https://community.freefem.org/t/the-saddle-point-system-of-the-mixed-finite-element/3400/1 "2024-07-16T18:32:36Z")

</div>

hello there,

I’m trying to get the underlying linear system of the mixed finite formulation of the poisson problem. The one of the form  
 ![Screenshot from 2024-07-16 14-31-21](https://canada1.discourse-cdn.com/flex030/uploads/freefem/original/2X/3/3769e64792ce79e13a183c645f3aba4487fe9771.png)  
is there a way to do so in freefem.

---

<div class="post-metadata">

### Author: ![prj](https://avatars.discourse-cdn.com/v4/letter/p/ecae2f/32.png) [@prj](https://community.freefem.org/u/prj)
#### Post date: [July 16, 2024, 7:10pm UTC](https://community.freefem.org/t/the-saddle-point-system-of-the-mixed-finite-element/3400/2 "2024-07-16T19:10:52Z")

</div>

Yes, there is a way to do so in FreeFEM.

---

<div class="post-metadata">

### Author: ![mohamed](https://avatars.discourse-cdn.com/v4/letter/m/d78d45/32.png) [@mohamed](https://community.freefem.org/u/mohamed)
#### Post date: [July 16, 2024, 7:39pm UTC](https://community.freefem.org/t/the-saddle-point-system-of-the-mixed-finite-element/3400/3 "2024-07-16T19:39:15Z")

</div>

Thank you for your reply,

Can you please provide a refernce or an example?

---

<div class="post-metadata">

### Author: ![prj](https://avatars.discourse-cdn.com/v4/letter/p/ecae2f/32.png) [@prj](https://community.freefem.org/u/prj)
#### Post date: [July 16, 2024, 8:02pm UTC](https://community.freefem.org/t/the-saddle-point-system-of-the-mixed-finite-element/3400/4 "2024-07-16T20:02:17Z")

</div>

Here is one [FreeFem-sources/examples/tutorial/LaplaceRT.edp at master · FreeFem/FreeFem-sources · GitHub](https://github.com/FreeFem/FreeFem-sources/blob/master/examples/tutorial/LaplaceRT.edp).

---

<div class="post-metadata">

### Author: ![mohamed](https://avatars.discourse-cdn.com/v4/letter/m/d78d45/32.png) [@mohamed](https://community.freefem.org/u/mohamed)
#### Post date: [July 16, 2024, 8:14pm UTC](https://community.freefem.org/t/the-saddle-point-system-of-the-mixed-finite-element/3400/5 "2024-07-16T20:14:48Z")

</div>

I have seen this example in the documentation, but I’d like to get access to the submatrices M and B I have tried the following

```auto
// Mesh
mesh Th = square(10, 10);
func PkV = RT0;
func PkP = P0;
func Pk = [PkV, PkP];               

fespace Wh(Th, Pk); // local finite element space

varf vMixedLaplace([u1, u2, p], [v1, v2, q]) = int2d(Th)(u1 * v1 + u2 * v2 + p*(dx(v1) + dy(v2)) + (dx(u1) + dy(u2))*q)
                                             + on(4, u1 = 1.0, u2 = 1.0);
matrix A;
A = vMixedLaplace(Wh, Wh, tgv = -1);

```

but the resulting matrix A does not have the form of the saddle point problem.

---

<div class="post-metadata">

### Author: ![mohamed](https://avatars.discourse-cdn.com/v4/letter/m/d78d45/32.png) [@mohamed](https://community.freefem.org/u/mohamed)
#### Post date: [July 16, 2024, 8:31pm UTC](https://community.freefem.org/t/the-saddle-point-system-of-the-mixed-finite-element/3400/6 "2024-07-16T20:31:39Z")

</div>

also, I tried to get the matrices M and B and solve the systen using the Schur complement, but I get wrong answer

```auto
// Fespace
fespace Vh(Th, RT0);
Vh [u1, u2];
Vh [v1, v2];

fespace Ph(Th, P0);
Ph p, q;

varf m([u1, u2], [v1, v2]) = int2d(Th)(u1*v1+u2*v2)+ on(4, u1=1, u2=1);
matrix M=m(Vh,Vh,tgv = -1);

varf b1([p],[v1,v2]) = int2d(Th)(p*dx(v1)+p*dy(v2));
matrix B=b1(Ph,Vh);

varf l1([unused],[v1,v2]) = int1d(Th, 1, 2, 3)(gd*v1*N.x+gd*v2*N.y,tgv = -1);
real[int] r1 = l1(0,Vh);

varf l2(unused, q) = int2d(Th)(-q);
real[int] r2 = l2(0,Ph);

```

---

<div class="post-metadata">

### Author: ![prj](https://avatars.discourse-cdn.com/v4/letter/p/ecae2f/32.png) [@prj](https://community.freefem.org/u/prj)
#### Post date: [July 17, 2024, 4:26am UTC](https://community.freefem.org/t/the-saddle-point-system-of-the-mixed-finite-element/3400/7 "2024-07-17T04:26:11Z")

</div>

Here is one example solving the system using the Schur complement: [FreeFem-sources/examples/hpddm/laplace-RT-2d-PETSc.edp at master · FreeFem/FreeFem-sources · GitHub](https://github.com/FreeFem/FreeFem-sources/blob/master/examples/hpddm/laplace-RT-2d-PETSc.edp).
