  Despite their ubiquity, the origin of cosmic magnetic fields remains unknown.
Various mechanisms have been proposed for their existence including primordial
fields generated by inflation, or amplification and injection by compact
astrophysical objects. Separating the potential impact of each magnetogenesis
scenario on the magnitude and orientation of the magnetic field and their
impact on gas dynamics may give insight into the physics that magnetised our
Universe. In this work, we demonstrate that because the induction equation and
solenoidal constraint are linear with $B$, the contribution from different
sources of magnetic field can be separated in cosmological magnetohydrodynamics
simulations and their evolution and influence on the gas dynamics can be
tracked. Exploiting this property, we develop a magnetic field tracer algorithm
for cosmological simulations that can track the origin and evolution of
different components of the magnetic field. We present a suite of cosmological
magnetohydrodynamical RAMSES simulations that employ this algorithm where the
primordial field strength is varied to determine the contributions of the
primordial and supernovae-injected magnetic fields to the total magnetic energy
as a function of time and spatial location. We find that, for our specific
model, the supernova-injected fields rarely penetrate far from haloes, despite
often dominating the total magnetic energy in the simulations. The magnetic
energy density from the supernova-injected field scales with density with a
power-law slope steeper than 4/3 and often dominates the total magnetic energy
inside of haloes. However, the star formation rates in our simulations are not
affected by the presence of magnetic fields, for the ranges of primordial field
strengths examined. These simulations represent a first demonstration of the
magnetic field tracer algorithm (abridged).
