Understanding the output of FreeFEM

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.

1 Like

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

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.

1 Like

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

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?

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.

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