# Output the files of .vtk (Savevtk) with varying name in the loop

**URL:** <https://community.freefem.org/t/output-the-files-of-vtk-savevtk-with-varying-name-in-the-loop/1984>\
**Category:** General Discussion\
**Created:** [September 3, 2022, 2:03am UTC](https://community.freefem.org/t/output-the-files-of-vtk-savevtk-with-varying-name-in-the-loop/1984 "2022-09-03T02:03:35Z")\
**Posts on this page:** 6\
**Page:** 1

<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 3, 2022, 2:03am UTC](https://community.freefem.org/t/output-the-files-of-vtk-savevtk-with-varying-name-in-the-loop/1984/1 "2022-09-03T02:03:35Z")

</div>

Hi everyone,

I don’t know how to name the \*. vtk file in a loop. Please help me.  
For example,  
"int t=0, dt=0.01;  
for(int i=0;i\<61;++i)  
{  
t=t+dt;  
Lame;  
if (i%20==0)  
savevtk(“u.vtk”, Th1, [u1,u2,u3], dataname=“u1,u2,u3”, order=Order);  
}  
The above statement can only output one file, i.e., u.vtk. How can I output three files with varying name in the loop, such as u20.vtk, u40.vtk, and u60.vtk?  
Actually, if the solutions as i=20, 40, and 60 could be saved in the only file of u.vtk in succession, this would be better than three files. However, how can I distinguish the solutions of different i or t values?

Sincerely yours,  
Liu

---

<div class="post-metadata">

**Author:** ![prj](https://avatars.discourse-cdn.com/v4/letter/p/ecae2f/32.png) [@prj](https://community.freefem.org/u/prj)\
**Post date:** [September 3, 2022, 4:40pm UTC](https://community.freefem.org/t/output-the-files-of-vtk-savevtk-with-varying-name-in-the-loop/1984/2 "2022-09-03T16:40:12Z")

</div>

Look at line 47 of [FreeFem-tutorial - Section 5 - example3.edp](http://joliv.et/FreeFem-tutorial/section_5/example3.edp.html). You’ll need to `load "hpddm"` or `load "PETSc"` and not `load "iovtk"` for this to work.

---

<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 4, 2022, 3:14am UTC](https://community.freefem.org/t/output-the-files-of-vtk-savevtk-with-varying-name-in-the-loop/1984/3 "2022-09-04T03:14:53Z")

</div>

Dear Professor,

Thank you so much for your help.

Best,  
Liu

---

<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 4, 2022, 12:47pm UTC](https://community.freefem.org/t/output-the-files-of-vtk-savevtk-with-varying-name-in-the-loop/1984/4 "2022-09-04T12:47:54Z")

</div>

Hello professor,

Please forgive my frequent questions.  
According to the code,  
“int t=0, dt=0.01;  
for(int i=0;i\<61;++i)  
{  
t=t+dt;  
Lame;  
}”,  
could FF++ output the solutions with varying time into a file such as .ex2, which could be played as an animation by Paraview?  
Thank you very much.

Give you my best wishes.  
Liu

---

<div class="post-metadata">

**Author:** ![prj](https://avatars.discourse-cdn.com/v4/letter/p/ecae2f/32.png) [@prj](https://community.freefem.org/u/prj)\
**Post date:** [September 4, 2022, 7:14pm UTC](https://community.freefem.org/t/output-the-files-of-vtk-savevtk-with-varying-name-in-the-loop/1984/5 "2022-09-04T19:14:16Z")

</div>

Yes, with `savevtk(..., append = true)`.

---

<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 5, 2022, 12:12am UTC](https://community.freefem.org/t/output-the-files-of-vtk-savevtk-with-varying-name-in-the-loop/1984/6 "2022-09-05T00:12:25Z")

</div>

Dear Professor,

Many thanks for your help.

Best,  
Liu
