# Order of variables in matrix generated with varf with a \[P1, P1, P0\] fespace

**URL:** https://community.freefem.org/t/order-of-variables-in-matrix-generated-with-varf-with-a-p1-p1-p0-fespace/3489
**Category:** General Discussion
**Created:** [September 17, 2024, 2:51pm UTC](https://community.freefem.org/t/order-of-variables-in-matrix-generated-with-varf-with-a-p1-p1-p0-fespace/3489 "2024-09-17T14:51:22Z")
**Posts on this page:** 1
**Showing post:** 2

<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: [September 20, 2024, 11:17am UTC](https://community.freefem.org/t/order-of-variables-in-matrix-generated-with-varf-with-a-p1-p1-p0-fespace/3489/2 "2024-09-20T11:17:18Z")

</div>

Hello,  
I think there is no official rule concerning the ordering of dof.  
Nevertheless you can get it a posteriori.  
In the FreeFem documentation

> **[FreeFEM-documentation.pdf](https://doc.freefem.org/pdf/FreeFEM-documentation.pdf)**
>
> 33.81 MB

p.116-120 you can find ways to get the mesh info,  
like `Th[k][i]` to get the vertex number (for i=0,1,2) in triangle k  
and `Th[k][i].x Th[k][i].y` its coordinates  
It induces a first vertex (i=0) associated to triangle k,  
a second vertex (i=1) and a third vertex (i=2).

For your fespace `XhxXhxMh(Th,[P1,P1,P0])`  
corresponding to x,y components of velocity in P1, pressure in P0  
you have the command `XhxXhxMh(k,i)` for k the triangle number, i=0,1…6  
it gives the 7 dof numbers around the triangle k. They are listed as  
x component of velocity for first vertex  
x component of velocity for second vertex  
x component of velocity for third vertex  
y component of velocity for first vertex  
y component of velocity for second vertex  
y component of velocity for third vertex  
pressure component for the triangle

For example, to show these values you can write

```auto
for (int k=0;k<Th.nt;k++){//loop on triangles
 for (int i=0;i<7;i++){//loop on dof around triangle
  int dof=XhxXhxMh(k,i);
  cout << "k="<< k << " i=" << i << " dof=" << dof << endl;
 }
}

```

With this you have the needed information. Then you should be able to reorder the indices as you wish…

---

_[View the full topic](https://community.freefem.org/t/order-of-variables-in-matrix-generated-with-varf-with-a-p1-p1-p0-fespace/3489)._
