# Coordinates of DoFs in RT space

Hello,

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

``````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:

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

``````

I’ve also tried:

``````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:

``````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.

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

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

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

Ops, thank you!

``````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:

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

``````

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.

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

``````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

``````// 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 (889 Bytes)

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)

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

``````

X and Y corresponding to rex a,d rty.