XDMF- Saving a timeseries of points and corresponding values

Dear all,

Using the library LEoPart I am currently trying to compute “strain-history” for particles inside a velocity field.
At t=0, I release 100 particles. Every timestep, these particles are advected inside the velocity field.
As output, I get a new coordinate and a new value of the strain for every particle (100 coordinates, 100 values for every timestep).

For post-processing, I would like to write the particle locations and the corresponding scalar values to XDMF.

In the link below I found that if I have a point cloud, I can use the XDMFFILE “write”-function as follows:
write(points, values)
However, it does not allow me to write the points and corresponding values for all timesteps into one single XMDF file.
Is there a convenient way that one can write a Timeseries of point clouds (with scalar values) to one single XDMF file?

With kind regards,
https://fenicsproject.org/olddocs/dolfin/2016.1.0/python/programmers-reference/cpp/io/XDMFFile.html

1 Like

Sadly there’s no support for time series of point clouds in old dolfin. I get around this by writing point clouds to a folder. The files are indexed by output number, or by time, in some chronological fashion. This information is encoded in the filenames. Paraview then interprets these filenames and constructs a file series for you. Other than the “mess” this creates in a folder, I find it doesn’t limit what I want to do with Paraview.

For a pseudocode example see

points_list = list(dolfin.Point(*p) for p in ptcls.positions())
particles_values = ptcls.get_property(property_idx)
dolfin.XDMFFile(
    os.path.join(particles_directory, f"step{idx:>04d}.xdmf")) \
        .write(points_list, particles_values)

where you’d change 04d to be some value realistic for the number of files you’re outputting.

See also: here and here.

1 Like

Unfortunately, my folders already tend towards being “messy”.
Therefore, your workaround will provide an excellent solution to my problem and my folders won’t noticeably become messier.
I was not aware that Paraview can construct a file series for me in this fashion.

Thank you very much and have a great day.

1 Like

The solution works perfectly, resulting in very nice animations.
Important for anyone reading this who would like to use this method in paraview:

Paraview will collect the files with the timesteps in the filename. You can select the group and click “OK” to open.
Subsequently, you should select the “XDMFReader” or “XDMF3ReaderT”, to open the files as a file series.
image

image

1 Like