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

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

Look at line 47 of FreeFem-tutorial - Section 5 - example3.edp. You’ll need to load "hpddm" or load "PETSc" and not load "iovtk" for this to work.

Dear Professor,

Thank you so much for your help.

Best,
Liu

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

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

Dear Professor,

Many thanks for your help.

Best,
Liu