# Mixed FEM - numeration

**URL:** <https://community.freefem.org/t/mixed-fem-numeration/739>\
**Category:** General Discussion\
**Created:** [January 10, 2021, 6:35pm UTC](https://community.freefem.org/t/mixed-fem-numeration/739 "2021-01-10T18:35:11Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![yongxing](https://yyz2.discourse-cdn.com/flex030/user_avatar/community.freefem.org/yongxing/32/3632_2.png) [@yongxing](https://community.freefem.org/u/yongxing)\
**Post date:** [January 10, 2021, 6:35pm UTC](https://community.freefem.org/t/mixed-fem-numeration/739/1 "2021-01-10T18:35:11Z")

</div>

Dear FreeFEM users,

For a mixed element, such as P2/P1 element for velocity (in space Vh) and pressure (in space Ph) pair. If I loop **for (i=0; i\<Vh.ndof; i++)**, how can I know which DOF includes pressure and which one does not ?

If I do **varf rhs([u,v,p],[uh,vh,ph]) =…**, and later do  
**real[int] b = rhs(0, Rh)**, with Rh=[Vh, Vh, Ph]  
How are variables u,v, and p numerated in b ?

Alternatively, if I solve for  
w=A^-1 \* b  
how can I give w to [u, v, p], what’s the order?

Thanks in advance!

Yongxing.

---

<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:** [January 10, 2021, 7:56pm UTC](https://community.freefem.org/t/mixed-fem-numeration/739/2 "2021-01-10T19:56:53Z")

</div>

```auto
fespace Wh(Th, [P2, P1]);
Wh [u, v] = [1, 2];
cout << u[] << endl;

```

You’ll see that the degrees of freedom are interleaved.

---

<div class="post-metadata">

**Author:** ![yongxing](https://yyz2.discourse-cdn.com/flex030/user_avatar/community.freefem.org/yongxing/32/3632_2.png) [@yongxing](https://community.freefem.org/u/yongxing)\
**Post date:** [January 26, 2021, 7:25pm UTC](https://community.freefem.org/t/mixed-fem-numeration/739/3 "2021-01-26T19:25:28Z")

</div>

> [@prj](#):
>
> interleaved

Thank you very much! This is interesting, so there is no particular order.  
why not u first then v, or [u1, v1, u2, v2, u3, v3…] ?  
The interleaved arrangement can guarantee a good matrix structure?

---

<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:** [January 26, 2021, 7:28pm UTC](https://community.freefem.org/t/mixed-fem-numeration/739/4 "2021-01-26T19:28:55Z")

</div>

Yes, much better. For example, take a `[P1, P1]` `fespace`, instead of having a 2-by-2 block matrix [[A, B]; [C, D]], you end up with a sparse matrix A where all unknowns are 2-by-2 dense small blocks. This is coherent, for example, with PETSc [MATBAIJ](https://www.mcs.anl.gov/petsc/petsc-current/docs/manualpages/Mat/MATBAIJ.html) format.
