Recently, I am very interested in fluid simulation. For details, refer to the paper of Jos stam: Real-Time fluid dynamics for games, expand its 2D solver, and make a simple 3D fluid solver, simulate a simple fluid. Demo andSource codeHere.
Big talk
Real-time fluid simulation is a concern in the field of computational fluid dynamics (CFD). In order to use computer simulation, engineers can obtain information about a certain fluid under specific conditions, such: the momentum, heat, and mass of the fluid. Due to engineering accuracy, the calculation required is generally complex. Later, real-time Fluid Simulation became a hot issue in computer graphics (CG), but people wanted to simulate the external image of the fluid. The computation is not accurate, but the visual effect is emphasized. For example, simulate smoke, fire, clouds, and water to meet special movie effects or game effects.
Body
Of course, I am concerned with the fluid simulation in CG. The fluid effects that can be found in reality and that cannot be found are all simulated for me. It's so funny and confusing! Haha. I found some differences on the InternetAlgorithm, Found by different Daniel. There are probably the following types:
1. Solving nses)
2. Based on large-scale data sampling (Fast Fourier Transform (FFT ))
3. parameter modeling (linear wave combination)
4...
Among them, the results obtained by the nses method are more realistic. After all, the results are based on the physical model, but the disadvantage is that the calculation is large, and the results are sometimes unstable and sensitive to the time step. Real-time is hard. In this regard, Jos stam is a character. He introduced the semi-Laplace algorithm into the CG field to solve nses and achieve real-time fluid simulation. So he looked for his paper. A lot. I see an article about real-time fluid dynamics for games. Good guy, real time is not what you want. So, looked at, in fact its core is to use the Gauss-Seidel Relaxation Method to Solve the linear equations, fast convergence and stability. For details, see: http://www.dgp.toronto.edu/people/stam/reality/Research/pdf/GDC03.pdf.
Because the original article is for 2D, I tried to write a 3D file myself. It was purely curious, and I didn't make any optimizations, so the speed was average. The rendering part gets a random Alpha mixture, and it is estimated that it is better to use the Volume Rendering Method (Volume Rendering. The final rendering is on my old book (CPU 1.4 GHz). When the grid size is 16*16*16, the FPS is about 14, and the desktop (CPU 2.6 GHz) it is about 32. If you want better results, you need to increase the grid size. Of course, FPS will definitely decrease.
Demo
1. grid size = 16*16*16, diff = 0, VISC = 0 (scattering coefficient = 0, viscosity coefficient = 0)
2. grid size = 32*32*16, diff = 0.00001, VISC = 0.000001