Export solution

Dear FreeFem community!

I would like to know if there is an example to save a 2D solution for 1D, considering a unit square domain, and wanting to save for example the solution on the axis Y = 0.5

Given a FE-function u, you can get the value at some point (for example (1, 0.5)), like this: u(1, 0.5).If you iterate over the x-coordinate, you can sample a line.

Just to giving a sample code to complement the previous answer:
(f is a FE field)
ofstream o(“line_output”);
int Np = 50;
real delx = (x1-x0)/(Np-1.);
real dely = (y1-y0)/(Np-1.);
real xp = x0;
real yp = y0;
for(int i=0; i<Np; ++i){
o << xp <<" “;
o << yp <<” “;
o <<f(xp,yp)<<”\n";
xp += delx;
yp += dely;

Thank you, your tips were very useful!