Fluid volume simulation

Voxilla

Regular
EDIT: New improved version 1.3 available

Here another volume simulator, this time simulating an incompressible fluid solving the Navier- Stokes differential equations. The simulation runs in a 200x200x200 voxel box

The calculations make use of a well known scheme of velocity advection, Jaccobi pressure solving and making the velocity divergence free by subtracting the gradient of the pressure.

This is the so called Semi-Lagrangian scheme. A more accurate solver makes use of the second order MacCormack technique. The simulation makes use of the latter. However it makes the simulation unstable and introduces artifacts. Limiting generated extremes can fix this, unfortunately I was not able to get this working, so the simulation runs without limiters, still the result is some visual interesting turbulent behavior.

The amplitude of the speed vectors are visualized. To make a 3d rendering, a simple ray maximum projection is used. This shoots rays through the volume searching the maximum speed along the ray. With a linear interpolation the speed is given some color.


Controls:
- mouse left drags a source on a plane through the center of the volume and parallel to the screen
- mouse right to rotate the volume
- mouse wheel to zoom in and out
- space bar to toggle between MacCormack and Semi-Lagrangian simulation
 
Last edited by a moderator:
Fellix, are you using the 9.12 hotfix drivers? I can't get my 5850 to run the application and I have all the latest drivers. I went to rerun all of Voxillas demos and QJulia4D is the only one that now works, the others crash immediately!!!
 
I'm with the 9.12 hotfix and all the demos out there (DC/OCL) are trouble-free for me. ;)

Could it be from the OS? Mine is Win7 x86 w/ all the pre-SP1 patches and hotfixes (~130 in count).
 
It's possible to make this quite a bit faster still. The Jacobi iterations are especially expensive. Now 20 of them are done, meaning 20 times reading and writing the whole volume per frame.

With vector maths, it could be made twice faster.
As the simulation is mostly limited by memory bandwidth, the Jacobi iterations seem like a nice candidate for shared memory. However due to the nature of the iterations I'm not sure this is possible.
 
I'm really new to OpenCL and Direct Compute, would it be possible to implement this effect targeting D3D_FEATURE_LEVEL_10_1?

I'm asking because I only have a Radeon 4850 gpu.

Thank you.
 
WOW, this looks great especially on the Semi-Lagrangian mode. The other mode has some strange artifacts along grid boundaries. Small marks aligned orthogonally?! It would be awesome to set this up as a screensaver with some random input. Great work Voxilla, you never cease to amaze!!!

P.S. Anyone running Windows 7 64bit RC will need 9.11 drivers. 9.12 drivers have severe problems with DX11 on the Release Candidate.
 
The semi Lagrangian looks ok, but it is a bit too smooth as velocity gets dissipated quickly. That's where the second order MacCormack should make things better by adding more detail and less dissipation.
The artifacts you see are the result of using no limiters, there is one in the code but I could not get it working. If there is some computational fluids specialist around there, it would be great to get some hints.
I've got it running 40% faster now, also fluid bounces correctly of the walls, but I want correct MacCormack first before releasing something new.
 
I'm really new to OpenCL and Direct Compute, would it be possible to implement this effect targeting D3D_FEATURE_LEVEL_10_1?

It would be more difficult to process volumes (3d textures) as CS 4 compute shaders can only be dispatched over 2d domains. Working around this and other limitations might be possible.
 
So I assume that if it was OpenCL, it would have the same restrictions, needing a fairly recent GPU (DX11 class) right?
 
I did some tests with OpenCL, but even with a DX11 GPU there are currently limitations like not being able to sample textures, at least with ATI. This is something that will get fixed in drivers later on.
DX10 GPUs would have similar limitations as CS4 using OpenCL, it's not something that can be solved in software, the DX10 hardware simply lacks features.
 
I did some tests with OpenCL, but even with a DX11 GPU there are currently limitations like not being able to sample textures, at least with ATI. This is something that will get fixed in drivers later on.
That would be the case of missing support for OpenGL interops, am I correct?
 
btw, do you have pointers to articles I should read to understand what's going on? (maybe something you read before implementing the effect)

thx
g.
 
I've added a new version 1.2 the artifacts are gone and speed is up by about 40%.

This new version has a more smoky aspect and smoke bounces off the wall.
Instead of visualizing the velocity an advected fire reaction coordinate is rendered.
 
FYI - I would love to run this on my Windows 7 64 bit, but cant seem to find enough .dll files to make it happy. ;)
fluid.jpg
 
Back
Top