A procedure to locally refine and un-refine an unstructured computational grid of four-node quadrilaterals (in 2D) or of eight-node hexahedra (in 3D) is presented. The chosen refinement strategy generates only elements of the same type as their parents, but also produces so-called hanging nodes along non-conforming element-to-element interfaces. Continuity of the solution across such interfaces is enforced strongly by Lagrange multipliers. The element split and un-split algorithm is entirely integer-based. It relies only upon element connectivity and makes no use of nodal coordinates or other real-number quantities. The chosen data structure and the continuous tracking of the nature of each node facilitate the treatment of natural and essential boundary conditions in adaptivity. A generalization of the concept of neighbor elements allows transport calculations in adaptive fluid calculations. The proposed procedure is tested in structure and fluid wave propagation problems in explicit transient dynamics.