  In simulations of partial differential equations using particle-in-cell (PIC)
methods, it is often advantageous to resample the particle distribution
function to increase simulation accuracy, reduce compute cost, and/or avoid
numerical instabilities. We introduce an algorithm for particle resampling
called Moment Preserving Contrained Resampling (MPCR). The general algorithm
partitions the system space into smaller subsets and is designed to conserve
any number of particle and grid quantities with a high degree of accuracy (i.e.
machine accuracy). The resampling scheme can be integrated into any PIC code.
The advantages of MPCR, including performance, accuracy, and stability, are
presented by examining several numerical tests, including a use-case study in
gyrokinetic fusion plasma simulations. The tests demonstrate that while the
computational cost of MPCR is negligible compared to the nascent particle
evolution in PIC methods, periodic particle resampling yields a significant
improvement in the accuracy and stability of the results.
