In this paper, an adaptive mesh refinement technique is presented for simulation of compressible flows, which can effectively refine the mesh in the regions with shock waves and vortices. The present approach uses the total energy per unit volume as an indicator to capture the shock waves and vortical structures. In the approach, an h-refinement strategy is adopted. To save the computational effort, the flow variables on the new mesh are obtained from the previous step by interpolation, which ensures that the problem is always solved on the refined mesh. Both inviscid and viscous compressible flows are considered in this work. Their governing equations are, respectively, Euler equations and Navier–Stokes equations associated with the implementation of the Spalart–Allmaras turbulence model. The cell-centered finite volume method and Jameson scheme are chosen to carry out spatial discretization, and the five-stage Runge–Kutta scheme is applied to discretize the temporal derivative. The present approach is applied to simulate three test problems for its validation. Numerical results show that it can effectively capture the shock waves and vortices with improvement in solution accuracy.