Uploaded March 2024 | Updated September 2026, 1 week ago
#FluidX3D has been a visualization powerhouse from the beginning, and with update v2.14 it got even better: Now velocity, density and temperature fields can be visualized in field, slice, streamline, and Q-criterion isosurface modes, in real time while the #CFD simulation is running. All of this #OpenCL rendering works on multi-#GPU systems too, with any combination of #Nvidia/#AMD/#Intel GPUs.
Full release notes: github.com/ProjectPhysX/FluidX3D/releases/tag/v2.14
The video is some screen recordings to showcase the update, all real-time simulations on #IntelArc A750:
0:00 Delta Wing
0:58 Cow Aerodynamics
1:43 2D Karman Vortex Street
1:49 Turbulence around Sphere at Re=1M
2:02 Raytraced Water Sloshing
2:38 Cessna 172
3:02 3D Rayleigh-Benard Convection
4:32 Outro
To give you some insight in development: This update was ~650 lines of code, ~5% of the FluidX3D code base. Implementation is the easiest and quickest part; I spend most time on testing and validation, because I do not tolerate bugs in my software. Just as I had checked that all new rendering kernels were working on my Arc A750, I tested again on a GTX 960M and realized it wasn't working there - because of another bug in Nvidia's drivers (vector types like int3 as OpenCL kernel parameters are broken). This was the 7th bug I have discovered in Nvidia's OpenCL drivers so far (and reported to them). A workaround later all was good on the Nvidia GPU too, and I could finally publish the update. Maintaining compatibility across all hardware takes large effort, but it's worth it, as it gives users the freedom to choose any hardware without #CUDA/HIP vendor lock-in.
#FluidX3D has been a visualization powerhouse from the beginning, and with update v2.14 it got even better: Now velocity, density and temperature fields can be visualized in field, slice, streamline, and Q-criterion isosurface modes, in real time while the #CFD simulation is running. All of this #OpenCL rendering works on multi-#GPU systems too, with any combination of #Nvidia/#AMD/#Intel GPUs.
Full release notes: github.com/ProjectPhysX/FluidX3D/releases/tag/v2.14
The video is some screen recordings to showcase the update, all real-time simulations on #IntelArc A750:
0:00 Delta Wing
0:58 Cow Aerodynamics
1:43 2D Karman Vortex Street
1:49 Turbulence around Sphere at Re=1M
2:02 Raytraced Water Sloshing
2:38 Cessna 172
3:02 3D Rayleigh-Benard Convection
4:32 Outro
To give you some insight in development: This update was ~650 lines of code, ~5% of the FluidX3D code base. Implementation is the easiest and quickest part; I spend most time on testing and validation, because I do not tolerate bugs in my software. Just as I had checked that all new rendering kernels were working on my Arc A750, I tested again on a GTX 960M and realized it wasn't working there - because of another bug in Nvidia's drivers (vector types like int3 as OpenCL kernel parameters are broken). This was the 7th bug I have discovered in Nvidia's OpenCL drivers so far (and reported to them). A workaround later all was good on the Nvidia GPU too, and I could finally publish the update. Maintaining compatibility across all hardware takes large effort, but it's worth it, as it gives users the freedom to choose any hardware without #CUDA/HIP vendor lock-in.
![Combined scientific CFD simulation and interactive raytracing with OpenCL (IWOCL & SYCLcon 2022)
This is my IWOCL & SYCLcon 2022 technical talk.
Extended Abstract: https://www.researchgate.net/publication/360501260_Combined_scientific_CFD_simulation_and_interactive_raytracing_with_OpenCL
Slides: https://www.iwocl.org/wp-content/uploads/06-presentation-iwocl-syclcon-2022-lehmann.pdf
0:00 Intro & Demos
4:16 Basic Idea
6:54 Lattice Boltzmann CFD
8:35 Benchmarks & Efficiency
11:33 Application
12:37 Graphics with OpenCL
23:06 Conclusions
24:16 More Demos!!
26:09 Outro
One of the main uses for OpenCL is compute applications where rendering is done externally. However separating simulation and rendering has many disadvantages, especially the slowdown caused by copying data from device to host, and needing to store raw data on the hard drive.
A much faster approach is to implement both simulation and rendering in OpenCL. The rendering kernels have direct read-only access to the raw simulation data in ultra-fast GPU memory. This eliminates almost all PCIe data transfer, allowing for interactive visualization in real time while the simulation is running.
Although OpenCL does not have existing functionality for graphical rendering, being a general compute language, it allows for implementing an entire graphics engine. On top, specific low-level optimizations make this OpenCL graphics engine outperform any existing rendering solution for this scenario, enabling fluid raytracing in real time on even non-RTX GPUs.
This is demonstrated with the software FluidX3D [1].
First I introduce the lattice Boltzmann method for simulating physically accurate fluid flow and discuss optimizations: Being a memory-bound algorithm, coalesced memory access is key. This is achieved through AoS data layout and the one-step-pull LBM streaming scheme. One-step-pull leverages that misaligned read penalty is much smaller than misaligned write penalty on most GPUs. Roofline analysis shows that with these optimizations, the LBM runs at 100% efficiency on the fastest GPUs [2].
For free surface flows, the LBM is extended with an efficient Volume-of-Fluid (VoF) implementation [3]. This allows covering new grounds in science: FluidX3D has been used to simulate more than 1600 raindrop impacts to evaluate how microplastics transition from the ocean surface into the atmosphere [4].
Rasterization on the GPU is parallelized not over pixels but lines/triangles instead. Each line/triangle is transformed from 3D to 2D screen coordinates and then rasterized onto the frame (integer array) with Bresenham [5] and z-buffer.
The raytracing graphics are based on a combination of fast ray-grid traversal and marching-cubes, leveraging that the computational grid from the LBM already is an ideal acceleration structure for raytracing. The idea is simple: Through each pixel on screen, shoot a reverse light ray out of the camera and see where it intersects with a surface in the scene. Then (recursively) calculate reflected/refracted rays and mix colors. If a ray doesnt intersect anything, its color is determined by the skybox.
With mesh surfaces consisting of triangles, computation time quickly becomes a problem, as all triangles have to be tested for intersection. To overcome this, an acceleration structure is required. While games often use a bounding volume hierarchy, the LBM already provides an ideal alternative acceleration structure: the simulation grid. The corresponding algorithm is called ray-grid traversal: When a ray shoots through the 3D grid, intersections with the surface only have to be checked for at each traversed grid cell rather than the entire grid. Triangles are generated on-the-fly with marching-cubes and ray-triangle intersections are checked with Möller-Trumbore. If an intersection has been found, the normals are calculated on the 8 grid points spanning the cell, and are trilinearly interpolated to the intersection. The interpolated surface normal makes the raytraced surface appear smooth.
On the GPU, the ray(s) for each pixel are computed in parallel. It is important how to align the OpenCL workgroups: best performance is achieved for 8x8 pixel tiles; this is about 50% faster than 64x1 tiles, because all rays of the workgroup are more likely to traverse the same grid cells, improving memory broadcasting. For marching-cubes, the algorithm by Paul Bourke [6] is implemented in OpenCL. Table size is reduced to 1/8. The Möller-Trumbore algorithm [7] is implemented branchless.
This raytracing implementation is fast enough to run in real time for even the largest lattice dimensions that fit into GPU memory. This is demonstrated on the most realistic simulation of an impacting raindrop ever done [8].
[1] https://doi.org/10.15495/EPub_UBT_00005400
[2] https://arxiv.org/abs/2112.08926
[3] https://doi.org/10.3390/computation10020021
[4] https://doi.org/10.1186/s43591-021-00018-8
[5] https://doi.org/10.1147/sj.41.0025
[6] http://paulbourke.net/geometry/polygonise/
[7] https://doi.org/10.1080/10867651.1997.10487468
[8] https://youtu.be/1g_zFsvScME Combined scientific CFD simulation and interactive raytracing with OpenCL (IWOCL & SYCLcon 2022)](https://i.ytimg.com/vi/pD8JWAZ2f8o/mqdefault.jpg)


![PhysX3D [GRAVITY SIMULATION] Extreme Performance
Durch ein bisschen Mikrooptimisierung und Verbesserung des Multithreading-Modus konnte ich nochmal den Faktor 2,3 an Rechenleistung rausholen.
Zu sehen ist das JPL-Sonnensystem mit den 178 größten Körpern, der Sonne, Planeten, Zwergplaneten, Asteroiden und Kometen. Ausgeschlossen sind Monde.
PhysX3D berechnet pro Sekunde ein Jahrzehnt. Die CPU-Auslastung links unten ist die reine Auslastung durch PhysX3D, sie ist nicht ganz 100%, weil das Videoaufnahmetool (Game-DVR) selbst Rechenleistung frisst.
Mehr Informationen auf: http://www.projectphysx.de
Musik: Chris Zabriskie - Cylinder Five PhysX3D [GRAVITY SIMULATION] Extreme Performance](https://i.ytimg.com/vi/sAMPQV5_p6I/mqdefault.jpg)






