# Export solution results

**URL:** <https://community.freefem.org/t/export-solution-results/1972>\
**Category:** General Discussion\
**Created:** [August 29, 2022, 11:58am UTC](https://community.freefem.org/t/export-solution-results/1972 "2022-08-29T11:58:41Z")\
**Posts on this page:** 11\
**Page:** 1

<div class="post-metadata">

**Author:** ![liang](https://yyz2.discourse-cdn.com/flex030/user_avatar/community.freefem.org/liang/32/1257_2.png) [@liang](https://community.freefem.org/u/liang)\
**Post date:** [August 29, 2022, 11:58am UTC](https://community.freefem.org/t/export-solution-results/1972/1 "2022-08-29T11:58:41Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![miguelpicos](https://avatars.discourse-cdn.com/v4/letter/m/8797f3/32.png) [@miguelpicos](https://community.freefem.org/u/miguelpicos)\
**Post date:** [August 30, 2022, 8:35am UTC](https://community.freefem.org/t/export-solution-results/1972/2 "2022-08-30T08:35:17Z")

</div>

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:

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

```

---

<div class="post-metadata">

**Author:** ![zezhou](https://avatars.discourse-cdn.com/v4/letter/z/7cd45c/32.png) [@zezhou](https://community.freefem.org/u/zezhou)\
**Post date:** [August 30, 2022, 3:01pm UTC](https://community.freefem.org/t/export-solution-results/1972/3 "2022-08-30T15:01:27Z")

</div>

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  
ff\<\<“x”\<\<“\t”\<\<“y”\<\<“\t”\<\<“z”\<\<endl; // header  
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,

---

<div class="post-metadata">

**Author:** ![SHENG](https://avatars.discourse-cdn.com/v4/letter/s/839c29/32.png) [@SHENG](https://community.freefem.org/u/SHENG)\
**Post date:** [August 31, 2022, 1:52pm UTC](https://community.freefem.org/t/export-solution-results/1972/4 "2022-08-31T13:52:05Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![zezhou](https://avatars.discourse-cdn.com/v4/letter/z/7cd45c/32.png) [@zezhou](https://community.freefem.org/u/zezhou)\
**Post date:** [August 31, 2022, 2:09pm UTC](https://community.freefem.org/t/export-solution-results/1972/5 "2022-08-31T14:09:35Z")

</div>

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`](https://docs.scipy.org/doc/scipy/reference/interpolate.html#module-scipy.interpolate), to interpolate u at the point of interest.

Cheers,  
Zezhou

---

<div class="post-metadata">

**Author:** ![SHENG](https://avatars.discourse-cdn.com/v4/letter/s/839c29/32.png) [@SHENG](https://community.freefem.org/u/SHENG)\
**Post date:** [September 1, 2022, 12:17am UTC](https://community.freefem.org/t/export-solution-results/1972/6 "2022-09-01T00:17:47Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![miguelpicos](https://avatars.discourse-cdn.com/v4/letter/m/8797f3/32.png) [@miguelpicos](https://community.freefem.org/u/miguelpicos)\
**Post date:** [September 1, 2022, 6:08am UTC](https://community.freefem.org/t/export-solution-results/1972/7 "2022-09-01T06:08:55Z")

</div>

If you use directly:

```auto
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:

```auto
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.

---

<div class="post-metadata">

**Author:** ![SHENG](https://avatars.discourse-cdn.com/v4/letter/s/839c29/32.png) [@SHENG](https://community.freefem.org/u/SHENG)\
**Post date:** [September 1, 2022, 7:10am UTC](https://community.freefem.org/t/export-solution-results/1972/8 "2022-09-01T07:10:36Z")

</div>

Dear Miguel,

Thank you very much for your reply.  
It would be of great help to me.  
I have another question, please help 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:  
load “iovtk”  
…  
…  
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

---

<div class="post-metadata">

**Author:** ![miguelpicos](https://avatars.discourse-cdn.com/v4/letter/m/8797f3/32.png) [@miguelpicos](https://community.freefem.org/u/miguelpicos)\
**Post date:** [September 1, 2022, 7:39am UTC](https://community.freefem.org/t/export-solution-results/1972/9 "2022-09-01T07:39:25Z")

</div>

Hi Liu,

If you change “name of problem” by the mesh of your problem it should be ok. Check [Visualization](https://doc.freefem.org/documentation/visualization.html#link-with-paraview) to be sure that you use the right sintaxis.

Miguel

---

<div class="post-metadata">

**Author:** ![SHENG](https://avatars.discourse-cdn.com/v4/letter/s/839c29/32.png) [@SHENG](https://community.freefem.org/u/SHENG)\
**Post date:** [September 1, 2022, 7:49am UTC](https://community.freefem.org/t/export-solution-results/1972/10 "2022-09-01T07:49:56Z")

</div>

Dear Miguel,

Thank you so much for your considerate answer.

Best,  
Liu

---

<div class="post-metadata">

**Author:** ![liang](https://yyz2.discourse-cdn.com/flex030/user_avatar/community.freefem.org/liang/32/1257_2.png) [@liang](https://community.freefem.org/u/liang)\
**Post date:** [September 12, 2022, 3:05pm UTC](https://community.freefem.org/t/export-solution-results/1972/11 "2022-09-12T15:05:21Z")

</div>

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?
