Color TemporalParticlesToPathlines by velocity as in StreamTracer

Hello, when using TemporalParticlesToPathlines, is there a way to color the pathlines by velocity, as is an option for the StreamTracer filter?

The paths are pre-computed by the solver, so only their positions are read by paraview. The local velocity field is available if interpolating it is an option. It also would be easy to compute the local velocity with finite differences, but then I would need to somehow assign that velocity to the pathline.

Thank you,

Hi all,

This can be accomplished with python vtk by adding the velocity field to particle data using a snippet like the following. After reading the files that contain positions to data1 and data2, call

coords1 = data1.GetPoints().GetData()
coords2 = data2.GetPoints().GetData()

to load their coordinates, then

velocity = numpy_support.numpy_to_vtk((1.0/dt) * (np.array(coords2)-np.array(coords1)), deep=True, array_type=vtk.VTK_DOUBLE)

to add a field “velocity” to the data. Here this is a simple first order finite difference for the time derivative, but more sophisticated options could also be used. Then write a new vtu with data2, and upon reading in Paraview, the magnitude of velocity can be used to color the pathlines. Note that “numpy_support” is loaded from with “from vtk.util import numpy_support”.