InteractiveComputerGraphics / SPlisHSPlasH

SPlisHSPlasH is an open-source library for the physically-based simulation of fluids.
https://splishsplash.physics-simulation.org/
MIT License
1.58k stars 287 forks source link

warmstart not improving the iteration count #80

Closed scarensac closed 3 years ago

scarensac commented 4 years ago

Hi,

So, I was comparing the computation times of the current version of the DFSPH implementation with a GPU implementation that I made based on the SplishSplash code from 2 years ago (just to see if the performances changed significantly for some reason). I noticed that for some reason the current implementation was slower when simulating a fluid at a rest state. Doing some more test I noticed that, in the current implementation, the warmstart had no impact on the number of iterations of the density solver (the same may be true for the divergence solver but as the number of iterations is usually smaller, it is harder to properly test).

Here are the results I'm getting with showing in order: timestep count // density iterations // divergence iterations

with warmstart: 596 69 1 597 66 1 598 67 1 599 66 1 600 68 1 601 66 1 602 66 1 603 67 1 604 67 1 605 67 1 606 68 1 607 69 1

no warmstart: 596 68 1 597 67 1 598 68 1 599 68 1 600 68 1 601 67 1 602 68 1 603 68 1 604 68 1 605 68 1 606 67 1 607 68 1

By looking at the result I obtain with the older impelmentation I'd be expecting the density iterations count to be between 10 and 20 with the warmstart activated.

Here is the configuration file I'm using to quickly obtain a fluid near a rest state so that 500 iterations are enougth to properly see the problem (renamed to .txt so that github accept it ...).

DamBreakModel2.txt

To switch between the warmstart and non warmstart version I'm simply commenting the two warmstart defines at the top of the TimeStepDFSPH.h file

Am I missing something to activate the warmstart?

Thanks for your time,

janbender commented 4 years ago

Hi,

Can you tell me which Git commit corresponds to the "older implementation". Then I will test it.

Jan

scarensac commented 4 years ago

Hi,

Thanks for your response.

So I have no idea which exact commit my code is based on, but here is a commit where the warmstart it actually reducing the number of iterations necessary:

34d7c7c0ba460f4630d57c3e22a745dad7a3ab3d

janbender commented 4 years ago

Yesterday I had a bit time to take a closer look on this problem. I improved the warmstart and now it's much better. For your example it requires 2.5x less iterations with the new warmstart. This night I also tested the warmstart with a larger scenario (8M particles) and it works fine. So please test the new version.

scarensac commented 3 years ago

Hi,

Sorry it took me a while to verify it. Indeed your solution, make the warmstart work properly.

I'll close the issue, simply in the case it interest you i'll note a problem the warmstart has for the DFSPH. The initial reason why I found the problem with the warmstart is that I noted that for a fluid at rest the warmstart leads to unstable iteration count for the density solver. Initialy with the scene I gave in this thread you would see a sudden increse to around 20 iterations followed by a slow decrease to 9 and then it would increase again. With the new version this problem is significantly larger, it oscilate between 45 and 6 (see below). Athough on average it is indeed fast.

simulation_step density_iter divergence_iter 598 28 1 599 25 1 600 26 1 601 43 1 602 19 1 603 18 1 604 17 1 605 11 1 606 8 1 607 6 1 608 6 1 609 32 1 610 46 1 611 43 1 612 20 1 613 13 1 614 10 1 615 8 1 616 8 1 617 7 1

The main problem with that behaviour is that it is not simply a a computation time problem, this behaviour is associated with a small compression and expension of the fluid. If there are solids interaction with the fluid it will cause a huge variation (by like 50%) in the force applied on the solid, though the resulting animation still looks normal. The problem can be reduced by increasing the minimum number of iteration of the divergence solver, but I don't know of an actual modification of the warmstart solving that problem. Btw, I supose that the warmstart is also the reason why simulating columns of fluid is unstable when not using the divergence free solver but I have not extensively tested it.