lecture 20: physically-based animation and...

45
Computer Graphics CMU 15-462/15-662, Fall 2015 Lecture 20: Physically-Based Animation and PDEs

Upload: hoangnhan

Post on 26-Apr-2018

232 views

Category:

Documents


3 download

TRANSCRIPT

Page 1: Lecture 20: Physically-Based Animation and PDEs15462.courses.cs.cmu.edu/.../lectures/20_pdes/20_pdes_slides.pdf · Lecture 20: Physically-Based Animation and PDEs. ... LAPLACE EQUATION

Computer GraphicsCMU 15-462/15-662, Fall 2015

Lecture 20:

Physically-Based Animation and PDEs

Page 2: Lecture 20: Physically-Based Animation and PDEs15462.courses.cs.cmu.edu/.../lectures/20_pdes/20_pdes_slides.pdf · Lecture 20: Physically-Based Animation and PDEs. ... LAPLACE EQUATION

Graphics as optimizationMany complex criteria/constraintsTechnique: numerical optimization- pick initial guess- ski downhill- keep fingers crossed!Today: return to differential equations- saw ODEs—derivatives in time- now PDEs—also have derivatives in space- describe many natural phenomena (water, smoke, cloth, ...)- recent revolution in CG/visual effects

CMU 15-462/662, Fall 2015

Last time: Optimization

Page 3: Lecture 20: Physically-Based Animation and PDEs15462.courses.cs.cmu.edu/.../lectures/20_pdes/20_pdes_slides.pdf · Lecture 20: Physically-Based Animation and PDEs. ... LAPLACE EQUATION

CMU 15-462/662, Fall 2015

Partial Differential Equations (PDEs)ODE: Implicitly describe function in terms of its time derivativesLike any implicit description, have to solve for actual functionPDE: Also include space derivatives in description

PDE—rock lands in pondODE—rock flies through air

Page 4: Lecture 20: Physically-Based Animation and PDEs15462.courses.cs.cmu.edu/.../lectures/20_pdes/20_pdes_slides.pdf · Lecture 20: Physically-Based Animation and PDEs. ... LAPLACE EQUATION

CMU 15-462/662, Fall 2015

To make a long story short...Solving ODE looks like “add a little velocity each time”

Solving a PDE looks like “take weighted combination of neighbors to get velocity (...and add a little velocity each time)”

...obviously there is a lot more to say here!

Page 5: Lecture 20: Physically-Based Animation and PDEs15462.courses.cs.cmu.edu/.../lectures/20_pdes/20_pdes_slides.pdf · Lecture 20: Physically-Based Animation and PDEs. ... LAPLACE EQUATION

CMU 15-462/662, Fall 2015

Liquid Simulation in Graphics

Losasso, F., Shinar, T. Selle, A. and Fedkiw, R., "Multiple Interacting Liquids"

Page 6: Lecture 20: Physically-Based Animation and PDEs15462.courses.cs.cmu.edu/.../lectures/20_pdes/20_pdes_slides.pdf · Lecture 20: Physically-Based Animation and PDEs. ... LAPLACE EQUATION

CMU 15-462/662, Fall 2015

Smoke Simulation in Graphics

S. Weißmann, U. Pinkall. “Filament-based smoke with vortex shedding and variational reconnection”

Page 7: Lecture 20: Physically-Based Animation and PDEs15462.courses.cs.cmu.edu/.../lectures/20_pdes/20_pdes_slides.pdf · Lecture 20: Physically-Based Animation and PDEs. ... LAPLACE EQUATION

CMU 15-462/662, Fall 2015

Cloth Simulation in Graphics

Zhili Chen, Renguo Feng and Huamin Wang, “Modeling friction and air effects between cloth and deformable bodies”

Page 8: Lecture 20: Physically-Based Animation and PDEs15462.courses.cs.cmu.edu/.../lectures/20_pdes/20_pdes_slides.pdf · Lecture 20: Physically-Based Animation and PDEs. ... LAPLACE EQUATION

CMU 15-462/662, Fall 2015

Elasticity in Graphics

Irving, G., Schroeder, C. and Fedkiw, R., "Volume Conserving Finite Element Simulation of Deformable Models"

Page 10: Lecture 20: Physically-Based Animation and PDEs15462.courses.cs.cmu.edu/.../lectures/20_pdes/20_pdes_slides.pdf · Lecture 20: Physically-Based Animation and PDEs. ... LAPLACE EQUATION

CMU 15-462/662, Fall 2015

Fracture in Graphics

James F. O'Brien, Adam Bargteil, Jessica Hodgins, “Graphical Modeling and Animation of Ductile Fracture”

Page 11: Lecture 20: Physically-Based Animation and PDEs15462.courses.cs.cmu.edu/.../lectures/20_pdes/20_pdes_slides.pdf · Lecture 20: Physically-Based Animation and PDEs. ... LAPLACE EQUATION

CMU 15-462/662, Fall 2015

Viscoelasticity in Graphics

Chris Wojtan, Greg Turk, “Fast Viscoelastic Behavior with Thin Features”

Page 12: Lecture 20: Physically-Based Animation and PDEs15462.courses.cs.cmu.edu/.../lectures/20_pdes/20_pdes_slides.pdf · Lecture 20: Physically-Based Animation and PDEs. ... LAPLACE EQUATION

CMU 15-462/662, Fall 2015

Snow Simulation in Graphics

Alexey Stomakhin, Craig Schroeder, Lawrence Chai, Joseph Teran, Andrew Selle, “A Material Point Method For Snow Simulation”

Page 13: Lecture 20: Physically-Based Animation and PDEs15462.courses.cs.cmu.edu/.../lectures/20_pdes/20_pdes_slides.pdf · Lecture 20: Physically-Based Animation and PDEs. ... LAPLACE EQUATION

Definition of a PDEWant to solve for a function of time and space

time space

Function given implicitly in terms of derivatives:

any combination of time derivatives

plus any combination of space derivatives

Example:

(Burgers’ equation)

Page 14: Lecture 20: Physically-Based Animation and PDEs15462.courses.cs.cmu.edu/.../lectures/20_pdes/20_pdes_slides.pdf · Lecture 20: Physically-Based Animation and PDEs. ... LAPLACE EQUATION

CMU 15-462/662, Fall 2015

Anatomy of a PDELinear vs. nonlinear: how are derivatives combined?

Order: how many derivatives in space & time?

(Burgers’ equation)

(diffusion equation)

nonlinear!

(Burgers’ equation)

(wave equation)

1st order in time 2nd order in space

2nd order in space2nd order in time

Nonlinear / higher order ⇒ HARDER TO SOLVE!

Page 15: Lecture 20: Physically-Based Animation and PDEs15462.courses.cs.cmu.edu/.../lectures/20_pdes/20_pdes_slides.pdf · Lecture 20: Physically-Based Animation and PDEs. ... LAPLACE EQUATION

Model EquationsFundamental behavior of many important PDEs is well-captured by three model linear equations:

LAPLACE EQUATION (“ELLIPTIC”)

HEAT EQUATION (“PARABOLIC”)

WAVE EQUATION (“HYPERBOLIC”)

E A S I E R

INTERMEDIATE

ADVANCED

[ NONLINEAR + HYPERBOLIC + HIGH-ORDER ]EXPERTS ONLY

“what’s the smoothest functioninterpolating the given boundary data”

“how does an initial distributionof heat spread out over time?”

“if you throw a rock into a pond, howdoes the wavefront evolve over time?”

“Laplacian” (more later!)Solve numerically?

Page 16: Lecture 20: Physically-Based Animation and PDEs15462.courses.cs.cmu.edu/.../lectures/20_pdes/20_pdes_slides.pdf · Lecture 20: Physically-Based Animation and PDEs. ... LAPLACE EQUATION

CMU 15-462/662, Fall 2015

Elliptic PDEs / Laplace Equation“What’s the smoothest function interpolating the given boundary data?”

Conceptually: each value is at the average of its “neighbors”Roughly speaking, why is it easier to solve?Very robust to errors: just keep averaging with neighbors!

Image from Solomon, Crane, Vouga, “Laplace-Beltrami: The Swiss Army Knife of Geometry Processing”

Page 17: Lecture 20: Physically-Based Animation and PDEs15462.courses.cs.cmu.edu/.../lectures/20_pdes/20_pdes_slides.pdf · Lecture 20: Physically-Based Animation and PDEs. ... LAPLACE EQUATION

CMU 15-462/662, Fall 2015

Parabolic PDEs / Heat Equation“How does an initial distribution of heat spread out over time?”

After a long time, solution is same as Laplace equation!Models damping / viscosity in many physical systems

Page 18: Lecture 20: Physically-Based Animation and PDEs15462.courses.cs.cmu.edu/.../lectures/20_pdes/20_pdes_slides.pdf · Lecture 20: Physically-Based Animation and PDEs. ... LAPLACE EQUATION

CMU 15-462/662, Fall 2015

Hyperbolic PDEs / Wave Equation“If you throw a rock into a pond, how does the wavefront evolve over time?”

Errors made at the beginning will persist for a long time! (hard)

Page 19: Lecture 20: Physically-Based Animation and PDEs15462.courses.cs.cmu.edu/.../lectures/20_pdes/20_pdes_slides.pdf · Lecture 20: Physically-Based Animation and PDEs. ... LAPLACE EQUATION

CMU 15-462/662, Fall 2015

How did we do that?

Page 20: Lecture 20: Physically-Based Animation and PDEs15462.courses.cs.cmu.edu/.../lectures/20_pdes/20_pdes_slides.pdf · Lecture 20: Physically-Based Animation and PDEs. ... LAPLACE EQUATION

CMU 15-462/662, Fall 2015

Numerical Solution of PDEs—OverviewLike ODEs, many interesting PDEs are difficult/impossible to solve analytically—especially if we want to incorporate data (e.g., user interaction)Must instead use numerical integrationBasic strategy:- pick a time discretization (forward Euler, backward Euler...)- pick a spatial discretization (TODAY)- as with ODEs, run a time-stepping algorithmHistorically, very expensive—only for “hero shots” in moviesComputers are ever faster...More & more use of PDEs in games, interactive tools, ...

Page 21: Lecture 20: Physically-Based Animation and PDEs15462.courses.cs.cmu.edu/.../lectures/20_pdes/20_pdes_slides.pdf · Lecture 20: Physically-Based Animation and PDEs. ... LAPLACE EQUATION

CMU 15-462/662, Fall 2015

Real Time PDE-Based Simulation (Fire)

Page 23: Lecture 20: Physically-Based Animation and PDEs15462.courses.cs.cmu.edu/.../lectures/20_pdes/20_pdes_slides.pdf · Lecture 20: Physically-Based Animation and PDEs. ... LAPLACE EQUATION

CMU 15-462/662, Fall 2015

Lagrangian vs. EulerianTwo basic ways to discretize space: Lagrangian & EulerianE.g., suppose we want to encode the motion of a fluid

LAGRANGIAN

track position & velocityof moving particles

EULERIAN

track velocity (or flux)at fixed grid locations

Page 24: Lecture 20: Physically-Based Animation and PDEs15462.courses.cs.cmu.edu/.../lectures/20_pdes/20_pdes_slides.pdf · Lecture 20: Physically-Based Animation and PDEs. ... LAPLACE EQUATION

CMU 15-462/662, Fall 2015

Lagrangian vs. Eulerian—Trade-OffsLagrangian- conceptually easy (like polygon soup!)- resolution/domain not limited by grid- good particle distribution can be tough- finding neighbors can be expensiveEulerian- fast, regular computation- easy to represent, e.g., smooth surfaces- simulation “trapped” in grid- grid causes “numerical diffusion” (blur)- need to understand PDEs (but you will!)

Page 25: Lecture 20: Physically-Based Animation and PDEs15462.courses.cs.cmu.edu/.../lectures/20_pdes/20_pdes_slides.pdf · Lecture 20: Physically-Based Animation and PDEs. ... LAPLACE EQUATION

CMU 15-462/662, Fall 2015

Mixing Lagrangian & EulerianOf course, no reason you have to choose just one!Many modern methods mix Lagrangian & Eulerian:- PIC/FLIP, particle level sets, mesh-based surface tracking,

Voronoi-based, arbitrary Lagrangian-Eulerian (ALE), ...Pick the right tool for the job!

Maya Bifrost

Page 26: Lecture 20: Physically-Based Animation and PDEs15462.courses.cs.cmu.edu/.../lectures/20_pdes/20_pdes_slides.pdf · Lecture 20: Physically-Based Animation and PDEs. ... LAPLACE EQUATION

Aside: Which Quantity Do We Solve For?Many PDEs have mathematically equivalent formulations in terms of different quantitiesE.g., incompressible fluids:- velocity—how fast is each particle moving?- vorticity—how fast is fluid “spinning” at each point?Computationally, can make a big differencePick the right tool for the job!

Page 27: Lecture 20: Physically-Based Animation and PDEs15462.courses.cs.cmu.edu/.../lectures/20_pdes/20_pdes_slides.pdf · Lecture 20: Physically-Based Animation and PDEs. ... LAPLACE EQUATION

CMU 15-462/662, Fall 2015

Ok, but we’re getting way ahead of ourselves.How do we solve easy PDEs?

Page 28: Lecture 20: Physically-Based Animation and PDEs15462.courses.cs.cmu.edu/.../lectures/20_pdes/20_pdes_slides.pdf · Lecture 20: Physically-Based Animation and PDEs. ... LAPLACE EQUATION

CMU 15-462/662, Fall 2015

Numerical PDEs—Basic StrategyPick PDE formulation- Which quantity do we want to solve for?- E.g., velocity or vorticity?Pick spatial discretization- How do we approximate derivatives in space?Pick time discretization- How do we approximate derivatives in time?- When do we evaluate forces?- Forward Euler, backward Euler, symplectic Euler, ...Finally, we have an update ruleRepeatedly solve to generate an animation

Richard Courant

Page 29: Lecture 20: Physically-Based Animation and PDEs15462.courses.cs.cmu.edu/.../lectures/20_pdes/20_pdes_slides.pdf · Lecture 20: Physically-Based Animation and PDEs. ... LAPLACE EQUATION

CMU 15-462/662, Fall 2015

The Laplace OperatorAll of our model equations used the Laplace operatorDifferent conventions for symbol:

same symbol used for “change”same symbol used for Hessian!

Unbelievably important object showing up everywhere across physics, geometry, signal processing, ...Ok, but what does it mean?Differential operator: eats a function, spits out its “2nd derivative”

What does that mean for a function u: Rn→R?divergence of gradientsum of second derivatives“average” curvature

div grad

Page 30: Lecture 20: Physically-Based Animation and PDEs15462.courses.cs.cmu.edu/.../lectures/20_pdes/20_pdes_slides.pdf · Lecture 20: Physically-Based Animation and PDEs. ... LAPLACE EQUATION

CMU 15-462/662, Fall 2015

Discretizing the LaplacianHow do we approximate the Laplacian?Depends on discretization (Eulerian, Lagrangian, grid, mesh, ...)Two extremely common ways in graphics:

GRID TRIANGLE MESH(actually, this becomes that)

Also not too hard on point clouds, polygon meshes, ...

Page 31: Lecture 20: Physically-Based Animation and PDEs15462.courses.cs.cmu.edu/.../lectures/20_pdes/20_pdes_slides.pdf · Lecture 20: Physically-Based Animation and PDEs. ... LAPLACE EQUATION

CMU 15-462/662, Fall 2015

Numerically Solving the Laplace EquationWant to solve Δu = 0Plug in one of our discretizations, e.g.,

Oh: if we have a solution, then each value must be the average of the neighboring values.How do we solve this?One idea: keep averaging with neighbors! (“Jacobi method”)Correct, but slow. We’ll discuss faster methods next lecture.

Page 32: Lecture 20: Physically-Based Animation and PDEs15462.courses.cs.cmu.edu/.../lectures/20_pdes/20_pdes_slides.pdf · Lecture 20: Physically-Based Animation and PDEs. ... LAPLACE EQUATION

CMU 15-462/662, Fall 2015

Boundary Conditions for Discrete LaplaceWhat values do we use to compute averages near the boundary?

A: We get to choose—this is the data we want to interpolate!Two basic boundary conditions:1. Dirichlet—boundary data always set to fixed values2. Neumann—specify derivative (difference) across boundaryAlso mixed (Robin) boundary conditions (and more, in general)

Page 33: Lecture 20: Physically-Based Animation and PDEs15462.courses.cs.cmu.edu/.../lectures/20_pdes/20_pdes_slides.pdf · Lecture 20: Physically-Based Animation and PDEs. ... LAPLACE EQUATION

CMU 15-462/662, Fall 2015

Dirichlet Boundary ConditionsLet’s go back to smooth setting, function on real lineDirichlet means “prescribe values”E.g., Φ(0)=a, Φ(1) = b

Many possible functions “in between”!

Page 34: Lecture 20: Physically-Based Animation and PDEs15462.courses.cs.cmu.edu/.../lectures/20_pdes/20_pdes_slides.pdf · Lecture 20: Physically-Based Animation and PDEs. ... LAPLACE EQUATION

CMU 15-462/662, Fall 2015

Neumann Boundary ConditionsNeumann means “prescribe derivatives”E.g., Φ’(0)=u, Φ’(1) = v

Again, many possible functions!

Page 35: Lecture 20: Physically-Based Animation and PDEs15462.courses.cs.cmu.edu/.../lectures/20_pdes/20_pdes_slides.pdf · Lecture 20: Physically-Based Animation and PDEs. ... LAPLACE EQUATION

CMU 15-462/662, Fall 2015

Both Neumann & DirichletOr: prescribe some values, some derivativesE.g., Φ’(0)=u, Φ(1) = b

Q: What about Φ’(1)=v, Φ(1) = b? Does that work?Q: What about Φ’(0) + Φ(0) = p, Φ’(1) + Φ(1) = q? (Robin)

Page 36: Lecture 20: Physically-Based Animation and PDEs15462.courses.cs.cmu.edu/.../lectures/20_pdes/20_pdes_slides.pdf · Lecture 20: Physically-Based Animation and PDEs. ... LAPLACE EQUATION

CMU 15-462/662, Fall 2015

1D Laplace w/ Dirichlet BCs1D Laplace: ∂2Φ/∂x2 = 0Solutions: Φ(x) = cx + dQ: Can we always satisfy given Dirichlet boundary conditions?

Yes: a line can interpolate any two points.

Page 37: Lecture 20: Physically-Based Animation and PDEs15462.courses.cs.cmu.edu/.../lectures/20_pdes/20_pdes_slides.pdf · Lecture 20: Physically-Based Animation and PDEs. ... LAPLACE EQUATION

1D Laplace w/ Neumann BCsWhat about Neumann BCs?Q: Can we prescribe the derivative at both ends?

No! A line has only one slope.In general, solution to a PDE may not exist for given BCs.

Page 38: Lecture 20: Physically-Based Animation and PDEs15462.courses.cs.cmu.edu/.../lectures/20_pdes/20_pdes_slides.pdf · Lecture 20: Physically-Based Animation and PDEs. ... LAPLACE EQUATION

CMU 15-462/662, Fall 2015

2D Laplace w/ Dirichlet BCs2D Laplace: ∆ Φ=0Q: Can satisfy any Dirichlet BCs? (given data along boundary)

Yes: Laplace is long-time solution to heat flowData is “heat” at boundary. Then just let it flow...

Page 39: Lecture 20: Physically-Based Animation and PDEs15462.courses.cs.cmu.edu/.../lectures/20_pdes/20_pdes_slides.pdf · Lecture 20: Physically-Based Animation and PDEs. ... LAPLACE EQUATION

CMU 15-462/662, Fall 2015

2D Laplace w/ Neumann BCsWhat about Neumann BCs for ∆Φ=0?

Neumann BCs prescribe derivative in normal direction: n∙∇ΦQ: Can it always be done? (Wasn’t possible in 1D...)In 2D, we have the divergence theorem:

Should be called, “what goes in must come out theorem!”Can’t have a solution unless the net flux through the boundary is zero.

Numerical software will not always tell you if there’s a problem! (Especially if you wrote it yourself...)

Page 40: Lecture 20: Physically-Based Animation and PDEs15462.courses.cs.cmu.edu/.../lectures/20_pdes/20_pdes_slides.pdf · Lecture 20: Physically-Based Animation and PDEs. ... LAPLACE EQUATION

CMU 15-462/662, Fall 2015

Solving the Heat EquationBack to our three model equations, want to solve heat eqn.

Just saw how to discretize LaplacianAlso know how to do time (forward Euler, backward Euler, ...)E.g., forward Euler:

Q: On a grid, what’s our overall update now at ui,j?

Not hard to implement! Loop over grid, add up some neighbors.

Page 41: Lecture 20: Physically-Based Animation and PDEs15462.courses.cs.cmu.edu/.../lectures/20_pdes/20_pdes_slides.pdf · Lecture 20: Physically-Based Animation and PDEs. ... LAPLACE EQUATION

CMU 15-462/662, Fall 2015

Solving the Wave EquationFinally, wave equation:

Not much different; now have 2nd derivative in timeBy now we’ve learned two different techniques:- Convert to two 1st order (in time) equations:

- Or, use centered difference (like Laplace) in time:

Plus all our choices about how to discretize Laplacian.So many choices! And many, many (many) more we didn’t discuss.

Page 42: Lecture 20: Physically-Based Animation and PDEs15462.courses.cs.cmu.edu/.../lectures/20_pdes/20_pdes_slides.pdf · Lecture 20: Physically-Based Animation and PDEs. ... LAPLACE EQUATION

CMU 15-462/662, Fall 2015

DEMO: Model PDEs on a Triangle Mesh

Page 43: Lecture 20: Physically-Based Animation and PDEs15462.courses.cs.cmu.edu/.../lectures/20_pdes/20_pdes_slides.pdf · Lecture 20: Physically-Based Animation and PDEs. ... LAPLACE EQUATION

CMU 15-462/662, Fall 2015

Wait, what about all those cool fluids and stuff?

Page 44: Lecture 20: Physically-Based Animation and PDEs15462.courses.cs.cmu.edu/.../lectures/20_pdes/20_pdes_slides.pdf · Lecture 20: Physically-Based Animation and PDEs. ... LAPLACE EQUATION

CMU 15-462/662, Fall 2015

Want to Know More?There are some good books:And papers:

http://www.physicsbasedanimation.com/

Also, what did the folks who wrote these books & papers read?

Page 45: Lecture 20: Physically-Based Animation and PDEs15462.courses.cs.cmu.edu/.../lectures/20_pdes/20_pdes_slides.pdf · Lecture 20: Physically-Based Animation and PDEs. ... LAPLACE EQUATION

CMU 15-462/662, Fall 2015

Next up: solving linear equations