# Double use of diffusion() (Jos Stams paper .... again)

This topic is 2533 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

## Recommended Posts

Hi good people,

it's my first post and it's about Jos Stams' paper "Real Time Fluid Dynamics for Games".
As I have done my share of searching, i know that it has been discussed before, and I would actually like to continue a discussion that was started more than a year ago. The thread I am refering to is:

http://www.gamedev.n...m---gdc03-code/

The discussion was about eliminating the advection step and only use diffusion. If we just comment out the advective step, there is no diffusion even if there is no direct connection between the two. The discussion ended with the following comment from the OP:

## [font=helvetica, arial, verdana, tahoma, sans-serif][color=#282828]This turns out to work just fine. I do not however have any idea why it works, and would really appreciate any thoughts on the matter.[/font]Thanks!

##### Share on other sites
One thing I've noticed is that if we only have one diffusion() term, then because of the way SWAP() is used, x is always dens and so the linear solver only updates x.

Here I run through the logic:

In idle_func() we see that get_from_UI() gets dens_prev as argument. get_from_UI() fills up dens_prev according to where we click on the screen.

dens_step() then recieves dens and dens_prev. In dens_step(), add_source() updates dens according to the rule dens=dt*dens_prev.

Swap kicks in here to x=dens_prev and x0=dens. These values go into diffuse which updates x, i.e., dens_prev.

Another swap turns this into x=dens and x0=dens_prev.

If we now do not run diffuse() again, we are going to run into another swap which makes x=dens_prev and x0=dens. This is again going to be sent to diffuse() which will again update x=dens_prev. That is, it will never update x=dens, which consists of the values we draw.

That's at least where I am at today

1. 1
2. 2
3. 3
Rutin
15
4. 4
khawk
13
5. 5
frob
12

• 9
• 9
• 11
• 11
• 23
• ### Forum Statistics

• Total Topics
633663
• Total Posts
3013236
×