Particle refining and coarsening method for smoothed particle hydrodynamics simulations