# Export solution results

How can I get the result at the specified coordinate point after the solve is done？

After using solve your solution is stored on a FE function, so you can just evaluate that function where you want. If you just want to know the value on a point you could print it using:

``````cout << u(x,y,z) <<endl;
``````

Just in case you want to analyze the simulation with other code, here is the code I use to export the coordinates and solutions(u).

{
ofstream ff(“output.txt”);//open an output file
for (int i = 0; i < Th.nt; i++) {
for (int j = 0; j < 3; j++){
ff << Th[i][j].x << “,”<< Th[i][j].y << “,” << u[Vh(i,j)] << endl;} // “,” separator
}
}

Cheers,

Dear Liu,

What should I do if I want to output the results of one plane in the cube or the results of the whole cube?

Thank you very much.

Best regards,
Liu

I would recommend miguelpicos’s method. You can use the interpolation implemented in Freefem. I feel it’s way faster.

The other option is to use my way to save all the node values, but you have to use other codes, for example `scipy.interpolate`, to interpolate u at the point of interest.

Cheers,
Zezhou

Dear Zezhou,

Thank you very much for your reply.
If I want to use miguelpicos’s method to output the solution of the whole cube, is “cout << u << endl;” practicable?

Best regards,
Liu

If you use directly:

``````cout<< u[] << endl;
``````

you will get a list of values that correspond to the solution at every node of your mesh. If you also want to know which spatial point is related with each value you can use a loop like:

``````load "msh3"
mesh3 Th = cube(2,2,2);
fespace Vh(Th,P1);
Vh u = x^2 + y^2 + z^2;
cout<< "x,y,z,value" <<endl;
for(int i=0; i<Th.nv; i++){
cout<< Th(i).x << "," << Th(i).y << "," << Th(i).z << "," << u[][i]<<endl;
}
``````

I hope that could help.

Dear Miguel,

Thank you very much for your reply.
It would be of great help to me.
If I want to visualize the solution on any sectional views in the cube or on the whole cube, could I output the solution of the whole cube through the following statement:

savevtk (“Displacement of cube.vtk”, name of problem, u, dataname=Displacement of cube, order=Order);,
and then use paraview to visualize the solution on any sectional views in the cube or the whole cube?

Give you my best wishes.
Liu

Hi Liu,

If you change “name of problem” by the mesh of your problem it should be ok. Check Visualization to be sure that you use the right sintaxis.

Miguel

Dear Miguel,

Thank you so much for your considerate answer.

Best,
Liu

Thank you for your answers. Now I have a new question. After solving to obtain the electric field value, in order to obtain the magnetic field value, we need to find the curl of the electric field. How can this be realized in FreeFEM?