The direct numerical simulation (DNS) method has been used to the study of the linear and shock wave propagation in bubbly fluids and the estimation of the efficiency of the cavitation mitigation in the container of the Spallation Neutron Source liquid mercury target. The DNS method for bubbly flows is based on the front tracking technique developed for free surface flows. Our front tracking hydrodynamic simulation code FronTier is capable of tracking and resolving topological changes of a large number of interfaces in two- and three-dimensional spaces. Both the bubbles and the fluid are compressible. In the application to the cavitation mitigation by bubble injection in the SNS, the collapse pressure of cavitation bubbles was calculated by solving the Keller equation with the liquid pressure obtained from the DNS of the bubbly flows. Simulations of the propagation of linear and shock waves in bubbly fluids have been performed, and a good agreement with theoretical predictions and experiments has been achieved. The validated DNS method for bubbly flows has been applied to the cavitation mitigation estimation in the SNS. The pressure wave propagation in the pure and the bubbly mercury has been simulated, and the collapse pressure of cavitation bubbles has been calculated. The efficiency of the cavitation mitigation by bubble injection has been estimated. The DNS method for bubbly flows has been validated through comparison of simulations with theory and experiments. The use of layers of nondissolvable gas bubbles as a pressure mitigation technique to reduce the cavitation erosion has been confirmed.