Box2D Forums

It is currently Fri Sep 19, 2014 12:50 pm

All times are UTC - 8 hours [ DST ]




Post new topic Reply to topic  [ 11 posts ]  Go to page 1, 2  Next
Author Message
 Post subject: [WIP] Fluid for Box2D
PostPosted: Sun Feb 24, 2013 10:17 am 
Offline

Joined: Sun Mar 28, 2010 11:58 am
Posts: 16
Hello all!

As mentioned in my previous post, I have been working on getting fluids to work with Box2D, and have finally made enough progress to show you guys a working example!

I have attached a testbed with two preliminary tests: a standard dam break, and a buoyancy test that I have been experimenting with.

Some controls:
    You can click a particle to show some debug info.
    Check the 'AABBs' checkbox to see the fluids contact groups.
    Check the 'Contact Points' to render all the edges connecting the particles. You don't have zoom out very far, before it looks solid :)

The fluid in its current state is stable-ish. There are situations were the fact that it is 'only' running at 60hz is apparent, like during high-pressure situations. The lack of simulation precision causes it to temporary become unstable, but never so much that it explodes. I will look into this issue in the future, maybe using some kind of adaptive time-stepping.

- Kenneth G.


Attachments:
Testbed.zip [158.31 KiB]
Downloaded 275 times
Top
 Profile  
 
PostPosted: Sun Feb 24, 2013 4:39 pm 
Offline

Joined: Tue Jun 24, 2008 8:25 pm
Posts: 1943
Location: Tokyo
Unlike your earlier upload, this one is saying I need MSVCP110.dll and MSVCR110.dll. I found these on the net pretty quickly but there seems to be some incompatibility, at least with wine on linux :)
I wonder if you could build it in the same way as before - looking forward to trying it out!


Top
 Profile  
 
PostPosted: Mon Feb 25, 2013 12:16 am 
Offline

Joined: Sun Mar 28, 2010 11:58 am
Posts: 16
I recently upgraded to Visual Studio 2012, which is causing these issues for you. I re-downloaded and installed 2010, and here is a recompiled version.

Btw, I noticed that the 2010 version is several milliseconds slower than the 2012 version. Guess Microsoft put some more aggressive optimizations in the latest VS :)


Top
 Profile  
 
PostPosted: Mon Feb 25, 2013 4:45 am 
Offline

Joined: Tue Jun 24, 2008 8:25 pm
Posts: 1943
Location: Tokyo
Outstanding. Looks like your particles system was a good solid foundation to build this on :)


Top
 Profile  
 
PostPosted: Mon Feb 25, 2013 5:49 pm 
Offline

Joined: Mon Jun 15, 2009 4:34 pm
Posts: 69
I'm wondering if you are able to simulate a larger number of particles, and what kind of method are you using for collisions on particles vs. rigid bodies?


Top
 Profile  
 
PostPosted: Tue Feb 26, 2013 10:25 am 
Offline

Joined: Sun Mar 28, 2010 11:58 am
Posts: 16
genbox wrote:
I'm wondering if you are able to simulate a larger number of particles

I actually recently had a realization regarding my data-structures and how I was organising things, that I could change some things around, and speed it up considerably. I have attached the newest version of the testbed, with 4 different versions for the dambreak test (2K, 4K, 8K and 16K versions) that you can try out. I also managed to vastly stabilize the pressure calculations, so there is no more of the near-explosion fluctuations in high pressure areas, that I saw in earlier versions.

genbox wrote:
...what kind of method are you using for collisions on particles vs. rigid bodies?

It's almost the same code as the particle system, except I am testing against circles, and not particles.
The collision response is a slightly modified (optimized for particles) version of the collision response found in Box2Ds b2ContactSolver.cpp


Attachments:
Testbed_vs2012.zip [157.14 KiB]
Downloaded 196 times
Testbed_vs2010.zip [161.38 KiB]
Downloaded 176 times
Top
 Profile  
 
PostPosted: Tue Feb 26, 2013 12:53 pm 
Offline

Joined: Sun Mar 28, 2010 11:58 am
Posts: 16
irresistible force wrote:
Outstanding. Looks like your particles system was a good solid foundation to build this on :)

Thanks :)

Yeah, having the particle system done and ready to build on, makes it easier to stay focused on the fluid code, and getting that working and running fast.


Top
 Profile  
 
PostPosted: Mon Mar 04, 2013 2:47 pm 
Offline

Joined: Thu Aug 13, 2009 8:28 am
Posts: 14
Awesome!
This should pave the way for more interesting and dynamic physics!

I did notice the simulation gets unstable when I set the update step to 30Hz, has this to do with the fluid simulation itself?


Top
 Profile  
 
PostPosted: Wed Mar 13, 2013 7:44 am 
Offline

Joined: Sun Mar 28, 2010 11:58 am
Posts: 16
bitshit wrote:
I did notice the simulation gets unstable when I set the update step to 30Hz, has this to do with the fluid simulation itself?


Yes it does. All SPH fluid simulations are sensitive to the step size, and ideally it should run at a higher rate, but for now, 60hz seems to be adequate.


Top
 Profile  
 
PostPosted: Tue Sep 24, 2013 8:21 pm 
Offline

Joined: Tue Sep 24, 2013 8:18 pm
Posts: 2
Hi Kenneth,

Do you have any plan to release your code?


Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 11 posts ]  Go to page 1, 2  Next

All times are UTC - 8 hours [ DST ]


Who is online

Users browsing this forum: No registered users and 5 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Powered by phpBB® Forum Software © phpBB Group