PavelDoGreat / WebGL-Fluid-Simulation

Play with fluids in your browser (works even on mobile)
https://paveldogreat.github.io/WebGL-Fluid-Simulation/
MIT License
14.58k stars 1.67k forks source link

Test conjugate gradient for pressure solve #71

Open JamieJQuinn opened 2 years ago

JamieJQuinn commented 2 years ago

From what I can tell, the code looks like it's using Jacobi or Gauss-Seidel methods for solving the divergence <-> pressure Laplace equation. I presume Jacobi because that's what's in the GPU gems reference.

At any rate, I implemented a very similar algorithm in Python but replacing the Jacobi solver with a conjugate gradient solver and found the conjugate gradient method to converge to an error of something like 1e-6 in only about 3 iterations. This is compared to >100 iterations to achieve a similar error using the Jacobi method.

My expectation is that WebGL-FS could also benefit from using the conjugate gradient method and so I'm suggesting testing it keeping in mind the following caveats:

MiracleCK commented 2 years ago

您好,我已经收到你的信件!我会及时阅读并作出回应!