  We explore the impact of a magnetar giant flare (GF) on the neutron star (NS)
crust, and the associated baryon mass ejection. We consider that sudden
magnetic energy dissipation creates a thin high-pressure shell above a portion
of the NS surface, which drives a relativistic shockwave into the crust,
heating a fraction of these layers sufficiently to become unbound along
directions unconfined by the magnetic field. We explore this process using
spherically-symmetric relativistic hydrodynamical simulations. For an initial
shell pressure $P_{\rm GF}$ we find the total unbound ejecta mass roughly obeys
the relation $M_{\rm{ej}}\sim4-9\times10^{24}\:\rm{g}\:(P_{\rm
GF}/10^{30}\:\rm{ergs}\:\rm{cm}^{-3})^{1.43}$. For
$P_{\rm{GF}}\sim10^{30}-10^{31}\:\rm{ergs}\:\rm{cm}^{-3}$ corresponding to the
dissipation of a magnetic field of strength $\sim10^{15.5}-10^{16}\:\rm{G}$, we
find $M_{\rm{ej}}\sim10^{25}-10^{26}\:\rm{g}$ with asymptotic velocities
$v_{\rm{ej}}/c\sim0.3-0.6$ compatible with the ejecta properties inferred from
the afterglow of the December 2004 GF from SGR 1806-20. Because the flare
excavates crustal material to a depth characterized by an electron fraction
$Y_e\approx0.40-0.46$, and is ejected with high entropy and rapid expansion
timescale, the conditions are met for heavy element $r$-process nucleosynthesis
via the alpha-rich freeze-out mechanism. Given an energetic GF rate of roughly
once per century in the Milky Way, we find that magnetar GFs could be an
appreciable heavy $r$-process source that tracks star formation. We predict
that GFs are accompanied by short $\sim$minutes long, luminous
$\sim10^{39}\:\rm{ergs}\:\rm{s}^{-1}$ optical transients powered by $r$-process
decay ("nova brevis"), akin to scaled-down kilonovae. Our findings also have
implications for the synchrotron nebulae surrounding some repeating fast radio
burst sources.
