# Ffddm problem by using RT0 element

**URL:** <https://community.freefem.org/t/ffddm-problem-by-using-rt0-element/2427>\
**Category:** General Discussion\
**Created:** [May 2, 2023, 8:49am UTC](https://community.freefem.org/t/ffddm-problem-by-using-rt0-element/2427 "2023-05-02T08:49:39Z")\
**Posts on this page:** 8\
**Page:** 1

<div class="post-metadata">

**Author:** ![YAOH](https://avatars.discourse-cdn.com/v4/letter/y/ea5d25/32.png) [@YAOH](https://community.freefem.org/u/YAOH)\
**Post date:** [May 2, 2023, 8:49am UTC](https://community.freefem.org/t/ffddm-problem-by-using-rt0-element/2427/1 "2023-05-02T08:49:40Z")

</div>

Dear all,

I am using ffddm to a mixed finite element problem with finite spaces [RT0,P0].  
When I used ffddmbuildDfespace to build the local space, it showed an error:

Probleme partition de l’unite : uu.linfty = 1.

I realized that I should use ffddmbuildDfespaceEdge instead of ffddmbuildDfespace, for non Lagrange finite element:  
[https://doc.freefem.org/documentation/ffddm/documentation.html#ffddmdocumentationlocalfiniteelementspaces](https://doc.freefem.org/documentation/ffddm/documentation.html#ffddmdocumentationlocalfiniteelementspaces)

But I have no idea how to choose a Pkpart space for [RT0,P0].

The following is my example:

include “ffddm.idp”  
load “Element\_Mixte”

macro dimension 2// EOM  
int[int] ll=[1,2,3,4]; //boundary labels : 1 for bottom 2 for right 3 for upper 4 for left  
mesh Th = square(20, 20, [x, y],label=ll);  
ffddmbuildDmesh(M,Th,mpiCommWorld)

macro def(i) [i,i#B,i#C]// EOM // temperature field definition  
macro init(i) [i,i,i]// EOM // temperature field initialization  
func Pk = [RT0,P0];  
func PkPart = [P1,P1,P0];  
ffddmbuildDfespaceEdge(MFE , M , real , def , init , Pk, def, init,PkPart)  
ffddmsetupinit(M,MFE)

Thanks!  
Y.H.

---

<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:** [May 2, 2023, 9:11am UTC](https://community.freefem.org/t/ffddm-problem-by-using-rt0-element/2427/2 "2023-05-02T09:11:03Z")

</div>

~~ffddm does not handle RT finite elements as of today.~~ PETSc does, cf. [FreeFem-sources/laplace-RT-2d-PETSc.edp at develop · FreeFem/FreeFem-sources · GitHub](https://github.com/FreeFem/FreeFem-sources/blob/develop/examples/hpddm/laplace-RT-2d-PETSc.edp) or [FreeFem-sources/laplace-RT-3d-PETSc.edp at develop · FreeFem/FreeFem-sources · GitHub](https://github.com/FreeFem/FreeFem-sources/blob/develop/examples/hpddm/laplace-RT-3d-PETSc.edp).

---

<div class="post-metadata">

**Author:** ![YAOH](https://avatars.discourse-cdn.com/v4/letter/y/ea5d25/32.png) [@YAOH](https://community.freefem.org/u/YAOH)\
**Post date:** [May 2, 2023, 10:48am UTC](https://community.freefem.org/t/ffddm-problem-by-using-rt0-element/2427/3 "2023-05-02T10:48:48Z")

</div>

Thank you very much for your response, I will try to write by PETSc…

---

<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:** [May 2, 2023, 12:42pm UTC](https://community.freefem.org/t/ffddm-problem-by-using-rt0-element/2427/4 "2023-05-02T12:42:43Z")

</div>

Here it is with `macro_ddm.idp`.

```auto
load "PETSc"
include "macro_ddm.idp"
load "Element_Mixte"

int[int] ll=[1,2,3,4]; //boundary labels : 1 for bottom 2 for right 3 for upper 4 for left
mesh Th = square(20, 20, [x, y],label=ll);

macro def(i) [i,i#B,i#C]// EOM // temperature field definition
macro init(i) [i,i,i]// EOM // temperature field initialization
func Pk = [RT0,P0];
Mat A;
buildDmesh(Th);
fespace Wh(Th, Pk);
{
macro ThPostProcessD(D) {
    Wh def(u), def(v);
    varf onG(def(u), def(v)) = on(-111111, u = 10 + x + y, uB = 100 + y - x);
    v[] = D;
    u[] = onG(0, Wh);
    for [j, dj : u[]] dj = abs(dj) > 1e-2 ? 0.0 : 1.0;
    def(u) = [u, uB, vC];
    D = u[];
}// EOM
createMat(Th, A, Pk);
}

```

You do not have to worry about the `ThPostProcessD` macro, it’s just to make sure that your matrix is properly spread among processes. Then, you can write standard FreeFEM and assemble your `varf` in `A`.

---

<div class="post-metadata">

**Author:** ![phtournier](https://avatars.discourse-cdn.com/v4/letter/p/3da27b/32.png) [@phtournier](https://community.freefem.org/u/phtournier)\
**Post date:** [May 2, 2023, 1:56pm UTC](https://community.freefem.org/t/ffddm-problem-by-using-rt0-element/2427/5 "2023-05-02T13:56:51Z")

</div>

FYI you can use the P0edge finite element (scalar constant-per-edge element) to build a partition of unity for RT0 :

```auto
include "ffddm.idp"
load "Element_Mixte"

macro dimension 2// EOM
int[int] ll=[1,2,3,4]; //boundary labels : 1 for bottom 2 for right 3 for upper 4 for left
mesh Th = square(20, 20, [x, y],label=ll);
ffddmbuildDmesh(M,Th,mpiCommWorld)

macro def(i) [i,i#B,i#C]// EOM // temperature field definition
macro init(i) [i,i,i]// EOM // temperature field initialization
macro defpart(i) [i, i#B] //
macro initpart(i) [i,i] //
func Pk = [RT0,P0];
func PkPart = [P0edge,P0];
ffddmbuildDfespaceEdge(MFE , M , real , def , init , Pk, defpart, initpart, PkPart)
ffddmsetupinit(M,MFE)

```

---

<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:** [May 2, 2023, 2:13pm UTC](https://community.freefem.org/t/ffddm-problem-by-using-rt0-element/2427/6 "2023-05-02T14:13:10Z")

</div>

Oops, my bad, I will edit my answer to mention only higher orders (which are not handled if I’m not mistaken — again).

---

<div class="post-metadata">

**Author:** ![YAOH](https://avatars.discourse-cdn.com/v4/letter/y/ea5d25/32.png) [@YAOH](https://community.freefem.org/u/YAOH)\
**Post date:** [May 2, 2023, 2:15pm UTC](https://community.freefem.org/t/ffddm-problem-by-using-rt0-element/2427/7 "2023-05-02T14:15:21Z")

</div>

Thank you very much, your answer solve my problem.  
Bonne journée.

---

<div class="post-metadata">

**Author:** ![YAOH](https://avatars.discourse-cdn.com/v4/letter/y/ea5d25/32.png) [@YAOH](https://community.freefem.org/u/YAOH)\
**Post date:** [May 2, 2023, 2:25pm UTC](https://community.freefem.org/t/ffddm-problem-by-using-rt0-element/2427/8 "2023-05-02T14:25:06Z")

</div>

I tried Pk= [RT1, P0] with PkPart = [P1Edge,P0], not worked;  
but somehow Pk = [BDM1,P0] with PkPart = [P1nc,P1nc, P0] can work well, where BDM1 is a higher order option for me…  
Thank you again!
