An adaptive grid algorithm for computational shock hydrodynamics