SAP or Dynamic tree when simulating LOTS of spheres?

schteppe
Posts: 4
Joined: Thu Jan 13, 2011 9:26 am

SAP or Dynamic tree when simulating LOTS of spheres?

Post by schteppe »

Hi everyone.

Earlier today I tried to run a simulation with lots of particles. They are at start lined up in a cubic structure with little or no space in between. They are supposed to fall down into a container made out of static boxes and I'm going to analyse the force network in the system.

The thing is that I got some strange results when starting a simulation with 10.000 particles. Using the SAP collision detection algorithm (btAxisSweep3), it runs somewhat slow (as predicted) and uses about a gigabyte of memory in total for the app. Using Dynamic Tree algorithm instead (btDbvtBroadphase) makes my memory (4Gb in total) run out.

I heard the Dynamic Tree should be a lot better in most situations. From the wiki: "It handles dynamic worlds where many objects are in motion, and object addition and removal is faster than SAP". Do you have to pay for that performance with memory?

I would be glad if someone gave me some light here, as well as hints for my relatively large simulation.

Stefan
User avatar
Erwin Coumans
Site Admin
Posts: 4221
Joined: Sun Jun 26, 2005 6:43 pm
Location: California, USA

Re: SAP or Dynamic tree when simulating LOTS of spheres?

Post by Erwin Coumans »

If you have an extreme amount of sphere you likely need a custom broadphase.

Currently, the btDbvtBroadphase isn't memory optimized, while the SAP is compressed (quantized), hence the difference. It would be possible to optimize the btDbvtBroadphase, but you might be better off using a uniform grid (either on CPU or on GPU). See Bullet/Demos/ParticlesOpenCL.
Thanks,
Erwin
Johan Gidlund
Posts: 26
Joined: Mon Jun 01, 2009 2:21 pm
Location: Sweden

Re: SAP or Dynamic tree when simulating LOTS of spheres?

Post by Johan Gidlund »

I have not tested this with Bullet but in my SPH fluid simulation I use more than 10k particles with SPH and it runs quite fast. Unless I misunderstand your problem you should also have a situation where the relative position between particles don't change frequently so SAP should be very well suited for the problem.