The document describes a CUDA-based implementation of the 3D stable fluids simulation method for modeling natural phenomena in real-time. It presents the Eulerian approach to space partitioning used in the simulation. Key aspects of the physics model are described, including solving the Navier-Stokes equations and implementing advection, diffusion, and movement. The workflow and grid partitioning for the CUDA implementation are discussed. Results show the CUDA implementation achieved faster processing times than CPU-based simulations, allowing grid sizes up to 1283 using an Nvidia 8800 GT card. Future work is proposed to optimize memory usage and reduce numerical dissipation.
Simplifying Microservices & Apps - The art of effortless development - Meetup...
ICCSA 2010 Conference Presentation
1. ubi-logo
Introduction Stable Fluids NVIDIA Compute Unified Device Architecture (CUDA) Results Conclusions
A CUDA-based Implementation of Stable
Fluids in 3D with Internal and Moving
Boundaries
G. Amador and A. Gomes
Departamento de Inform´atica
Universidade da Beira Interior
Covilh˜a, Portugal
m1420@ubi.pt, agomes@di.ubi.pt
March, 2010
3. ubi-logo
Introduction Stable Fluids NVIDIA Compute Unified Device Architecture (CUDA) Results Conclusions
Overview
The study of natural phenomena simulation is impor-
tant for two industries:
(real-time) (off-line)
Real-time simulations must be fast while appearing
realistic (≥ 30 frames per second).
4. ubi-logo
Introduction Stable Fluids NVIDIA Compute Unified Device Architecture (CUDA) Results Conclusions
Overview
The study of natural phenomena simulation is impor-
tant for two industries:
(real-time) (off-line)
Real-time simulations must be fast while appearing
realistic (≥ 30 frames per second).
Problem:
How to implement a CUDA-based version of the 3D
stable fluids method?
5. ubi-logo
Introduction Stable Fluids NVIDIA Compute Unified Device Architecture (CUDA) Results Conclusions
The Eulerian approach
The Eulerian approach
Space partitioning:
Variations of velocity and density are observed at the
center of each cell.
Velocities and densities are updated through an im-
plicit method (Stam stable fluids, 1999), i.e., uncondi-
tionally stable for any time step.
6. ubi-logo
Introduction Stable Fluids NVIDIA Compute Unified Device Architecture (CUDA) Results Conclusions
Physics Model
Navier-Stokes equations for incompressible fluids
Mass conservation: −→
u = 0
Velocity evolution:
∂
−→
u
∂t
= −
−→
u ·
−→
u + v 2−→
u +
−→
f
Density evolution:
∂ρ
∂t
= −
−→
u · ρ + k 2
ρ + S
−→
u : velocity field.
v: fluids viscosity.
ρ: density of the field.
k: density diffusion rate.
−→
f : external forces added to the velocity field.
S: external sources added to the density field.
=
∂
∂x
,
∂
∂y
,
∂
∂z
: gradient.
7. ubi-logo
Introduction Stable Fluids NVIDIA Compute Unified Device Architecture (CUDA) Results Conclusions
Physics Model
Navier-Stokes equations implementation
Update velocity:
Add external forces (
−→
f ).
Velocity Diffusion (v 2−→
u ).
Move (−
−→
u .
−→
u e
−→
u = 0).
Update density:
Add external sources (S).
Density advection (−
−→
u . ρ).
Density diffusion (k 2
ρ).
8. ubi-logo
Introduction Stable Fluids NVIDIA Compute Unified Device Architecture (CUDA) Results Conclusions
Physics Model
Add external forces
−→
u =
−→
u0 + ∆t ×
−→
f (velocity).
ρ = ρ0 + ∆t × S (density).
−→
f : external forces to the velocity field.
S: external density source (e.g., ink mixed with water).
−→
u : new velocity.
−→
u0: old velocity.
ρ: new density.
ρ0: old density.
∆t: simulation time step.
9. ubi-logo
Introduction Stable Fluids NVIDIA Compute Unified Device Architecture (CUDA) Results Conclusions
Physics Model
Advection or transport
Quantities transport (e.g., the fluid itself, densities,
moving objects, etc.) when the fluid flows.
Particle trajectory tracked back in time.
10. ubi-logo
Introduction Stable Fluids NVIDIA Compute Unified Device Architecture (CUDA) Results Conclusions
Physics Model
Diffusion
Exchanges of density
or velocity between
neighbours (2D).
Solve a sparse linear system (Ax = b), using an iter-
ative method (e.g., Gauss-Seidel red black).
11. ubi-logo
Introduction Stable Fluids NVIDIA Compute Unified Device Architecture (CUDA) Results Conclusions
Physics Model
Move
Ensure mass conservation and the fluid’s incom-
pressibility.
Hodge decomposition:
Conservative field = our field - gradient
Determine the gradient using diffusion’s iterative
method (i.e., Gauss-Seidel red black).
16. ubi-logo
Introduction Stable Fluids NVIDIA Compute Unified Device Architecture (CUDA) Results Conclusions
Conclusions
Conclusions
The CUDA-based implementation of 3D stable fluids
achieved better performance (i.e. faster in processing
time) than the CPU-based implementation.
The CUDA-based implementation of 3D stable fluids
allows grid sizes up to 1283, using an Nvidia GeForce
8800 GT card.
The CUDA-based implementation of 3D stable fluids
allows real-time simulations to grid sizes up to 323,
using an Nvidia GeForce 8800 GT card.
17. ubi-logo
Introduction Stable Fluids NVIDIA Compute Unified Device Architecture (CUDA) Results Conclusions
Future Work
Future Work
Search ways, implementable using CUDA, to reduce
stable fluids memory requirements (e.g., data struc-
tures, dynamic memory, etc.).
Reduce, numerical error related, dissipation in the
semi-Lagrangian advection, using MacCormack ad-
vection instead.
Implement and analyse the performance of an CPU-
based multi-core version of 3D stable fluids.