methods for the physically based simulation of solids and fluids geoffrey irving stanford university...
TRANSCRIPT
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
OutlineOutline
• Three topics
– Robust finite element simulation
– Incompressible deformable solids
– Large scale water simulation
• Solids go first so I get more questions
Invertible Finite Elements for Robust Simulation of Large DeformationInvertible Finite Elements for Robust Simulation of Large Deformation
with Joseph Teran and Ron Fedkiw
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.
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
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.
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.).
ExampleExample
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
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
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.
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.
Diagonalization of FDiagonalization of F
SVD must be robust to zero or duplicate singular values.
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.
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.
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.
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.
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.
Element inversion is physicalElement inversion is physical
F continuous deformation by grey colored object
discrete version illustrates element inversion
ResultsResults
Elastic sphere compressed between two gears.
ResultsResults
Buddha model compressed between two gears.
ResultsResults
Buddha model colliding with kinematic sphere.
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.
Results: anisotropyResults: anisotropy
Anisotropic constitutive model for muscles.
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.
Results: plasticityResults: plasticity
Plastic sphere controlled towards a disk shape.
Results: plasticityResults: plasticity
A more obvious example of plasticity control
Results: plasticityResults: plasticity
Plastic shell compressed between two gears.
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.
Results: hexahedraResults: hexahedra
Hexahedral mesh collapsing into a puddle.
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.
Volume Preserving Finite Element Simulations of Deformation ModelsVolume Preserving Finite Element Simulations of Deformation Models
with Craig Schroeder and Ron Fedkiw
MotivationMotivation
• Virtual humans increasingly important
– Stunt doubles
– Virtual surgery
• Most biological tissues incompressible
– Muscles, skin, fat
• Volume preservation is local
– Conserving total volume insufficient
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.”
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)
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
ExampleExample
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
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
OutlineOutline
• Time Discretization
• Spatial Discretization
• Collisions and Contact
• Discussion and Results
OutlineOutline
• Time Discretization
• Spatial Discretization
• Collisions and Contact
• Discussion and Results
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
Volume correctionVolume correction
• Add volume correction to position step
• Set final volume equal to rest volume
Volume correctionVolume correction
• Want to linearize
• Time derivative of volume is divergence:
• Linearization is
• div is integrated divergence
Volume correctionVolume correction
• Volume correction is gradient of pressure
• Gives Poisson equation for pressure
• Solve with conjugate gradient
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!
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
OutlineOutline
• Time Discretization
• Spatial Discretization
• Collisions and Contact
• Discussion and Results
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
Volumetric lockingVolumetric locking
Poisson’s ratio 0.3, volume forces per-tetrahedron
Volumetric lockingVolumetric locking
Poisson’s ratio 0.499, volume forces per-tetrahedron
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
One-rings: no lockingOne-rings: no locking
Poisson’s ratio 0.5, volume preserved per one-ring
Spatial discretizationSpatial discretization
• Poisson equation is
• Need to define V, div, grad
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
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
OutlineOutline
• Time Discretization
• Spatial Discretization
• Collisions and Contact
• Discussion and Results
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
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
Contact constraintsContact constraints
• Particle-object, point-triangle, edge-edge
• Common form:
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
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
Symmetric Gauss-SeidelSymmetric Gauss-Seidel
• Solution: alternate sweeps
• Symmetric even if it doesn’t converge
• 4 iterations sufficed
• Fast enough for use inside CG
OutlineOutline
• Time Discretization
• Spatial Discretization
• Collisions and Contact
• Discussion and Results
Results: varying stiffnessResults: varying stiffness
High stiffness
Results: varying stiffnessResults: varying stiffness
Medium stiffness
Results: varying stiffnessResults: varying stiffness
Low stiffness
Results: rigid body collisionsResults: rigid body collisions
Results: self-collisionsResults: self-collisions
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
Results: 100 toriResults: 100 tori
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
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
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)
Solution: use bothSolution: use both
• Uniform 3D Navier-Stokes near interface
• Coarsen elsewhere using tall cells
uniform
uniformtall cells
tall cells
Solution: use bothSolution: use both
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
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
Why height fields workWhy height fields work
• Water likes to stay flat
• Only water-air interface is visible
• Vertical structure simpler than horizontal
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
OutlineOutline
• Grid structure
• Uniform solver
• Advection on tall cells
• Pressure solver on tall cells
• Parallel implementation
• Discussion and Results
OutlineOutline
• Grid structure
• Uniform solver
• Advection on tall cells
• Pressure solver on tall cells
• Parallel implementation
• Discussion and Results
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
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
Grid structure: pressureGrid structure: pressure
• Two pressure samples per tall cell
• Linear interpolation between
• Allows
Grid structure: velocityGrid structure: velocity
• Velocity corresponds to pressure gradients
Horizontal velocity (u and w) Vertical velocity (v)
Grid structure: velocityGrid structure: velocity
• Velocity corresponds to pressure gradients
Horizontal velocity (u and w) Vertical velocity (v)
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
Transferring velocityTransferring velocity
Interpolate Least squares
• Main criterion: conserve momentum
Transferring velocity (cont)Transferring velocity (cont)
• Interpolate:
• Least squares:
OutlineOutline
• Grid structure
• Uniform solver
• Advection on tall cells
• Pressure solver on tall cells
• Parallel implementation
• Discussion and Results
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
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
OutlineOutline
• Grid structure
• Uniform solver
• Advection on tall cells
• Pressure solver on tall cells
• Parallel implementation
• Discussion and Results
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
First order upwinding (uniform)First order upwinding (uniform)
Average to controlvolume face
Compute flux basedon upwind velocity
Adjust velocitiesbased on flux
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
Advection issuesAdvection issues
• Occasional instabilities near steep terrain
• Fix by clamping to affine combination
OutlineOutline
• Grid structure
• Uniform solver
• Advection on tall cells
• Pressure solver on tall cells
• Parallel implementation
• Discussion and Results
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)
Pressure solve: gradientPressure solve: gradient
• Gradient is easy:
Pressure solve: divergencePressure solve: divergence
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
OutlineOutline
• Grid structure
• Uniform solver
• Advection on tall cells
• Pressure solver on tall cells
• Parallel implementation
• Discussion and Results
• 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
Results: splash (300 x 200)Results: splash (300 x 200)
Optical depth equal to water depth
Results: splash (300 x 200)Results: splash (300 x 200)
Optical depth 1/4th water depth
Results: splash (300 x 200)Results: splash (300 x 200)
fully refined 1/4th refined
Results: splash (300 x 200)Results: splash (300 x 200)
Optical depth 1/16th water depth
Results: deep splashResults: deep splash
Water depth doubled
Results: boat (1500 x 300)Results: boat (1500 x 300)
Vortex particles from Selle et al. 2005
Matching bottom topographyMatching bottom topography
• Tall cells match ground for free
• Octrees would require extra refinement
• Less important in very deep water
Results: river (2000 x 200)Results: river (2000 x 200)
Results: river (2000 x 200)Results: river (2000 x 200)
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.
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
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?
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
The EndThe End
Questions?