Fluid Simulation and other OpenCL stuff


over the last couple of weeks I’ve been working on a collection of tools and algorithms with OpenCL, and the work will continue for quite some time.
Here is the library: https://github.com/shamanDevel/jME3-OpenCL-Library


  • BLAS level 1 for float,double,int,long (DONE)
  • extensions to BLAS: mapping, indexing, reordering (DONE)
  • sorting (DONE, see also Sorting algorithms with OpenCL )
  • simple particle system: seeding and advection controlled by kernels, automatic resizing (DONE)
  • sparse linear equation solver in 2D and 3D (TODO, Jacobi works, Multigrid is planned)
  • 2D fluid simulation (work in progress)
  • 3D fluid simulation (work in progress)
  • SPH (Maybe)
  • Voxel raytracer (Maybe, a simple raytracer is needed to render the 3D fluids)

What will come afterwards: I will see :wink:


And here I start with a showcase of the current state of the 2D fluid simulation:

Already implemented is simple buoyancy, first order semi-lagrange advection, and first order pressure projection.
The pressure projection steps seems to be still buggy and the solver (Jacobi) is too slow.
There is still a lot to do.


What is going on in the video? Is it a smoke simulation or something else? Just curious

Yes, it is a simple smoke simulation. The buoyancy moves the smoke upwards and the pressure projection forces it into this spiral shape.

is the base OpenCL functionality already integrated into the main jmonkey branch?

Yes, it is in the main branch on Github, but not in the 3.1 release.
(Therefore you have to manually add the latest jme version as local dependencies to compile and run the presented library)

Ahh, ok that makes sense. Thanks