Pipe cooling systems are among the potentially effective measures to control the temperature of mass concrete. However, if not properly controlled, thermal cracking in concrete, especially near water pipes, might occur, as experienced in many mass concrete structures. In this paper, a new numerical approach to simulate thermal cracking based on particle flow code is used to shed more light onto the process of thermal crack propagation and the effect of thermal cracks on thermal fields. Key details of the simulation, including the procedure of obtaining thermal and mechanical properties of particles, are presented. Importantly, a heat flow boundary based on an analytical solution is proposed and used in particle flow code in two dimensions to simulate the effect of pipe cooling. The simulation results are in good agreement with the monitored temperature data and observations on cored specimens from a real concrete gravity dam, giving confidence to the appropriateness of the adopted simulation. The simulated results also clearly demonstrate why thermal cracks occur and how they propagate, as well as the influence of such cracks on thermal fields.