# 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:** 1

<div class="post-metadata">

### Author: ![djahid](https://avatars.discourse-cdn.com/v4/letter/d/bbe5ce/32.png) [@djahid](https://community.freefem.org/u/djahid)
#### Post date: [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/1 "2024-09-17T14:51:22Z")

</div>

Hello,  
I’m trying to compare the matrix generated from the following code with another code I have that solves the same problem

```auto
mesh Th=square(2, 2);
fespace Xh(Th,P1);
fespace Mh(Th,P0);
fespace XhxXhxMh(Th,[P1,P1,P0]);

varf vfStokes ([u1,u2,p],[v1,v2,q]) =
    int2d(Th)(
             alpha*( u1*v1 + u2*v2)
            + nu * ( dx(u1)*dx(v1) + dy(u1)*dy(v1)
            + dx(u2)*dx(v2) + dy(u2)*dy(v2) )
            + p*q*(1e-4)
            - p*dx(v1) - p*dy(v2)
            - dx(u1)*q - dy(u2)*q
           );
varf b([u1,u2,p],[v1,v2,q]) = int2d(Th)( u1*v1+u2*v2+p*q*0.) ;
matrix A= vfStokes(XhxXhxMh, XhxXhxMh, solver="SPARSESOLVER", factorize=0); 
matrix B= b(XhxXhxMh, XhxXhxMh, solver=CG, eps=1e-20); 

```

Here the A matrix is:

```auto
0: 1 0 0.25 -0.5 0 0 0 0 -0.5 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
1: 0 1 -0.25 0 -0.5 0 0 0 0 -0.5 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
2: 0.25 -0.25 1.25e-05 -0.25 0 0 0 0 0 0.25 0 0 0 0 0 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 0 0 0
18: 0 0 0 0 0 0 0 0 0 0 0 0 0 0 -0.25 0.25 0 0 1.25e-05 0 0 -0.25 0.25 0 0 0
19: 0 0 0 0 0 0 0 0 0 0 -0.25 -0.5 0 -1 0 0 0 -0.25 0 2 0 0 0 -0.5 0 0 
20: 0 0 0 0 0 0 0 0 0 0 0.25 0 -0.5 0 -1 0 0 0 0 0 2 0 0 0 -0.5 -0.25
21: 0 0 0 0 0 0 0 0 0 0 0 0 0 -1 0 -0.5 0 0 -0.25 0 0 2 0 -0.5 0 0.25
22: 0 0 0 0 0 0 0 0 0 0 0 0 0 0 -1 0 -0.5 0.25 0.25 0 0 0 2 0 -0.5 0
23: 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 -0.5 0 -0.5 0 1 0 -0.25
24: 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 -0.5 0 -0.5 0 1 0.25
25: 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 -0.25 0.25 0 -0.25 0.25 1.25e-05

```

I’m trying to understand the order of the u1, u2, p variables in this matrix. Because I had thought it would be ordered like [u1\_1, u1\_2, u1\_3, …, u1\_NV, u2\_1, u2\_2, u2\_3, …, u2\_NV, p\_1, p\_2, …, p\_NT] but that’s not the case.

here is the matrix when I generated it using this order:

```auto
1 -0.5 0 -0.5 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0.25 0 0 0 0 0 0 0 
-0.5 2 -0.5 0 -1 0 0 0 0 0 0 0 0 0 0 0 0 0 -0.25 0 0.25 0 0 0 0 0 
0 -0.5 1 0 0 -0.5 0 0 0 0 0 0 0 0 0 0 0 0 0 0 -0.25 0 0 0 0 0 
-0.5 0 0 2 -1 0 -0.5 0 0 0 0 0 0 0 0 0 0 0 0 0.25 0 0 0.25 0 0 0 
0 -1 0 -1 4 -1 0 -1 0 0 0 0 0 0 0 0 0 0 0 -0.25 0 0.25 -0.25 0 0.25 0 
0 0 -0.5 0 -1 2 0 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0 0 0 0 0.25 0 0 -0.25 0 0 0 0 0 0 0 0.0001 0 0 0 0 
0 0 0 0.25 -0.25 0 0 0 0 0 0 0 0 0.25 0 0 -0.25 0 0 0 0 0 0.0001 0 0 0 
0 0 0 0 0 0 0.25 -0.25 0 0 0 0 0.25 0 0 -0.25 0 0 0 0 0 0 0 0.0001 0 0
0 0 0 0 0.25 -0.25 0 0 0 0 0 0 0 0 0.25 0 0 -0.25 0 0 0 0 0 0 0.0001 0
0 0 0 0 0 0 0 0.25 -0.25 0 0 0 0 0.25 0 0 -0.25 0 0 0 0 0 0 0 0 0.0001

```

which is basically a matrix of the form

```auto
A 0 Bx.T
0 A By.T
Bx By eps*I

```

So my question is where can I find this variable order information of the matrix A or the fespace XhxXhxMh? so I can compare the matrices

Thank you very much for your help and have a good day.

---

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