# How to use RT03d finite elements?

**URL:** <https://community.freefem.org/t/how-to-use-rt03d-finite-elements/3569>\
**Category:** General Discussion\
**Created:** [October 30, 2024, 11:56am UTC](https://community.freefem.org/t/how-to-use-rt03d-finite-elements/3569 "2024-10-30T11:56:12Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![yowie](https://avatars.discourse-cdn.com/v4/letter/y/e9bcb4/32.png) [@yowie](https://community.freefem.org/u/yowie)\
**Post date:** [October 30, 2024, 11:56am UTC](https://community.freefem.org/t/how-to-use-rt03d-finite-elements/3569/1 "2024-10-30T11:56:12Z")

</div>

Hey y’all!  
As prep for my master’s thesis, I’m trying to implement a numerical method for the heat equation using Raviart-Thomas finite elements. While the documentation has a nice example on how to use RT0 finite elements in 2D, I’m having a lot of trouble trying to get them to work in 3D. I naïvely tried to adapt the code in the `LaplaceRT.edp` example file as such:

> **Code**
>
> ```auto
> load "msh3"
> 
> // Parameters
> func gd = 1.;
> func g1n = 1.;
> func g2n = 1.;
> func g3n = 1.;
> 
> // Mesh
> mesh3 Th = cube(10, 10, 10);
> 
> // Fespace
> fespace Vh(Th, RT03d);
> Vh [u1, u2, u3];
> Vh [v1, v2, v3];
> 
> fespace Ph(Th, P0);
> Ph p, q;
> 
> // Problem
> problem laplaceMixte ([u1, u2, u3, p], [v1, v2, v3, q], solver=GMRES, eps=1.0e-10, tgv=1e30, dimKrylov=150)
> = int3d(Th)(
> p*q*1e-15 //this term is here to be sure
> // that all sub matrix are inversible (LU requirement)
> + u1*v1
> + u2*v2
> + u3*v3
> + p*(dx(v1)+dy(v2)+dz(v3))
> + (dx(u1)+dy(u2)+dz(u3))*q
> )
> + int3d(Th) (
> q
> )
> - int2d(Th, 1, 2, 3, 4, 5)(
> gd*(v1*N.x + v2*N.y + v3*N.z)
> )
> + on(6, u1=g1n, u2=g2n, u3=g3n)
> ;
> 
> // Solve
> laplaceMixte;
> 
> // Plot
> plot([u1, u2, u3], coef=0.1, wait=true, value=true);
> plot(p, fill=1, wait=true, value=true);
> 
> ```

The GMRES solver is not converging, and even if I cut it off prematurely, the plots are empty. What’s going wrong here? And advice would be greatly appreciated. I’m using FreeFEM++ version 4.14.

---

<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:** [October 30, 2024, 12:27pm UTC](https://community.freefem.org/t/how-to-use-rt03d-finite-elements/3569/2 "2024-10-30T12:27:03Z")

</div>

Why are you using GMRES?

---

<div class="post-metadata">

**Author:** ![yowie](https://avatars.discourse-cdn.com/v4/letter/y/e9bcb4/32.png) [@yowie](https://community.freefem.org/u/yowie)\
**Post date:** [October 30, 2024, 5:01pm UTC](https://community.freefem.org/t/how-to-use-rt03d-finite-elements/3569/3 "2024-10-30T17:01:32Z")

</div>

I only changed the parts of the example code that were absolutely necessary to go from 2D to 3D. Using the default solver options (i.e. passing no additional arguments to the `problem` constructor) still leads to empty plots.

---

<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:** [October 30, 2024, 9:28pm UTC](https://community.freefem.org/t/how-to-use-rt03d-finite-elements/3569/4 "2024-10-30T21:28:14Z")

</div>

Even with `solver = sparsesolver`?

---

<div class="post-metadata">

**Author:** ![yowie](https://avatars.discourse-cdn.com/v4/letter/y/e9bcb4/32.png) [@yowie](https://community.freefem.org/u/yowie)\
**Post date:** [October 31, 2024, 3:27pm UTC](https://community.freefem.org/t/how-to-use-rt03d-finite-elements/3569/5 "2024-10-31T15:27:19Z")

</div>

Yup, still empty plots.

---

<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:** [October 31, 2024, 3:31pm UTC](https://community.freefem.org/t/how-to-use-rt03d-finite-elements/3569/6 "2024-10-31T15:31:22Z")

</div>

If you do `cout << u1[].min << " " << u1[].max << endl;` you’ll see that the solution is clearly nonzero. FreeFEM is not a very suitable tool for 3D visualization, so I would just output the solution using `savevtk` and do any post-processing in ParaView.
