We use numerical simulations of transonic flow through a crack to study the dynamics of the formation of shock waves downstream from a nozzle-like constriction inside the crack. The model solves the full set of Navier-Stokes equations in two dimensions via an explicit multifield finite difference representation. The crack walls are assumed to be perfectly rigid, and elastic coupling to the solid is not considered. The simulations demonstrate how the behavior of unsteady shock waves near the walls can produce recurring step-like pressure transients in the flow, which in turn induce resonance of the fluid-filled crack. The motion of the shock waves is governed primarily by smooth, low-amplitude pressure fluctuations at the outlet of the crack. The force induced on the walls scales with the amplitude of the shock, which is a function of the magnitude of the inlet pressure, aperture of the constriction, and thickness of the boundary layer. The applied force also scales in proportion to the spatial extent of the shock excursion, which depends on the fluctuation rate of outlet pressure. Using the source parameters of long-period (LP) events at Redoubt Volcano, Alaska, as a guide for our simulations, we infer that coupling of the shock to the walls occurs for crack inlet to outlet pressure ratios pipo > 2.31 and that the position of the shock front becomes most sensitive to outlet pressure fluctuations for flow regimes with pipo > 2.48. For such regimes, fluctuations of outlet pressure of up to ??0.5 MPa at rates up to 3 MPa/s are sufficient to induce pressure transients with magnitudes up to 12.5 MPa over 0.1-2.5 m of the walls within ???0.5 s. These flow parameters may be adequate for triggering the LP events in the precursory swarm to the December 14, 1989, eruption of Redoubt. According to the flow model the recurrence rate and amplitudes of LP events are inferred to be a manifestation of the response of a shallow hydrothermal reservoir to the sustained injection of superheated steam from a magma column roofing below this reservoir.