Animation of Fluids Animating Fluid is Hard Too

  • Slides: 47
Download presentation
Animation of Fluids

Animation of Fluids

Animating Fluid is Hard… • Too complex to animate by hand – Surface is

Animating Fluid is Hard… • Too complex to animate by hand – Surface is changing very quickly – Lots of small details – In short, a nightmare! • Need automatic simulations…

Ad-Hoc Methods • Some simple algorithms exist for special cases – Mostly waves… •

Ad-Hoc Methods • Some simple algorithms exist for special cases – Mostly waves… • What about water glass? • Too much work to come up with empirical algorithms for each case…

Physically-Based Approach • Look to Fluid Dynamics – Long history. Back to Newton… –

Physically-Based Approach • Look to Fluid Dynamics – Long history. Back to Newton… – Equations that describe fluid motion • Use numerical methods to approximate fluid equations, simulating fluid motion – Like mass-spring systems

Current State-of-the-art in CG • Marker-And-Cell (MAC) Method – fedkiw_fluidglass 00. avi – fedkiw_fluidsplash-640.

Current State-of-the-art in CG • Marker-And-Cell (MAC) Method – fedkiw_fluidglass 00. avi – fedkiw_fluidsplash-640. avi • Smoothed Particle Hydrodynamics (SPH) – muller_particlessph. avi – muller_particlespool. avi

Applications • Mostly Hollywood – Shrek – Antz – Terminator 3 – Many others…

Applications • Mostly Hollywood – Shrek – Antz – Terminator 3 – Many others… • Games • Engineering…

Fluid Dynamics (with as little math as possible)

Fluid Dynamics (with as little math as possible)

What do we mean by ‘Fluid’? • liquids or gasses • Mathematically: – A

What do we mean by ‘Fluid’? • liquids or gasses • Mathematically: – A vector field u (represents the fluid velocity) – A scalar field p (represents the fluid pressure) – fluid density (d) and fluid viscosity (v)

Vector Fields • 2 D Scalar function: – f(x, y) = z – z

Vector Fields • 2 D Scalar function: – f(x, y) = z – z is a scalar value • 2 D Vector function: – u(x, y) = v – v is a vector value • v = (x’, y’) • The set of values u(x, y) = v is called a vector field

Fluid Velocity == Vector Field • Can model a fluid as a vector field

Fluid Velocity == Vector Field • Can model a fluid as a vector field u(x, y) – u is the velocity of the fluid at (x, y) – Velocity is different at each point in fluid! • Need to compute change in vector field

Conceptual Leap • Particle Simulation: – Track particle positions x = (x, y) –

Conceptual Leap • Particle Simulation: – Track particle positions x = (x, y) – Numerically Integrate: change in position • Fluid Simulation : – Track fluid velocities u = (u, v) at all points x in some fluid volume D – Numerically Integrate: change in velocity

Equations of Fluid Dynamics • Navier-Stokes Equation: – Non-linear Partial Differential Equation – Models

Equations of Fluid Dynamics • Navier-Stokes Equation: – Non-linear Partial Differential Equation – Models fluid transport – Derived from Newton’s second law • conservation of momentum – all the forces go “somewhere” • Mass-Conservation condition: – If we have a liter of water at the beginning of the solution, we have a liter at the end…

Change in Velocity • Derivative of velocity with respect to time • Change in

Change in Velocity • Derivative of velocity with respect to time • Change in velocity, or acceleration – So this equation models acceleration of fluids

Advection Term Change in Velocity • Advection term – Force exerted on a particle

Advection Term Change in Velocity • Advection term – Force exerted on a particle of fluid by the other particles of fluid surrounding it – How the fluid “pushes itself around”

Particle Advection Video

Particle Advection Video

Diffusion Term Change in Velocity Advection • Viscosity constant controls velocity diffusion • Essentially,

Diffusion Term Change in Velocity Advection • Viscosity constant controls velocity diffusion • Essentially, this term describes how fluid motion is damped • Highly viscous fluids stick together – Like maple syrup • Low-viscosity fluids flow freely – Gasses have low viscosity

Weather: Advection & Diffusion • “Jet-Stream”

Weather: Advection & Diffusion • “Jet-Stream”

Pressure Term Change in Velocity Advection Diffusion • Pressure follows a diffusion process –

Pressure Term Change in Velocity Advection Diffusion • Pressure follows a diffusion process – Fluid moves from high-pressure areas to low-pressure areas • Moving == velocity – So fluid moves in direction of largest change in pressure – This direction is the gradient p=0 p=1 Time… p = 0. 5

Weather: Pressure • “Fronts” are the boundaries between regions of air with different pressure…

Weather: Pressure • “Fronts” are the boundaries between regions of air with different pressure… • “High Pressure Zones” will diffuse into “Low Pressure Zones”

Fluid Example • Fast moving fluid is “pulled” towards slower-moving fluid

Fluid Example • Fast moving fluid is “pulled” towards slower-moving fluid

Body Force Change in Velocity Advection Diffusion Pressure • Body force term represents external

Body Force Change in Velocity Advection Diffusion Pressure • Body force term represents external forces that act on the fluid – Gravity – Wind – Etc…

Summary Change in Velocity Advection Diffusion Pressure • And 1 liter == 1 liter

Summary Change in Velocity Advection Diffusion Pressure • And 1 liter == 1 liter constraint: • Need to simulate these equations…

Intermission • Smoke – fedkiw_octreesmoke_octree. avi • Fire – fedkiw_fireflammable. avi

Intermission • Smoke – fedkiw_octreesmoke_octree. avi • Fire – fedkiw_fireflammable. avi

Implementation Overview

Implementation Overview

Fluid Representation • Want to simulate motion of some fluid body – fluid is

Fluid Representation • Want to simulate motion of some fluid body – fluid is represented by a vector field • Two problems: – Need to compute change in vector field (using Navier. Stokes equation) – Need to track fluid position

Solution: Discretization • Create regular grid

Solution: Discretization • Create regular grid

Solution: Discretization • Create regular grid • Discretize fluid into grid cells

Solution: Discretization • Create regular grid • Discretize fluid into grid cells

Solution: Discretization • Create regular grid • Discretize fluid into grid cells • Track

Solution: Discretization • Create regular grid • Discretize fluid into grid cells • Track single velocity vector in each grid cell

Simulation Step • “Solve” Navier-Stokes equation for each grid cell to compute change in

Simulation Step • “Solve” Navier-Stokes equation for each grid cell to compute change in velocity: ¶u 1 = -(u × Ñ)u + Ñ × (vÑu) - Ñp + f ¶t d non-linear Advection term is difficult. Can finite-difference, but is not robust… finite-difference Diffusion and Pressure terms are linear systems of equations Body Force is just like massspring systems

Free Surface Tracking with Marker Particles • Want higher-resolution surface for rendering • Add

Free Surface Tracking with Marker Particles • Want higher-resolution surface for rendering • Add a bunch of particles • Passively Advect them based on fluid velocity

So the rest is easy, right? • No • Still have to enforce mass-conservation

So the rest is easy, right? • No • Still have to enforce mass-conservation constaint: • Standard equation does not take boundary conditions into account – Boundary conditions are things like walls, fluid/air boundaries, rubber duckies, and so on – Have to ‘hack’ the equations…this is hard… • Numerical Stability is elusive…

Intermission 2 • Melting – carlson_meltingbunnyside. mpg • Rigid Body + Fluid – carlson_rigidfluidrigidfluid.

Intermission 2 • Melting – carlson_meltingbunnyside. mpg • Rigid Body + Fluid – carlson_rigidfluidrigidfluid. avi

Problems with Fluid Simulation

Problems with Fluid Simulation

Surface Resolution…

Surface Resolution…

Weird Behavior….

Weird Behavior….

Water or Vegetable Oil? • fedkiw_fluidglass 00. avi • Oh, and it’s very, very

Water or Vegetable Oil? • fedkiw_fluidglass 00. avi • Oh, and it’s very, very slow – 7 minutes per frame for water glass…

Hard to Control • Animators want to control fluid behavior • Fluid simulation has

Hard to Control • Animators want to control fluid behavior • Fluid simulation has a lot of free variables • There has been limited success so far…

Numerical Stability

Numerical Stability

Maya Fluid Effects

Maya Fluid Effects

What does fluid effects support? • Naver-Stokes-based Fluids: – – – Smoke Clouds Explosions

What does fluid effects support? • Naver-Stokes-based Fluids: – – – Smoke Clouds Explosions Fire “Goo” type-stuff • Ad-Hoc / Mass-Spring fluids: – Oceans – Ponds

Fluid Effects Algorithms • Unconditionally Stable Navier-Stokes simulation – Means they never explode, even

Fluid Effects Algorithms • Unconditionally Stable Navier-Stokes simulation – Means they never explode, even with large timesteps – Jos Stam, “Stable Fluids”, SIGGRAPH 99 • Do not preserve volume very well – Ok for smoke – Problematic for water glass… – Gets worse w/ larger timestep

Maya Smoke • Smoke demo

Maya Smoke • Smoke demo

Maya Fire • Looks like smoke…

Maya Fire • Looks like smoke…

More Fluid Effects Demos

More Fluid Effects Demos

Maya Ocean • 2 D height field – no crashing waves • Can attach

Maya Ocean • 2 D height field – no crashing waves • Can attach ‘bouyant’ objects

Maya Pond • 2 D height field – No splashing • Mass-spring system •

Maya Pond • 2 D height field – No splashing • Mass-spring system • Bouys, Boats, Wakes • Can run in real-time

Fin (questions? )

Fin (questions? )