A dynamic particle coalescing and splitting scheme for SPH