# Doubt in the variational formulation of LaplaceRT.edp

**URL:** https://community.freefem.org/t/doubt-in-the-variational-formulation-of-laplacert-edp/2471
**Category:** General Discussion
**Created:** [May 18, 2023, 10:32am UTC](https://community.freefem.org/t/doubt-in-the-variational-formulation-of-laplacert-edp/2471 "2023-05-18T10:32:12Z")
**Posts on this page:** 6
**Page:** 1

<div class="post-metadata">

### Author: ![89273166](https://avatars.discourse-cdn.com/v4/letter/8/f475e1/32.png) [@89273166](https://community.freefem.org/u/89273166)
#### Post date: [May 18, 2023, 10:32am UTC](https://community.freefem.org/t/doubt-in-the-variational-formulation-of-laplacert-edp/2471/1 "2023-05-18T10:32:12Z")

</div>

![Mixed](https://canada1.discourse-cdn.com/flex030/uploads/freefem/original/2X/5/5852db3a32fec4d1e1c6879d792af4f98fdb96e7.jpeg)  
This code is to find the finite element solution for the mixed formulation for the poission equation(please refer to page no. 540 for details). In the above code how to find the first term " p_q_1e^-15".

Thank you in advanced.

---

<div class="post-metadata">

### Author: ![marchywka](https://avatars.discourse-cdn.com/v4/letter/m/ee59a6/32.png) [@marchywka](https://community.freefem.org/u/marchywka)
#### Post date: [May 18, 2023, 11:17am UTC](https://community.freefem.org/t/doubt-in-the-variational-formulation-of-laplacert-edp/2471/2 "2023-05-18T11:17:54Z")

</div>

Thanks. Did you actually try to run the code? Normally that factor is used  
when “p” does not appear and I explain that as a way to set the “DC” level  
which is otherwise arbitrary ( although “P” may appear, it can be taken out  
with integration by parts ). In this case, it appears on the boundary condition  
so that term is kind of surprising to me. In fact, if you try running the code I’m  
not sure the term helps and I got convergence in GMRES and GC by omitting it  
( or multiplying it by zero ). LU failed to converge in any case.

So, I guess I’d have to question it too. I wanted to learn a bit about the RT elements  
so I may look at the matrix some more.

---

<div class="post-metadata">

### Author: ![marchywka](https://avatars.discourse-cdn.com/v4/letter/m/ee59a6/32.png) [@marchywka](https://community.freefem.org/u/marchywka)
#### Post date: [May 18, 2023, 11:32am UTC](https://community.freefem.org/t/doubt-in-the-variational-formulation-of-laplacert-edp/2471/3 "2023-05-18T11:32:08Z")

</div>

Actually if you convert the RT elements to [P2,P2] and P0 with P1  
it looks better  
( without trying to do analytical solution or check by eye more closely ).  
And again with the term in question set to zero- including it made plot look  
like blue monster attacking from the right lol.

---

<div class="post-metadata">

### Author: ![frederichecht](https://yyz2.discourse-cdn.com/flex030/user_avatar/community.freefem.org/frederichecht/32/15_2.png) [@frederichecht](https://community.freefem.org/u/frederichecht)
#### Post date: [May 22, 2023, 8:40am UTC](https://community.freefem.org/t/doubt-in-the-variational-formulation-of-laplacert-edp/2471/4 "2023-05-22T08:40:27Z")

</div>

The storie is due to old freefem solver LU with no renumbering  
And no pivoting so in this bold matrix we have 0 on diagonal bloc so small term insure no zero, and the consergenvce in eps is due to the well poseness of the problem

---

<div class="post-metadata">

### Author: ![marchywka](https://avatars.discourse-cdn.com/v4/letter/m/ee59a6/32.png) [@marchywka](https://community.freefem.org/u/marchywka)
#### Post date: [May 22, 2023, 1:30pm UTC](https://community.freefem.org/t/doubt-in-the-variational-formulation-of-laplacert-edp/2471/5 "2023-05-22T13:30:49Z")

</div>

Just to have the entire code here for reference.

```auto
// Parameters
func gd = 1.;
func g1n = 1.;
func g2n = 1.;
// Mesh
mesh Th = square(10, 10);
// Fespace
//fespace Vh(Th, RT0);
fespace Vh(Th, [P2,P2]);
Vh [u1, u2];
Vh [v1, v2];
fespace Ph(Th, P1);
Ph p, q;
Ph foo;
//foo=int0d(Th)(p);
// Problem
//problem laplaceMixte ([u1, u2, p], [v1, v2, q], solver=GMRES, eps=1.0e-10, tgv=1e30, dimKrylov=150)
//problem laplaceMixte ([u1, u2, p], [v1, v2, q], solver=GMRES)
problem laplaceMixte ([u1, u2, p], [v1, v2, q], solver=CG, eps=1.0e-10, tgv=1e30, dimKrylov=150)
//problem laplaceMixte ([u1, u2, p], [v1, v2, q], solver=LU, eps=1.0e-10, tgv=1e30, dimKrylov=150)
= int2d(Th)(
p*q*0*1e-15 //this term is here to be sure
//p*q*1e-15 //this term is here to be sure
// that all sub matrix are inversible (LU requirement)
+ u1*v1
+ u2*v2
+ p*(dx(v1)+dy(v2))
+ (dx(u1)+dy(u2))*q
)
+ int2d(Th) ( q)
- int1d(Th, 1, 2, 3)(
gd*(v1*N.x +v2*N.y)
)
+ on(4, u1=g1n, u2=g2n)
;

laplaceMixte;

// Plot
plot([u1, u2], coef=0.1, wait=true, value=true);
plot(p, fill=1, wait=true, value=true);

```

---

<div class="post-metadata">

### Author: ![frederichecht](https://yyz2.discourse-cdn.com/flex030/user_avatar/community.freefem.org/frederichecht/32/15_2.png) [@frederichecht](https://community.freefem.org/u/frederichecht)
#### Post date: [May 24, 2023, 7:39am UTC](https://community.freefem.org/t/doubt-in-the-variational-formulation-of-laplacert-edp/2471/6 "2023-05-24T07:39:06Z")

</div>

This linear system is symmetric but not positive so GC do not work in general
