How to get the data from the P2

Dear all,
I use the P2 and P1 to compare with analytical solution by paraview.
The error of P2 is bigger than P1.
I know that the warning " Finite element variables saved using paraview must be in P0 or P1 ".
Why not use paraview to load P2?
Is it because paraview can only read the vertices, the other three nodes on the border can’t?

And, how to get the data from P2?

Thanks~

Paraview only knows Cell type (P0) and Data type (P1), you can not read P2 finite element function directly with paraview.
You can export P2 data in a file using something like this:

for (int i=0; i<Uh.ndof; ++i)
  file >> u[][i] << endl;

Dear simon.garnotel,
If I want to get values on a line that I select (like paraview), how can I do?
example:a square (0,0), (2,0), (2,2), (0,2)
How to get values on a line (point(0,1) to point(2,1))?

Thanks~

Hi everyone !

This topic seems perfect to ask my question !

I use FreeFem++ to get the matrices of a given problem and then solve the system in Matlab for some reason. I build the matrices with P2 elements. However I need to export the label (for boundary elements) of each node of the fespace P2. So far I succeeded to have the region(s) of each nodes, but still have issues to get the label of “boundary nodes”.
Does someone knows how to do it ?

By the way, I know that we can obtain the boundary elements with Th.be(k), but we only get “P1 nodes” with Th.be(k)[i]…

Thank you for your help !
Julien