  Context: Radiation-MHD simulations have become a standard tool to investigate
the physics of solar and stellar atmospheres. Aims: The aim of this paper to
present a method that allows efficient and accurate analysis of flows in such
simulations in the Lagrangian frame. Methods: This paper presents a method that
allows the construction of pathlines given a seed point that can be chosen
freely at any location and at any time during the simulation where the
simulation state is stored. The method is based on passive tracer particles.
Through injection of particles in expanding regions the occurrence of
particle-free volumes is avoided, even in the case of strongly compressive
flows. Results:The method was implemented in the solar and stellar atmosphere
simulation code Bifrost. It is efficient and accurate. As examples I present an
analysis of a gas parcel in the convection zone and a particle in the solar
transition region.}
