My goal is to remove a particle from the domain once it has reached a certain position and a certain velocity, and store the position of the particle when it is removed. I have written a UDF that prints the positions/velocities of all the particles in my domain, but I need to refine this to only remove particles which meet certain criteria. I was previously trying this with DPM_SCALAR_UPDATE but couldn't find a way to save the positions of the particles it was removing. Does anyone have any suggestions? My UDF (which I compile) is below.