methods for the physically based simulation of solids and fluids geoffrey irving stanford university...

119
Methods for the Physically Based Simulation of Solids and Fluids Geoffrey Irving Stanford University May 16, 2007

Upload: dina-reeves

Post on 26-Dec-2015

219 views

Category:

Documents


0 download

TRANSCRIPT

Page 1: Methods for the Physically Based Simulation of Solids and Fluids Geoffrey Irving Stanford University May 16, 2007

Methods for the Physically Based Simulation of Solids and FluidsMethods for the Physically Based Simulation of Solids and Fluids

Geoffrey Irving

Stanford University

May 16, 2007

Page 2: Methods for the Physically Based Simulation of Solids and Fluids Geoffrey Irving Stanford University May 16, 2007

OutlineOutline

• Three topics

– Robust finite element simulation

– Incompressible deformable solids

– Large scale water simulation

• Solids go first so I get more questions

Page 3: Methods for the Physically Based Simulation of Solids and Fluids Geoffrey Irving Stanford University May 16, 2007

Invertible Finite Elements for Robust Simulation of Large DeformationInvertible Finite Elements for Robust Simulation of Large Deformation

with Joseph Teran and Ron Fedkiw

Page 4: Methods for the Physically Based Simulation of Solids and Fluids Geoffrey Irving Stanford University May 16, 2007

Goal: Keep Lagrangian Simulations from breakingGoal: Keep Lagrangian Simulations from breaking

• Finite element method: volumetric objects tessellated with tetrahedra.

• Simulation only as robust as the worst element.

• One inversion can halt the simulation.

Page 5: Methods for the Physically Based Simulation of Solids and Fluids Geoffrey Irving Stanford University May 16, 2007

Previous workPrevious work

• Mass-spring systems:

– Palmerio 1994 - psuedopressure term

– Cooper 1997, Molino 2003 - altitude springs

• Rotated linear finite elements:

– Etzmuss 2003, Muller 2004 – used polar decomposition to fix rotation errors from linearization

• ALE and remeshing:

– Hirt 1974, Camacho 1997, Espinoza 1998

Page 6: Methods for the Physically Based Simulation of Solids and Fluids Geoffrey Irving Stanford University May 16, 2007

Why not masses and springs?Why not masses and springs?

• Altitude springs or psuedopressure terms work well: fast and robust.

• Unless you want to change the material behavior.

• Harder to add plasticity, biphasic response for flesh, etc.

• No intuitive relationship between different force components.

Page 7: Methods for the Physically Based Simulation of Solids and Fluids Geoffrey Irving Stanford University May 16, 2007

Our approach:Invertible finite elementsOur approach:Invertible finite elements

• Start with standard finite elements.

• Forces on nodes result from stress in each tetrahedron.

• Modify stress to behave correctly through inversion.

• Resulting forces reasonable for all possible configurations (inverted, flat, line, point, etc.).

Page 8: Methods for the Physically Based Simulation of Solids and Fluids Geoffrey Irving Stanford University May 16, 2007

ExampleExample

Page 9: Methods for the Physically Based Simulation of Solids and Fluids Geoffrey Irving Stanford University May 16, 2007

OutlineOutline

• State of each tetrahedron given by deformation gradient F (3x3 matrix).

• Diagonalize F to remove rotations:

F = UFDVT

• Use first Piola-Kirchhoff stress:

P = UPDVT

• Forces on nodes are linear in P:

G = PBm

Page 10: Methods for the Physically Based Simulation of Solids and Fluids Geoffrey Irving Stanford University May 16, 2007

Deformation Gradient: FDeformation Gradient: F

• Maps vectors in material space to world space.

0X��������������

2X��������������

1X��������������

0x

1x

2x

2md��������������

1md��������������

1sd��������������

2sd��������������

deformed(world coordinates)

undeformed(material coordinates)

1s mF D D

Page 11: Methods for the Physically Based Simulation of Solids and Fluids Geoffrey Irving Stanford University May 16, 2007

Standard approach: Green StrainStandard approach: Green Strain

• We could write stress in terms of Green strain 1/2(FTF-I).

• Bad for two reasons:

– Already nonlinear in deformation.

– Can’t detect inversion!

• Instead, we write stress P directly in terms of F, and ignore strain.

Page 12: Methods for the Physically Based Simulation of Solids and Fluids Geoffrey Irving Stanford University May 16, 2007

Diagonalization of FDiagonalization of F

• Isotropic materials are invariant under rotations of material and world space, but not under reflections.

• Standard SVD gives F = UFDVT with– V a pure rotation

– U a pure rotation or a reflection

– Diagonal FD with all positive entries

• If U is a reflection, we negate an entry of FD and the corresponding column of U.

• Heuristic: choose smallest entry of FD to make tetrahedron recover as quickly as possible.

Page 13: Methods for the Physically Based Simulation of Solids and Fluids Geoffrey Irving Stanford University May 16, 2007

Diagonalization of FDiagonalization of F

SVD must be robust to zero or duplicate singular values.

Page 14: Methods for the Physically Based Simulation of Solids and Fluids Geoffrey Irving Stanford University May 16, 2007

First Piola-Kirchhoff StressFirst Piola-Kirchhoff Stress

• For an isotropic model, diagonal FD gives a

diagonal stress PD.

• Can consider one stress component at a time.

• St. Venant-Kirchhoff useless for large compression.

Page 15: Methods for the Physically Based Simulation of Solids and Fluids Geoffrey Irving Stanford University May 16, 2007

First Piola-Kirchhoff StressFirst Piola-Kirchhoff Stress

• Better models have a singularity at the origin

• Adds severe stiffness

• Still dies if numerical errors cause inversion.

Page 16: Methods for the Physically Based Simulation of Solids and Fluids Geoffrey Irving Stanford University May 16, 2007

First Piola-Kirchhoff StressFirst Piola-Kirchhoff Stress

• We fix this by extrapolating the curve through inversion after a threshold.

• Diagonalization makes this easy for any model.

Page 17: Methods for the Physically Based Simulation of Solids and Fluids Geoffrey Irving Stanford University May 16, 2007

Constant vs. linear extrapolationConstant vs. linear extrapolation

• In practice, constant extrapolation fails.

• Energy function not strictly convex.

• Slightly deformed tetrahedra can improve at the cost of inverted tetrahedra.

• Tangling results in incoherent inversion directions.

• Model explodes slowly.

Page 18: Methods for the Physically Based Simulation of Solids and Fluids Geoffrey Irving Stanford University May 16, 2007

Force ComputationForce Computation

• Given a correct diagonal stress PD, the

forces can be computed as

G = PBm = UPDVTBm

• Bm is a matrix depending only on the rest

state of the tetrahedron.

• Since forces are linear in P, robust P means robust forces.

Page 19: Methods for the Physically Based Simulation of Solids and Fluids Geoffrey Irving Stanford University May 16, 2007

Element inversion is physicalElement inversion is physical

F continuous deformation by grey colored object

discrete version illustrates element inversion

Page 20: Methods for the Physically Based Simulation of Solids and Fluids Geoffrey Irving Stanford University May 16, 2007

ResultsResults

Elastic sphere compressed between two gears.

Page 21: Methods for the Physically Based Simulation of Solids and Fluids Geoffrey Irving Stanford University May 16, 2007

ResultsResults

Buddha model compressed between two gears.

Page 22: Methods for the Physically Based Simulation of Solids and Fluids Geoffrey Irving Stanford University May 16, 2007

ResultsResults

Buddha model colliding with kinematic sphere.

Page 23: Methods for the Physically Based Simulation of Solids and Fluids Geoffrey Irving Stanford University May 16, 2007

Damping and anisotropyDamping and anisotropy

• Damping forces computed analogously to elastic forces.

• Difficult to conserve angular momentum during damping for flat or inverted elements, but no visual artifacts from lack of conservation.

• For anisotropic constitutive models, use V to rotate anisotropic terms into diagonal space.

Page 24: Methods for the Physically Based Simulation of Solids and Fluids Geoffrey Irving Stanford University May 16, 2007

Results: anisotropyResults: anisotropy

Anisotropic constitutive model for muscles.

Page 25: Methods for the Physically Based Simulation of Solids and Fluids Geoffrey Irving Stanford University May 16, 2007

PlasticityPlasticity

• We use multiplicative plasticity:

F = Fe Fp

• Elastic forces computed from elastic deformation Fe .

• Plastic deformation Fp clamped away from inversion

to ensure robustness.

• Plasticity can be controlled by accepting only deformations that move towards a target shape.

Page 26: Methods for the Physically Based Simulation of Solids and Fluids Geoffrey Irving Stanford University May 16, 2007

Results: plasticityResults: plasticity

Plastic sphere controlled towards a disk shape.

Page 27: Methods for the Physically Based Simulation of Solids and Fluids Geoffrey Irving Stanford University May 16, 2007

Results: plasticityResults: plasticity

A more obvious example of plasticity control

Page 28: Methods for the Physically Based Simulation of Solids and Fluids Geoffrey Irving Stanford University May 16, 2007

Results: plasticityResults: plasticity

Plastic shell compressed between two gears.

Page 29: Methods for the Physically Based Simulation of Solids and Fluids Geoffrey Irving Stanford University May 16, 2007

Generalization to other elementsGeneralization to other elements

• Inversion fixes modify underlying PDE.

• Any (Lagrangian) discretization can be applied to the new PDE.

• For other element types, modified P(F) is evaluated at each Gauss point.

Page 30: Methods for the Physically Based Simulation of Solids and Fluids Geoffrey Irving Stanford University May 16, 2007

Results: hexahedraResults: hexahedra

Hexahedral mesh collapsing into a puddle.

Page 31: Methods for the Physically Based Simulation of Solids and Fluids Geoffrey Irving Stanford University May 16, 2007

ConclusionsConclusions

• Simple method for robust FEM:

– Diagonalize F to remove rotations.

– Modify first Piola-Kirchhoff stress P for inversion.

• Diagonal setting helps intuition.

• Works for arbitrary constitutive models, including anisotropy.

• Easy to add plasticity and plasticity control.

Page 32: Methods for the Physically Based Simulation of Solids and Fluids Geoffrey Irving Stanford University May 16, 2007

Volume Preserving Finite Element Simulations of Deformation ModelsVolume Preserving Finite Element Simulations of Deformation Models

with Craig Schroeder and Ron Fedkiw

Page 33: Methods for the Physically Based Simulation of Solids and Fluids Geoffrey Irving Stanford University May 16, 2007

MotivationMotivation

• Virtual humans increasingly important

– Stunt doubles

– Virtual surgery

• Most biological tissues incompressible

– Muscles, skin, fat

• Volume preservation is local

– Conserving total volume insufficient

Page 34: Methods for the Physically Based Simulation of Solids and Fluids Geoffrey Irving Stanford University May 16, 2007

MotivationMotivation

• Important principle of animation

• Lasseter 1987:

“The most important rule to squash and stretch is that, no matter how squashed or stretched out a particular object gets, its volume remains constant.”

Page 35: Methods for the Physically Based Simulation of Solids and Fluids Geoffrey Irving Stanford University May 16, 2007

Three main challengesThree main challenges

• Volumetric locking

– Incompressibility aliases with other modes

– Turns entire object rigid

• Volume preservation infinitely stiff

– Implicit integration necessary

– Might introduce oscillations in other modes

• Not the only infinite force (collisions)

Page 36: Methods for the Physically Based Simulation of Solids and Fluids Geoffrey Irving Stanford University May 16, 2007

Our approachOur approach

• Volumetric locking

– Caused by too many constraints

– Conserve volume per node (one-ring)

– Fewer constraints: no locking

• Volume preservation stiffness

– Use separate implicit solves for position and velocity

– Cancels errors without introducing oscillations

– Analogous to projection method in fluids

• Incorporate collisions into linear solves

Page 37: Methods for the Physically Based Simulation of Solids and Fluids Geoffrey Irving Stanford University May 16, 2007

ExampleExample

Page 38: Methods for the Physically Based Simulation of Solids and Fluids Geoffrey Irving Stanford University May 16, 2007

Previous workPrevious work

• Spring-like forces for volume preservation

– Cooper and Maddock 1997, many others

• Quasi-incompressibility

– Simo and Taylor 1991

– Weiss et al. 1996, Teran et al. 2005: muscle simulation

• Per-node pressure variables

– Bonet and Burton 1998: averaged nodal pressure

– Lahiri et al. 2005: variational integrators

– Cockburn et al. 2006: discontinuous Galerkin

Page 39: Methods for the Physically Based Simulation of Solids and Fluids Geoffrey Irving Stanford University May 16, 2007

Basic setupBasic setup

• Start with linear tetrahedral elements

– Position, velocity located at each node

– Elastic forces computed per tetrahedron

• Preserve volume of each one-ring

Page 40: Methods for the Physically Based Simulation of Solids and Fluids Geoffrey Irving Stanford University May 16, 2007

OutlineOutline

• Time Discretization

• Spatial Discretization

• Collisions and Contact

• Discussion and Results

Page 41: Methods for the Physically Based Simulation of Solids and Fluids Geoffrey Irving Stanford University May 16, 2007

OutlineOutline

• Time Discretization

• Spatial Discretization

• Collisions and Contact

• Discussion and Results

Page 42: Methods for the Physically Based Simulation of Solids and Fluids Geoffrey Irving Stanford University May 16, 2007

Time discretizationTime discretization

• Start with any time integration scheme

• Add two new steps:

– When updating position, solve for pressure to correct volume loss

– After updating velocity, solve for pressure to correct divergence

• Correspond to elastic and damping forces

Page 43: Methods for the Physically Based Simulation of Solids and Fluids Geoffrey Irving Stanford University May 16, 2007

Volume correctionVolume correction

• Add volume correction to position step

• Set final volume equal to rest volume

Page 44: Methods for the Physically Based Simulation of Solids and Fluids Geoffrey Irving Stanford University May 16, 2007

Volume correctionVolume correction

• Want to linearize

• Time derivative of volume is divergence:

• Linearization is

• div is integrated divergence

Page 45: Methods for the Physically Based Simulation of Solids and Fluids Geoffrey Irving Stanford University May 16, 2007

Volume correctionVolume correction

• Volume correction is gradient of pressure

• Gives Poisson equation for pressure

• Solve with conjugate gradient

Page 46: Methods for the Physically Based Simulation of Solids and Fluids Geoffrey Irving Stanford University May 16, 2007

Volume correctionVolume correction

• All volume error corrected in one step

• O(x) errors give O(1) values of x

• Do not use x to update v!

Page 47: Methods for the Physically Based Simulation of Solids and Fluids Geoffrey Irving Stanford University May 16, 2007

Divergence correctionDivergence correction

• Once volume error is removed, adjust velocity to avoid future change

• Same as before except no volume term

• This is a pure projection

Page 48: Methods for the Physically Based Simulation of Solids and Fluids Geoffrey Irving Stanford University May 16, 2007

OutlineOutline

• Time Discretization

• Spatial Discretization

• Collisions and Contact

• Discussion and Results

Page 49: Methods for the Physically Based Simulation of Solids and Fluids Geoffrey Irving Stanford University May 16, 2007

Volumetric lockingVolumetric locking

• Obvious approach: preserve volume of each tetrahedron

• This approach fails

– Mesh has N nodes, 4-5N tetrahedra

– 3N degrees of freedom

– At least 4N constraints

– 4N > 3N

– Excessive artificial stiffness

Page 50: Methods for the Physically Based Simulation of Solids and Fluids Geoffrey Irving Stanford University May 16, 2007

Volumetric lockingVolumetric locking

Poisson’s ratio 0.3, volume forces per-tetrahedron

Page 51: Methods for the Physically Based Simulation of Solids and Fluids Geoffrey Irving Stanford University May 16, 2007

Volumetric lockingVolumetric locking

Poisson’s ratio 0.499, volume forces per-tetrahedron

Page 52: Methods for the Physically Based Simulation of Solids and Fluids Geoffrey Irving Stanford University May 16, 2007

One-rings: no lockingOne-rings: no locking

• Could use higher order elements

– Loses simplicity

• Instead, just preserve volume at each node

– 3N degrees of freedom

– N constraints

– No locking

Page 53: Methods for the Physically Based Simulation of Solids and Fluids Geoffrey Irving Stanford University May 16, 2007

One-rings: no lockingOne-rings: no locking

Poisson’s ratio 0.5, volume preserved per one-ring

Page 54: Methods for the Physically Based Simulation of Solids and Fluids Geoffrey Irving Stanford University May 16, 2007

Spatial discretizationSpatial discretization

• Poisson equation is

• Need to define V, div, grad

Page 55: Methods for the Physically Based Simulation of Solids and Fluids Geoffrey Irving Stanford University May 16, 2007

DivergenceDivergence

• Measuring one-ring volume is easy

• Define volume-weighted divergence as the gradient of the volume function

• Equivalent to integrating pointwise divergence over each one-ring

Page 56: Methods for the Physically Based Simulation of Solids and Fluids Geoffrey Irving Stanford University May 16, 2007

GradientGradient

• Can’t define gradient with volume integral

– Single tetrahedron would have constant gradient

– Wrong boundary conditions

– Violates momentum conservation

• Instead, define

– div maps velocity to pressure

– grad maps pressure to velocity

• Results in symmetric linear systems

Page 57: Methods for the Physically Based Simulation of Solids and Fluids Geoffrey Irving Stanford University May 16, 2007

OutlineOutline

• Time Discretization

• Spatial Discretization

• Collisions and Contact

• Discussion and Results

Page 58: Methods for the Physically Based Simulation of Solids and Fluids Geoffrey Irving Stanford University May 16, 2007

The problemThe problem

• Incompressibility is infinitely strong

• Collisions are infinitely stronger

• Volume correction tries to cause large interpenetration every time step

• Self-collisions fight back…

• …Jagged, tangled surfaces

Page 59: Methods for the Physically Based Simulation of Solids and Fluids Geoffrey Irving Stanford University May 16, 2007

Contact constraintsContact constraints

• Make pressure forces collision-aware

• Projection matrix P removes normal component of velocity at each contact

• New pressure solves coupled between colliding objects

Page 60: Methods for the Physically Based Simulation of Solids and Fluids Geoffrey Irving Stanford University May 16, 2007

Contact constraintsContact constraints

• Particle-object, point-triangle, edge-edge

• Common form:

Page 61: Methods for the Physically Based Simulation of Solids and Fluids Geoffrey Irving Stanford University May 16, 2007

Enforcing contact constraintsEnforcing contact constraints

• Projecting out one normal component is easy

• N constraints CT v = 0 hard

• Need to invert NxN matrix CT M-1 C

• Much too slow for every CG iteration

Page 62: Methods for the Physically Based Simulation of Solids and Fluids Geoffrey Irving Stanford University May 16, 2007

Gauss-SeidelGauss-Seidel

• Luckily, don’t need exact answer

• A few Gauss-Seidel sweeps is sufficient

• But Gauss-Seidel breaks symmetry

– don’t commute

– Can’t use in CG

Page 63: Methods for the Physically Based Simulation of Solids and Fluids Geoffrey Irving Stanford University May 16, 2007

Symmetric Gauss-SeidelSymmetric Gauss-Seidel

• Solution: alternate sweeps

• Symmetric even if it doesn’t converge

• 4 iterations sufficed

• Fast enough for use inside CG

Page 64: Methods for the Physically Based Simulation of Solids and Fluids Geoffrey Irving Stanford University May 16, 2007

OutlineOutline

• Time Discretization

• Spatial Discretization

• Collisions and Contact

• Discussion and Results

Page 65: Methods for the Physically Based Simulation of Solids and Fluids Geoffrey Irving Stanford University May 16, 2007

Results: varying stiffnessResults: varying stiffness

High stiffness

Page 66: Methods for the Physically Based Simulation of Solids and Fluids Geoffrey Irving Stanford University May 16, 2007

Results: varying stiffnessResults: varying stiffness

Medium stiffness

Page 67: Methods for the Physically Based Simulation of Solids and Fluids Geoffrey Irving Stanford University May 16, 2007

Results: varying stiffnessResults: varying stiffness

Low stiffness

Page 68: Methods for the Physically Based Simulation of Solids and Fluids Geoffrey Irving Stanford University May 16, 2007

Results: rigid body collisionsResults: rigid body collisions

Page 69: Methods for the Physically Based Simulation of Solids and Fluids Geoffrey Irving Stanford University May 16, 2007

Results: self-collisionsResults: self-collisions

Page 70: Methods for the Physically Based Simulation of Solids and Fluids Geoffrey Irving Stanford University May 16, 2007

SingularitiesSingularities

• Pressure matrix not always positive definite

• Too many collisions can cause singularities

• Solution: use MINRES instead of CG

• Doesn’t require definiteness

• Stable for large examples

Page 71: Methods for the Physically Based Simulation of Solids and Fluids Geoffrey Irving Stanford University May 16, 2007

Results: 100 toriResults: 100 tori

Page 72: Methods for the Physically Based Simulation of Solids and Fluids Geoffrey Irving Stanford University May 16, 2007

ConclusionsConclusions

• Keep simplicity of constant strain tetrahedra

• Enforce volume preservation per node

– Avoids locking

• Separate treatment of volume and divergence

– Position errors don’t cause huge velocities

• Make pressure solve collision aware

– Symmetric Gauss-Seidel usable inside MINRES

Page 73: Methods for the Physically Based Simulation of Solids and Fluids Geoffrey Irving Stanford University May 16, 2007

Efficient Simulation of Large Bodies of Water by Coupling Two and Three Dimensional Techniques

Efficient Simulation of Large Bodies of Water by Coupling Two and Three Dimensional Techniques

with Eran Guendelman,

Frank Losasso, and Ron Fedkiw

Page 74: Methods for the Physically Based Simulation of Solids and Fluids Geoffrey Irving Stanford University May 16, 2007

MotivationMotivation

• Large scale water phenomena important

– Rivers, lakes, oceans, floods

• Fast option: height field methods

– Nice wave propagation

– Can’t handle overturning

• Accurate option: 3D Navier Stokes

– Captures three dimensional behavior

– Slow at high resolutions: O(N4)

Page 75: Methods for the Physically Based Simulation of Solids and Fluids Geoffrey Irving Stanford University May 16, 2007

Solution: use bothSolution: use both

• Uniform 3D Navier-Stokes near interface

• Coarsen elsewhere using tall cells

uniform

uniformtall cells

tall cells

Page 76: Methods for the Physically Based Simulation of Solids and Fluids Geoffrey Irving Stanford University May 16, 2007

Solution: use bothSolution: use both

Page 77: Methods for the Physically Based Simulation of Solids and Fluids Geoffrey Irving Stanford University May 16, 2007

Related work: 2DRelated work: 2D

• Deep water

– Fournier and Reeves 1986, Peachy 1986

– Recent: Thon et al. 2000, Hinsinger 2002

• Shallow Water

– Kass and Miller 1990, O’Brien and Hodgins 1995

• Rivers and streams

– Chen and Lobo 1994, Thon and Ghazanfarpour 2001

Page 78: Methods for the Physically Based Simulation of Solids and Fluids Geoffrey Irving Stanford University May 16, 2007

Related work: 3DRelated work: 3D

• Uniform Navier-Stokes water

– Foster and Metaxas 1997, Foster and Fedkiw 2001

– Enright et. al 2002: Particle level set method

• Large bodies of water

– Takahashi et al. 2003: spray and foam

– Mihalef et al. 2004: breaking waves

• Adaptive simulation

– Losasso et al. 2004: Octree grids

– Houston et al. 2006: Run-Length Encoded (RLE) grids

Page 79: Methods for the Physically Based Simulation of Solids and Fluids Geoffrey Irving Stanford University May 16, 2007

Why height fields workWhy height fields work

• Water likes to stay flat

• Only water-air interface is visible

• Vertical structure simpler than horizontal

Page 80: Methods for the Physically Based Simulation of Solids and Fluids Geoffrey Irving Stanford University May 16, 2007

Mixing height fields and 3DMixing height fields and 3D

• Specify “optical depth” where we expect turbulent motion

• Use uniform 3D cells within optical depth

• Use height field model elsewhere

optical depthoptical depth

Page 81: Methods for the Physically Based Simulation of Solids and Fluids Geoffrey Irving Stanford University May 16, 2007

OutlineOutline

• Grid structure

• Uniform solver

• Advection on tall cells

• Pressure solver on tall cells

• Parallel implementation

• Discussion and Results

Page 82: Methods for the Physically Based Simulation of Solids and Fluids Geoffrey Irving Stanford University May 16, 2007

OutlineOutline

• Grid structure

• Uniform solver

• Advection on tall cells

• Pressure solver on tall cells

• Parallel implementation

• Discussion and Results

Page 83: Methods for the Physically Based Simulation of Solids and Fluids Geoffrey Irving Stanford University May 16, 2007

Grid structureGrid structure

• Start with uniform MAC grid

• Keep cells within optical depth of the interface

• Outside optical depth, merge vertical sequences of cells into single tall cells

Page 84: Methods for the Physically Based Simulation of Solids and Fluids Geoffrey Irving Stanford University May 16, 2007

Grid structure: storing valuesGrid structure: storing values

• Start with MAC grid storage

– Level set values in cell centers near interface

– Pressure values in cell centers

– Velocity components on corresponding faces

Page 85: Methods for the Physically Based Simulation of Solids and Fluids Geoffrey Irving Stanford University May 16, 2007

Grid structure: pressureGrid structure: pressure

• Two pressure samples per tall cell

• Linear interpolation between

• Allows

Page 86: Methods for the Physically Based Simulation of Solids and Fluids Geoffrey Irving Stanford University May 16, 2007

Grid structure: velocityGrid structure: velocity

• Velocity corresponds to pressure gradients

Horizontal velocity (u and w) Vertical velocity (v)

Page 87: Methods for the Physically Based Simulation of Solids and Fluids Geoffrey Irving Stanford University May 16, 2007

Grid structure: velocityGrid structure: velocity

• Velocity corresponds to pressure gradients

Horizontal velocity (u and w) Vertical velocity (v)

Page 88: Methods for the Physically Based Simulation of Solids and Fluids Geoffrey Irving Stanford University May 16, 2007

Refinement and coarseningRefinement and coarsening

• Grid is rebuilt whenever fluid moves based on current level set

• Linear time (Houston et al. 2006)

• Velocity must be transferred to new grid

– optionally transfer pressure as initial guess

Page 89: Methods for the Physically Based Simulation of Solids and Fluids Geoffrey Irving Stanford University May 16, 2007

Transferring velocityTransferring velocity

Interpolate Least squares

• Main criterion: conserve momentum

Page 90: Methods for the Physically Based Simulation of Solids and Fluids Geoffrey Irving Stanford University May 16, 2007

Transferring velocity (cont)Transferring velocity (cont)

• Interpolate:

• Least squares:

Page 91: Methods for the Physically Based Simulation of Solids and Fluids Geoffrey Irving Stanford University May 16, 2007

OutlineOutline

• Grid structure

• Uniform solver

• Advection on tall cells

• Pressure solver on tall cells

• Parallel implementation

• Discussion and Results

Page 92: Methods for the Physically Based Simulation of Solids and Fluids Geoffrey Irving Stanford University May 16, 2007

Uniform solverUniform solver

• Navier-Stokes equations for velocity:

• Level set equation:

• Standard uniform MAC grid within uniform band

• Level set exists only in uniform cells

Page 93: Methods for the Physically Based Simulation of Solids and Fluids Geoffrey Irving Stanford University May 16, 2007

Uniform solver (cont)Uniform solver (cont)

• Advect velocity and add gravity

– use semi-Lagrangian for uniform cells (Stam 1999)

• Solve Laplace equation for pressure

• Apply pressure correction to velocity

Page 94: Methods for the Physically Based Simulation of Solids and Fluids Geoffrey Irving Stanford University May 16, 2007

OutlineOutline

• Grid structure

• Uniform solver

• Advection on tall cells

• Pressure solver on tall cells

• Parallel implementation

• Discussion and Results

Page 95: Methods for the Physically Based Simulation of Solids and Fluids Geoffrey Irving Stanford University May 16, 2007

Tall cell advectionTall cell advection

• Can’t use semi-Lagrangian for tall cells

• Use conservative method for plausible motion

• Simplest option: first order upwinding

Ignored by semi-Lagrangian

Page 96: Methods for the Physically Based Simulation of Solids and Fluids Geoffrey Irving Stanford University May 16, 2007

First order upwinding (uniform)First order upwinding (uniform)

Average to controlvolume face

Compute flux basedon upwind velocity

Adjust velocitiesbased on flux

Page 97: Methods for the Physically Based Simulation of Solids and Fluids Geoffrey Irving Stanford University May 16, 2007

First order upwinding (tall cells)First order upwinding (tall cells)

• Pretend to do the following

– Refine to uniform grid

– Advect

– Coarsen back to original grid

• Simulate this by applying least squares directly to uniform discretization

• Same answer but faster

Page 98: Methods for the Physically Based Simulation of Solids and Fluids Geoffrey Irving Stanford University May 16, 2007

Advection issuesAdvection issues

• Occasional instabilities near steep terrain

• Fix by clamping to affine combination

Page 99: Methods for the Physically Based Simulation of Solids and Fluids Geoffrey Irving Stanford University May 16, 2007

OutlineOutline

• Grid structure

• Uniform solver

• Advection on tall cells

• Pressure solver on tall cells

• Parallel implementation

• Discussion and Results

Page 100: Methods for the Physically Based Simulation of Solids and Fluids Geoffrey Irving Stanford University May 16, 2007

Pressure solve on tall cellsPressure solve on tall cells

• Pressure projection is

• Need to define two operations:

– Gradient (pressure to velocity)

– Divergence (velocity to pressure)

Page 101: Methods for the Physically Based Simulation of Solids and Fluids Geoffrey Irving Stanford University May 16, 2007

Pressure solve: gradientPressure solve: gradient

• Gradient is easy:

Page 102: Methods for the Physically Based Simulation of Solids and Fluids Geoffrey Irving Stanford University May 16, 2007

Pressure solve: divergencePressure solve: divergence

Page 103: Methods for the Physically Based Simulation of Solids and Fluids Geoffrey Irving Stanford University May 16, 2007

Pressure solve: LaplacianPressure solve: Laplacian

• Compose divergence and gradient to get linear system

• Symmetric and positive definite since we used the same weights in both

• Solve using preconditioned conjugate gradients

Page 104: Methods for the Physically Based Simulation of Solids and Fluids Geoffrey Irving Stanford University May 16, 2007

OutlineOutline

• Grid structure

• Uniform solver

• Advection on tall cells

• Pressure solver on tall cells

• Parallel implementation

• Discussion and Results

Page 105: Methods for the Physically Based Simulation of Solids and Fluids Geoffrey Irving Stanford University May 16, 2007

• Parallelize only along horizontal dimensions

– No harder than parallelizing a uniform code

– Vertical dimension already cheap

• Exchange data with neighbors every step

• Solve for pressure on all processors globally

Parallel implementationParallel implementation

Page 106: Methods for the Physically Based Simulation of Solids and Fluids Geoffrey Irving Stanford University May 16, 2007

Results: splash (300 x 200)Results: splash (300 x 200)

Optical depth equal to water depth

Page 107: Methods for the Physically Based Simulation of Solids and Fluids Geoffrey Irving Stanford University May 16, 2007

Results: splash (300 x 200)Results: splash (300 x 200)

Optical depth 1/4th water depth

Page 108: Methods for the Physically Based Simulation of Solids and Fluids Geoffrey Irving Stanford University May 16, 2007

Results: splash (300 x 200)Results: splash (300 x 200)

fully refined 1/4th refined

Page 109: Methods for the Physically Based Simulation of Solids and Fluids Geoffrey Irving Stanford University May 16, 2007

Results: splash (300 x 200)Results: splash (300 x 200)

Optical depth 1/16th water depth

Page 110: Methods for the Physically Based Simulation of Solids and Fluids Geoffrey Irving Stanford University May 16, 2007

Results: deep splashResults: deep splash

Water depth doubled

Page 111: Methods for the Physically Based Simulation of Solids and Fluids Geoffrey Irving Stanford University May 16, 2007

Results: boat (1500 x 300)Results: boat (1500 x 300)

Vortex particles from Selle et al. 2005

Page 112: Methods for the Physically Based Simulation of Solids and Fluids Geoffrey Irving Stanford University May 16, 2007

Matching bottom topographyMatching bottom topography

• Tall cells match ground for free

• Octrees would require extra refinement

• Less important in very deep water

Page 113: Methods for the Physically Based Simulation of Solids and Fluids Geoffrey Irving Stanford University May 16, 2007

Results: river (2000 x 200)Results: river (2000 x 200)

Page 114: Methods for the Physically Based Simulation of Solids and Fluids Geoffrey Irving Stanford University May 16, 2007

Results: river (2000 x 200)Results: river (2000 x 200)

Page 115: Methods for the Physically Based Simulation of Solids and Fluids Geoffrey Irving Stanford University May 16, 2007

Comparison with octreesComparison with octrees

• Advantages over octrees:

– Easy to parallelize

– Reduces to MAC discretization with refinement

– Matches bottom topography for free

• Main disadvantage: relies on vertical simplicity for efficiency

• Not applicable for all flows

– rising bubbles, colliding droplets, etc.

Page 116: Methods for the Physically Based Simulation of Solids and Fluids Geoffrey Irving Stanford University May 16, 2007

ConclusionConclusion

• Want high resolution near interface

– Uniform interface resolution sufficient

• Plausible bulk motion enough elsewhere

• Many flows have simple vertical structure

• Use this to create hybrid 2D/3D method

Page 117: Methods for the Physically Based Simulation of Solids and Fluids Geoffrey Irving Stanford University May 16, 2007

Future workFuture work

• Improved advection scheme

– Match ENO/WENO schemes for shallow water

• Better parallelism

– Remove global linear system solve

• Find optimal adaptive structure

– Hybrid RLE / octree grid?

Page 118: Methods for the Physically Based Simulation of Solids and Fluids Geoffrey Irving Stanford University May 16, 2007

AcknowledgementsAcknowledgements

• Weronika

• Ron Fedkiw

• My committee: Adrian Lew, Leo Guibas, Matt West, Michael Kass

• Co-authors:

Joey Teran, Eftychis Sifakis, Frank Losasso, Eran Guendelman

Craig Schroeder, Tamar Shinar, Andrew Selle, Jonathan Su

• Stanford Physically-Based Modeling group

Neil, Josh, Igor, Duc, Fred, Sergey, Rachel, Avi, Jerry, Nipun

• Pixar Research Group

John Anderson, Tony DeRose, Michael Kass, Andy Witkin, Mark Meyer

• Funding agencies

– NSF, ONR, ARO, Packard and Sloan Foundations

Page 119: Methods for the Physically Based Simulation of Solids and Fluids Geoffrey Irving Stanford University May 16, 2007

The EndThe End

Questions?