# Understanding the output of FreeFEM

**URL:** <https://community.freefem.org/t/understanding-the-output-of-freefem/479>\
**Category:** General Discussion\
**Created:** [June 19, 2020, 11:58am UTC](https://community.freefem.org/t/understanding-the-output-of-freefem/479 "2020-06-19T11:58:47Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![kws](https://avatars.discourse-cdn.com/v4/letter/k/5f8ce5/32.png) [@kws](https://community.freefem.org/u/kws)\
**Post date:** [June 19, 2020, 11:58am UTC](https://community.freefem.org/t/understanding-the-output-of-freefem/479/1 "2020-06-19T11:58:47Z")

</div>

I am having some trouble understanding the output of FreeFEM and how to use it for further analysis. After solving for a solution u it is possible to save it to a file using

ofstream TheFile(“some\_file\_name”); TheFile \<\< u[];

or alternatively using

ffSaveData(u,“some\_file\_name”);

if one includes ffmatlib.idp. This gives a bunch of numbers, but it is unclear to me exactly what they mean. If one uses P1 then the amount of numbers contained in u equals the number of vertices, so I expect u to contain the values of the function at those vertices. This seems indeed to be the case at least for some PDE that I considered.

However, if one uses P2 then the u contains more numbers than the amount of vertices. So I wonder what these numbers mean.

Finally, I wonder if also in the P2 case one can get some output from FreeFem which can be used for further analysis. Ideally, this would be an array of the form [x, y, u(x,y)] where u is the solution.

Any help would be greatly appreciated!

EDIT: Initially I doubted that the values of u correspond to function values at the vertices in the case P1. Upon closer inspection I now believe that this is the case, so I modified my message in this regard.

---

<div class="post-metadata">

**Author:** ![frederichecht](https://yyz2.discourse-cdn.com/flex030/user_avatar/community.freefem.org/frederichecht/32/15_2.png) [@frederichecht](https://community.freefem.org/u/frederichecht)\
**Post date:** [June 22, 2020, 7:21am UTC](https://community.freefem.org/t/understanding-the-output-of-freefem/479/2 "2020-06-22T07:21:03Z")

</div>

The idea is simple,

u[] is the array of degree of freedom (dof)  
when you write:

```
TheFile << u[];

```

you save this array

for the ffmatlib.idp see/use [https://github.com/samplemaker/freefem\_matlab\_octave\_plot](https://github.com/samplemaker/freefem_matlab_octave_plot)

To set an array with dof as x or y coordinates just do in Vh fespace

```
 Vh xx=x,yy=y;

```

then xx[], yy[] gives you the array fo coordintate x or y respectively.

so you can write some thing like

```
for(int i=0; i< Vh.ndof; ++i)
   {
      TheFile << xx[][i] << " " << yy[][i] << " " << u[][i] << endl; 
   }

```

FH.

---

<div class="post-metadata">

**Author:** ![kws](https://avatars.discourse-cdn.com/v4/letter/k/5f8ce5/32.png) [@kws](https://community.freefem.org/u/kws)\
**Post date:** [June 22, 2020, 7:26pm UTC](https://community.freefem.org/t/understanding-the-output-of-freefem/479/3 "2020-06-22T19:26:56Z")

</div>

Thank you!  
This is exactly what I was looking for!

---

<div class="post-metadata">

**Author:** ![haiyang-liu-19](https://yyz2.discourse-cdn.com/flex030/user_avatar/community.freefem.org/haiyang-liu-19/32/1864_2.png) [@haiyang-liu-19](https://community.freefem.org/u/haiyang-liu-19)\
**Post date:** [August 25, 2023, 8:51am UTC](https://community.freefem.org/t/understanding-the-output-of-freefem/479/4 "2023-08-25T08:51:52Z")

</div>

Thanks! I used your method, and successfully got the matrix containing x,y,z,u at each rows. But i noticed that there exists same coordinates (x,y,z) for different u when using P1dc fespace. If it is the problem of freedoms, is there some way to clarify the kind of each value of u?

 ![无标题](https://canada1.discourse-cdn.com/flex030/uploads/freefem/original/2X/a/a342db62b0e2006bda6184bef2c2014bd1f46850.jpeg)

---

<div class="post-metadata">

**Author:** ![frederichecht](https://yyz2.discourse-cdn.com/flex030/user_avatar/community.freefem.org/frederichecht/32/15_2.png) [@frederichecht](https://community.freefem.org/u/frederichecht)\
**Post date:** [August 26, 2023, 2:57pm UTC](https://community.freefem.org/t/understanding-the-output-of-freefem/479/5 "2023-08-26T14:57:23Z")

</div>

The problem is P1dc implies for each triangle 3 dof (degree of freedom) one a each vertices,

But because it is discontinue the value at vertices differs form one vertices to a other depending of the triangle but the coordinates are the same.

In all the case Lagrange case, the dof is defined with the coordinate and the triangle containing this dof.

---

<div class="post-metadata">

**Author:** ![haiyang-liu-19](https://yyz2.discourse-cdn.com/flex030/user_avatar/community.freefem.org/haiyang-liu-19/32/1864_2.png) [@haiyang-liu-19](https://community.freefem.org/u/haiyang-liu-19)\
**Post date:** [August 30, 2023, 2:41pm UTC](https://community.freefem.org/t/understanding-the-output-of-freefem/479/6 "2023-08-30T14:41:27Z")

</div>

Thanks! Your answer helps me better understand the fespaces in freeFEM.
