Knowing the grain size distribution is of critical importance during star formation. It affects the opacities, the non-ideal magnetohydrodynamics (MHD) resistivities, and by extension the angular momentum, the chemical evolution of the gas and planet formation. The size distribution evolves due to the coagulation of grains, a process that is costly to compute on-the-fly in hydrodynamical simulations. We have developed an analytical method for tracking the state of coagulation of any grain size distribution. The method is mathematically exact, works for most coagulation kernels and can be implemented in hydrodynamical simulations at a negligible cost. We have also created a second method to calculate rapidly the charge distribution of grains, number of electrons and number of ions in the gas, so as to compute non-ideal MHD resitivities self-consistently in conjunction with the first method. I will describe both methods, their limits, benefits and application domains.