A small puzzle about the length of vector valued fespace

Dear all
if we create two fespace Vh(Th,[P2 P2 P1]) and Mh(Th,P1) on the same mesh, then we define Vh [ux,uy,up] and Mh [vp], I find that the length of vp (vp.n) doesn’t equal to the length of up.
I think the length of up should equal to the number of points, because it is defined as P1 in the Vh(Th,[P2 P2 P1]). But it doesn’t. I just don’t know why.
Thanks a lot!

I think ux, uy, up all just return the vector that corresponds to the full vectorial finite element space. This is just how it is as far as I know.

If you want to access only up as a vector, you could set up a problem with three FE spaces ux (P2), uy (P2), up (P1), and assemble the problem you are solving using block matrices.

Or maybe use indices and go through the vector with something like this (I did not test the code)
Vh fieldInd [f1,f2,f3] = [1,2,3];
Mh mp;
int ip = 0;
for [i, fi: f1] (fi==3 ? mp[ip++] = fi : 0);

1 Like

Thanks very much~ I have found the problem that some of the data is stored according to the mesh connectivity( the length of data vp [p1] equals to the 3*n_triangle), while some of the data up [p1] is stored in the point of the mesh , so its length equals to the n_points. It’s my fault to make such a mistake…

Besides, there also exits a tool in matlab (ffvectorget.m) which could get ux from the vectorized fespace (ux,uy,up). However, the ux is stored according to the mesh connectivity, so the length of ux equals to 6*n_triangle instead of the degree of freedom about P2 on the Th.