Detecting shock waves in cosmological smoothed particle hydrodynamics simulations