# Coordinates of DoFs in RT space

**URL:** <https://community.freefem.org/t/coordinates-of-dofs-in-rt-space/3101>\
**Category:** General Discussion\
**Created:** [April 14, 2024, 9:27pm UTC](https://community.freefem.org/t/coordinates-of-dofs-in-rt-space/3101 "2024-04-14T21:27:17Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![larismartins](https://yyz2.discourse-cdn.com/flex030/user_avatar/community.freefem.org/larismartins/32/2712_2.png) [@larismartins](https://community.freefem.org/u/larismartins)\
**Post date:** [April 14, 2024, 9:27pm UTC](https://community.freefem.org/t/coordinates-of-dofs-in-rt-space/3101/1 "2024-04-14T21:27:17Z")

</div>

Hello,

I’m trying to find the coordinates of the dofs of a Raviart-Thomas space, I’ve tried the following:

```auto
mesh Th = square(1,1);
fespace RT(Th, RT0);
RT [rtx, rty] = [x,y];

real[int, int] coordDofRT(RT.ndof, 2);

for(int i=0; i<RT.ndof; i++){
  coordDofRT(i,0) = rtx[][i];
  coordDofRT(i,0) = rty[][i];
}

cout << coordDofRT << "\n";

```

but it gives me weird coordinates:

```auto
5 2	
	   1 0
	   0 0
	   0 0
	  -1 0
	   0 0

```

I’ve also tried:

```auto
mesh Th = square(1,1);
fespace RT(Th, RT0);
RT [rtx1, rtx2] = [x,x];
RT [rty1, rty2] = [y,y];

real[int, int] coordDofRT(RT.ndof, 2);

for(int i=0; i<RT.ndof; i++){
  coordDofRT(i,0) = rtx2[][i];
  coordDofRT(i,0) = rty2[][i];
}

cout << coordDofRT << "\n";

```

and it also gives me weird values:

```auto
5 2	
	 0.5 0
	   0 0
	   0 0
	  -1 0
	 0.5 0

```

Does anyone know how to do this? I need to identify the DoFs that touch the boundary of the domain and I would like to do this through the coordinates, like, if x == y == 0 && x == y == 1.

---

<div class="post-metadata">

**Author:** ![lucassfernandez](https://avatars.discourse-cdn.com/v4/letter/l/8dc957/32.png) [@lucassfernandez](https://community.freefem.org/u/lucassfernandez)\
**Post date:** [April 15, 2024, 4:19pm UTC](https://community.freefem.org/t/coordinates-of-dofs-in-rt-space/3101/2 "2024-04-15T16:19:49Z")

</div>

Hi! 😉  
I think the second line within the loop should be:

```auto
coordDofRT(i,1) = rty[][i];

```

I’m not sure about the second attempt that you tried. It seems it is not ok.

---

<div class="post-metadata">

**Author:** ![larismartins](https://yyz2.discourse-cdn.com/flex030/user_avatar/community.freefem.org/larismartins/32/2712_2.png) [@larismartins](https://community.freefem.org/u/larismartins)\
**Post date:** [April 15, 2024, 4:38pm UTC](https://community.freefem.org/t/coordinates-of-dofs-in-rt-space/3101/3 "2024-04-15T16:38:35Z")

</div>

Ops, thank you!

```auto
mesh Th = square(1,1);
fespace RT(Th, RT0);
RT [rtx, rty] = [x,y];

real[int, int] coordDofRT(RT.ndof, 2);

for(int i=0; i<RT.ndof; i++){
  coordDofRT(i,0) = rtx[][i];
  coordDofRT(i,1) = rty[][i];
}

cout << coordDofRT << "\n";

```

But even though, I still get some weird coordinates:

```auto
5 2	
	   1 1
	   0 0
	   0 0
	  -1 -1
	   0 0

```

---

<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:** [April 16, 2024, 2:38pm UTC](https://community.freefem.org/t/coordinates-of-dofs-in-rt-space/3101/5 "2024-04-16T14:38:18Z")

</div>

Warning the RT0 finite element are not a Lagrange Finite element so the Dot are not value a point (node).

so  
rtx[10] are the value of the dof 10 not coordinate of points.

---

<div class="post-metadata">

**Author:** ![fb77](https://yyz2.discourse-cdn.com/flex030/user_avatar/community.freefem.org/fb77/32/3796_2.png) [@fb77](https://community.freefem.org/u/fb77)\
**Post date:** [April 16, 2024, 3:56pm UTC](https://community.freefem.org/t/coordinates-of-dofs-in-rt-space/3101/6 "2024-04-16T15:56:05Z")

</div>

I had such difficulty and I used the folloing lines to get the connectivity of edges with respect to triangles

```auto
fespace RT(Th, RT0);

// array of no of (1 or 2) triangles on each side of edge associated to dof
// and associated edge number
int[int,int] trofdof(RT.ndof,4);
trofdof=-1;// -1 means not (yet) defined
for (int k=0;k<Th.nt;k++){
for (int i=0;i<3;i++){
   int noki=RT(k,i);// df of element k and edge i
   if (trofdof(noki,0)==-1){
   trofdof(noki,0)=k;
   trofdof(noki,1)=i;
   }
   else if (trofdof(noki,2)==-1){
   trofdof(noki,2)=k;
   trofdof(noki,3)=i;
   }
   else {
   cout << "error trofdof" << endl;
   }
}}

```

Then `trofdof(j, )` has a -1 means that j is the index of dof on the boundary.  
If you want the coordinates you can do

```auto
// coordinates of dof
real[int] rtx(RT.ndof),rty(RT.ndof);
for (int j=0;j<RT.ndof;j++){
    int k=trofdof(j,0);
    int i=trofdof(j,1);
    rtx(j)=(Th[k][(i+1)%3].x+Th[k][(i+2)%3].x)/2.;
    rty(j)=(Th[k][(i+1)%3].y+Th[k][(i+2)%3].y)/2.;
}

```

full code is  
[RTDoF.edp](https://community.freefem.org/uploads/short-url/bxjPf2TU4SLRpKXvIXaNVrQ1oOH.edp) (889 Bytes)

---

<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:** [April 20, 2024, 5:24pm UTC](https://community.freefem.org/t/coordinates-of-dofs-in-rt-space/3101/7 "2024-04-20T17:24:20Z")

</div>

I o not like the name coordinate of dog in this case because they are no sens.

But if you want to have coordinate of middle of edge no problem,  
Use the finite element P0edge and interpole x and y like (not tested)

```auto
mesh Th= squrare(10,10);
fespace Eh(Th,P0edge);
Ex X=x,Y=y;

```

X and Y corresponding to rex a,d rty.
