ICCSA 2010 Conference Presentation

19
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 [email protected], [email protected] March, 2010

Transcript of ICCSA 2010 Conference Presentation

Page 1: ICCSA 2010 Conference Presentation

ubi-logo

Introduction Stable Fluids NVIDIA Compute Unified Device Architecture (CUDA) Results Conclusions

A CUDA-based Implementation of StableFluids in 3D with Internal and Moving

Boundaries

G. Amador and A. Gomes

Departamento de InformaticaUniversidade da Beira Interior

Covilha, Portugal

[email protected], [email protected]

March, 2010

Page 2: ICCSA 2010 Conference Presentation

ubi-logo

Introduction Stable Fluids NVIDIA Compute Unified Device Architecture (CUDA) Results Conclusions

1 Introduction

2 Stable FluidsThe Eulerian approachPhysics Model

3 NVIDIA Compute Unified Device Architecture (CUDA)WorkflowGrid partition

4 ResultsResults - Processing time

5 ConclusionsConclusionsFuture WorkDemoQuestions

Page 3: ICCSA 2010 Conference Presentation

ubi-logo

Introduction Stable Fluids NVIDIA Compute Unified Device Architecture (CUDA) Results Conclusions

OverviewThe study of natural phenomena simulation is impor-tant for two industries:

(real-time) (off-line)Real-time simulations must be fast while appearingrealistic (≥ 30 frames per second).

Problem:How to implement a CUDA-based version of the 3Dstable fluids method?

Page 4: ICCSA 2010 Conference Presentation

ubi-logo

Introduction Stable Fluids NVIDIA Compute Unified Device Architecture (CUDA) Results Conclusions

OverviewThe study of natural phenomena simulation is impor-tant for two industries:

(real-time) (off-line)Real-time simulations must be fast while appearingrealistic (≥ 30 frames per second).Problem:How to implement a CUDA-based version of the 3Dstable fluids method?

Page 5: ICCSA 2010 Conference Presentation

ubi-logo

Introduction Stable Fluids NVIDIA Compute Unified Device Architecture (CUDA) Results Conclusions

The Eulerian approach

The Eulerian approachSpace partitioning:

Variations of velocity and density are observed at thecenter 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.

Page 6: ICCSA 2010 Conference Presentation

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.

Page 7: ICCSA 2010 Conference Presentation

ubi-logo

Introduction Stable Fluids NVIDIA Compute Unified Device Architecture (CUDA) Results Conclusions

Physics Model

Navier-Stokes equations implementationUpdate 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ρ).

Page 8: ICCSA 2010 Conference Presentation

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.

Page 9: ICCSA 2010 Conference Presentation

ubi-logo

Introduction Stable Fluids NVIDIA Compute Unified Device Architecture (CUDA) Results Conclusions

Physics Model

Advection or transportQuantities transport (e.g., the fluid itself, densities,moving objects, etc.) when the fluid flows.

Particle trajectory tracked back in time.

Page 10: ICCSA 2010 Conference Presentation

ubi-logo

Introduction Stable Fluids NVIDIA Compute Unified Device Architecture (CUDA) Results Conclusions

Physics Model

Diffusion

Exchanges of densityor velocity betweenneighbours (2D).

Solve a sparse linear system (Ax = b), using an iter-ative method (e.g., Gauss-Seidel red black).

Page 11: ICCSA 2010 Conference Presentation

ubi-logo

Introduction Stable Fluids NVIDIA Compute Unified Device Architecture (CUDA) Results Conclusions

Physics Model

MoveEnsure mass conservation and the fluid’s incom-pressibility.Hodge decomposition:Conservative field = our field - gradient

Determine the gradient using diffusion’s iterativemethod (i.e., Gauss-Seidel red black).

Page 12: ICCSA 2010 Conference Presentation

ubi-logo

Introduction Stable Fluids NVIDIA Compute Unified Device Architecture (CUDA) Results Conclusions

Physics Model

Gauss-Seidel Red-Black

Page 13: ICCSA 2010 Conference Presentation

ubi-logo

Introduction Stable Fluids NVIDIA Compute Unified Device Architecture (CUDA) Results Conclusions

Workflow

Workflow

Page 14: ICCSA 2010 Conference Presentation

ubi-logo

Introduction Stable Fluids NVIDIA Compute Unified Device Architecture (CUDA) Results Conclusions

Grid partition

Grid partition

Page 15: ICCSA 2010 Conference Presentation

ubi-logo

Introduction Stable Fluids NVIDIA Compute Unified Device Architecture (CUDA) Results Conclusions

Results - Processing time

Results - Processing time

Page 16: ICCSA 2010 Conference Presentation

ubi-logo

Introduction Stable Fluids NVIDIA Compute Unified Device Architecture (CUDA) Results Conclusions

Conclusions

ConclusionsThe CUDA-based implementation of 3D stable fluidsachieved better performance (i.e. faster in processingtime) than the CPU-based implementation.The CUDA-based implementation of 3D stable fluidsallows grid sizes up to 1283, using an Nvidia GeForce8800 GT card.The CUDA-based implementation of 3D stable fluidsallows real-time simulations to grid sizes up to 323,using an Nvidia GeForce 8800 GT card.

Page 17: ICCSA 2010 Conference Presentation

ubi-logo

Introduction Stable Fluids NVIDIA Compute Unified Device Architecture (CUDA) Results Conclusions

Future Work

Future WorkSearch ways, implementable using CUDA, to reducestable fluids memory requirements (e.g., data struc-tures, dynamic memory, etc.).Reduce, numerical error related, dissipation in thesemi-Lagrangian advection, using MacCormack ad-vection instead.Implement and analyse the performance of an CPU-based multi-core version of 3D stable fluids.

Page 18: ICCSA 2010 Conference Presentation

ubi-logo

Introduction Stable Fluids NVIDIA Compute Unified Device Architecture (CUDA) Results Conclusions

Demo

Demo

Page 19: ICCSA 2010 Conference Presentation

ubi-logo

Introduction Stable Fluids NVIDIA Compute Unified Device Architecture (CUDA) Results Conclusions

Questions

Questions???