Save time step solution progress to continue next run

Hi,

Just wondering if anyone has tried saving their time-step progress to continue in a different run. I found that I could export solution data with “ffmatlib” and “iovtk”. However, “ffmatlib” doesn’t have the function to import the data back. “iovtk” has the function “vtkload”, but I am only able to import the mesh details. The FreeFem++ documentation for “vtkload” function only shows “to-do”, so I don’t know how much this function could do.

Robin

Dear @robin997,

You can define your own function.

func int savesnaps(real[int] & u, int cnt) {
  ofstream file("results/snapshot." + cnt + ".txt", append);
  file.precision(16);
  for(int cnt = 0; cnt < u.n; cnt++){
    file << u[cnt] << endl;
  }
  return 0;
}

where you call it like savesnaps(u[], tid), with u being a fespace function, and hence, u[] is the associated vector and tid is a unique time id. To reload the data

real[int] data(V.ndof);
ifstream file("results/snapshot.123.txt/"); // for snapshot at 123 time step
for (int cnt = 0; cnt < V.ndof; cnt++) {
  file >> data[cnt];
}
V ulast; ulast[] = data;

with u[].n==V.ndof and the same mesh.

Regards,
/Fotios Kasolis

1 Like

@fotios.kasolis Thank you so much, it works great!

1 Like