Compressed air energy storage (CAES) in underground spaces is a common method for addressing the instability of renewable energy generation. As the construction and testing of CAES systems are often of high cost, the numerical simulation which offers a more efficient and low-cost research method can provide a better alternative to research the process. In this study, a numerical simulation model has been developed to describe the air movement within the CAES process. Specifically, the study focuses on two different types of motion: air compressible flow within the cavern and air porous flow in the surrounding rock. Using OpenFOAM, a multi-region coupling solver has been developed to address the different governing equations for these two types of motion, and couples pressure, velocity, and temperature at the boundaries. The developed solver is used to simulate a field test of a CAES system. The numerical simulation results closely match the experimental data, verifying the reliability of the solver. Moreover, the solver can achieve multi-region flow simulations that are previously unattainable, resulting in more accurate simulations. Simulations have also been conducted to analyze various working conditions, including different rock permeability, porosity, and air injection mass rates. The results show that different conditions significantly affect air pressure, leakage rate, temperature, and flow field changes within the cavern. These simulation results and the underlying mechanisms have been analyzed to provide reference and technical support for site selection, construction, and operational strategies of CAES systems in underground spaces.