Save multiple time frames in VTU files

Dear All.
I have different FEM results (continuous and discontinuous) that I save together in a VTU file.
For each selected time instant I generate a new VTU file.

Is there a way in GetFEM to save multiple time frames in a single VTU file?

Thank you.
Lorenzo

I think this question is mostly about ParaView than GetFEM. Sure you can store several time step in a single VTU file, but you will have to name them differently:

mfout.export_to_vtu("output.vtu", mftheta, T1, "temperature_step1",
                                  mftheta, T2, "temperature_step2",
                                  mftheta, T3, "temperature_step3", ...)

but I do not see how this can work well with paraview. What kind of workflow are you aiming at?

AFAIK, the default ParaView workflow is very much based on the idea of one file per iteration.

Hello Kostas,

concerning Paraview, I just found out at the following link

that in Paraview I can generate a file like the following:

{
  "file-series-version" : "1.0",
  "files" : [
    { "name" : "F1.0.vtu", "time" : 1 },
    { "name" : "F2.0.vtu", "time" : 2 },
    { "name" : "F3.0.vtu", "time" : 3 },
    { "name" : "F4.0.vtu", "time" : 4 },
  ]
}

that allows to put all the time steps together and open them in Paraview at once.

Originally, I was not thinking at Paraview but at PyVista instead.
In PyVista I just discovered that there’s the chance to make a single MultiBlock file .pvd with all the .vtk/.vtu time steps together

I was wondering what is the good practice with GetFem to do the same and if I need to use the above mentioned methods or maybe if there’s another better way to proceed.

Thank you,
Lorenzo

exactly, you can use the json format you have found, or you can use a pvd file
https://www.paraview.org/Wiki/ParaView/Data_formats#PVD_File_Format

E.g. at the end of your simulation you can create the pvd file like this:

      with open(f"{resultspath}/postproc.pvd", "w") as f:
         f.write('<?xml version="1.0"?>')
         f.write('<VTKFile type="Collection" version="0.1"')
         f.write('         byte_order="LittleEndian">')
         f.write('  <Collection>')
         for step in range(len(progress)):
            f.write(f'    <DataSet timestep="{stored_times[step]}" group="" part="0"')
            f.write(f'             file="simulation_results_{step}.vtu"/>')
         f.write('  </Collection>')
         f.write('</VTKFile>')

Regarding pyvista, be a bit careful with it. Last time I checked, its support for second order elements was not that great. In general when you visualize second order finite element results with ParaView you should always be using some larger value for Nonlinear Subdivision Level than the default of 1.