# How to get the data from the P2

**URL:** https://community.freefem.org/t/how-to-get-the-data-from-the-p2/296
**Category:** General Discussion
**Created:** [March 9, 2020, 5:58pm UTC](https://community.freefem.org/t/how-to-get-the-data-from-the-p2/296 "2020-03-09T17:58:13Z")
**Posts on this page:** 4
**Page:** 1

<div class="post-metadata">

### Author: ![Dylan](https://avatars.discourse-cdn.com/v4/letter/d/e95f7d/32.png) [@Dylan](https://community.freefem.org/u/Dylan)
#### Post date: [March 9, 2020, 5:58pm UTC](https://community.freefem.org/t/how-to-get-the-data-from-the-p2/296/1 "2020-03-09T17:58:13Z")

</div>

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~

---

<div class="post-metadata">

### Author: ![simon.garnotel](https://yyz2.discourse-cdn.com/flex030/user_avatar/community.freefem.org/simon.garnotel/32/11_2.png) [@simon.garnotel](https://community.freefem.org/u/simon.garnotel)
#### Post date: [March 9, 2020, 7:05pm UTC](https://community.freefem.org/t/how-to-get-the-data-from-the-p2/296/2 "2020-03-09T19:05:02Z")

</div>

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:

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

```

---

<div class="post-metadata">

### Author: ![Dylan](https://avatars.discourse-cdn.com/v4/letter/d/e95f7d/32.png) [@Dylan](https://community.freefem.org/u/Dylan)
#### Post date: [March 10, 2020, 6:11am UTC](https://community.freefem.org/t/how-to-get-the-data-from-the-p2/296/3 "2020-03-10T06:11:03Z")

</div>

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~

---

<div class="post-metadata">

### Author: ![Julien](https://avatars.discourse-cdn.com/v4/letter/j/71e660/32.png) [@Julien](https://community.freefem.org/u/Julien)
#### Post date: [June 12, 2020, 12:52pm UTC](https://community.freefem.org/t/how-to-get-the-data-from-the-p2/296/4 "2020-06-12T12:52:14Z")

</div>

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
