Welcome, Guest. Please login or register.
Did you miss your activation email?

Login with username, password and session length

 
Advanced search

878562 Posts in 32927 Topics- by 24337 Members - Latest Member: kellerx25

May 22, 2013, 07:42:29 AM
TIGSource ForumsDeveloperTechnical (Moderators: Glaiel-Gamer, ThemsAllTook)Let's talk about Fluid Simulation
Pages: 1 [2]
Print
Author Topic: Let's talk about Fluid Simulation  (Read 3719 times)
raigan
Level 4
****


View Profile
« Reply #15 on: March 24, 2010, 11:30:51 AM »

would call me a lunatic for using timescales as big as 1/30th of a second,

Lunatic!! Smiley

Seriously though, I don't know that stability @ 30hz is a reasonable expectation -- AFAIK many rigid-body sims have timesteps around 60-100hz, and the systems they're trying to solve are typically sparser than a huge wad of interacting particles.

Do you know what the current bottleneck is in your sim?
Logged
LemonScented
Level 7
**



View Profile Email
« Reply #16 on: March 24, 2010, 03:32:58 PM »

I just double checked my fluid code (not looked at it in a while) and it turns out I was lying (well, mistaken). It's wired to use a dt of 1/60th of a second but since I can't guarantee 60FPS with higher numbers of particles I clamp the overall framerate to 30FPS (so, effectively, my fluid runs at half speed). There's evidently some timing and tuning stuff to be worked out there, but it looks good on my screen, for now.

It's difficult to say what the current bottleneck is with my sim, except for "all of it". I spent months running a profiler over and over again and tuning stuff, and there's no one part of the simulation that takes noticeably more than any other parts. The engine as a whole is pretty optimal, rendering the fluid is no particular problem, and managing the neighbours lists is pretty optimal, so the main issue is the stuff to calculate densities and to apply forces. It's multithreaded and as optimised as I can get it, but for large numbers of particles it still chews up a lot of CPU horsepower. Perhaps a bit more could be squeezed out by looking into memory cache misses, but it's not easy to profile that (at least with any free/cheap tools I know of) so I've applied every rule of thumb I know of and kept all of the ones that seemed to help (or at least not hurt).

I spent a while working on a version that used CUDA (NVidia's stuff for doing arbitrary maths and physics on a graphics card) which (despite being pretty suboptimal) runs at a much nicer framerate at the expense of making the code even harder to maintain. I'm hoping for widespread adoption and availability of OpenCL so I can get it to work on ATI cards too, but I'm concerned that only high-end cards will be able to run that, unless the manufacturers make OpenCL work on older cards as well.
Logged

raigan
Level 4
****


View Profile
« Reply #17 on: March 27, 2010, 12:02:01 PM »

I just came across the Moving Particle Semi-Implicit method.. I have no idea what it is really or how it works, because I can't seem to find the original paper, but it might be of interest since it's similar to SPH (so possibly some ideas may be of use): http://en.wikipedia.org/wiki/Moving_particle_semi-implicit_method
Logged
Pages: 1 [2]
Print
Jump to:  

Theme orange-lt created by panic