Methods for the Physically Based Simulation of Solids and Fluids Geoffrey Irving Stanford University May 16, 2007
Outline 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 Deformation with Joseph Teran and Ron Fedkiw
Goal: 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 work Mass-spring systems: – Palmerio psuedopressure term – Cooper 1997, Molino 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? 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 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.).
Example
Outline State of each tetrahedron given by deformation gradient F (3x3 matrix). Diagonalize F to remove rotations: F = UF D V T Use first Piola-Kirchhoff stress: P = UP D V T Forces on nodes are linear in P: G = PB m
Deformation Gradient: F Maps vectors in material space to world space. deformed (world coordinates) undeformed (material coordinates)
Standard approach: Green Strain We could write stress in terms of Green strain 1/2(F T F-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 F Isotropic materials are invariant under rotations of material and world space, but not under reflections. Standard SVD gives F = UF D V T with – V a pure rotation – U a pure rotation or a reflection – Diagonal F D with all positive entries If U is a reflection, we negate an entry of F D and the corresponding column of U. Heuristic: choose smallest entry of F D to make tetrahedron recover as quickly as possible.
Diagonalization of F SVD must be robust to zero or duplicate singular values.
First Piola-Kirchhoff Stress For an isotropic model, diagonal F D gives a diagonal stress P D. Can consider one stress component at a time. St. Venant-Kirchhoff useless for large compression.
First Piola-Kirchhoff Stress Better models have a singularity at the origin Adds severe stiffness Still dies if numerical errors cause inversion.
First 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 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 Computation Given a correct diagonal stress P D, the forces can be computed as G = PB m = UP D V T B m B m 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 physical continuous deformation by grey colored object discrete version illustrates element inversion
Results Elastic sphere compressed between two gears.
Results Buddha model compressed between two gears.
Results Buddha model colliding with kinematic sphere.
Damping 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: anisotropy Anisotropic constitutive model for muscles.
Plasticity We use multiplicative plasticity: F = F e F p Elastic forces computed from elastic deformation F e. Plastic deformation F p clamped away from inversion to ensure robustness. Plasticity can be controlled by accepting only deformations that move towards a target shape.
Results: plasticity Plastic sphere controlled towards a disk shape.
Results: plasticity A more obvious example of plasticity control
Results: plasticity Plastic shell compressed between two gears.
Generalization 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: hexahedra Hexahedral mesh collapsing into a puddle.
Conclusions 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 Models with Craig Schroeder and Ron Fedkiw
Motivation Virtual humans increasingly important – Stunt doubles – Virtual surgery Most biological tissues incompressible – Muscles, skin, fat Volume preservation is local – Conserving total volume insufficient
Motivation 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 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 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
Example
Previous 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 setup Start with linear tetrahedral elements – Position, velocity located at each node – Elastic forces computed per tetrahedron Preserve volume of each one-ring
Outline Time Discretization Spatial Discretization Collisions and Contact Discussion and Results
Outline Time Discretization Spatial Discretization Collisions and Contact Discussion and Results
Time 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 correction Add volume correction to position step Set final volume equal to rest volume
Volume correction Want to linearize Time derivative of volume is divergence: Linearization is div is integrated divergence
Volume correction Volume correction is gradient of pressure Gives Poisson equation for pressure Solve with conjugate gradient
Volume 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 correction Once volume error is removed, adjust velocity to avoid future change Same as before except no volume term This is a pure projection
Outline Time Discretization Spatial Discretization Collisions and Contact Discussion and Results
Volumetric 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 locking Poisson’s ratio 0.3, volume forces per-tetrahedron
Volumetric locking Poisson’s ratio 0.499, volume forces per-tetrahedron
One-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 locking Poisson’s ratio 0.5, volume preserved per one-ring
Spatial discretization Poisson equation is Need to define V, div, grad
Divergence 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
Gradient 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
Outline Time Discretization Spatial Discretization Collisions and Contact Discussion and Results
The 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 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 constraints Particle-object, point-triangle, edge-edge Common form:
Enforcing contact constraints Projecting out one normal component is easy N constraints C T v = 0 hard Need to invert NxN matrix C T M -1 C Much too slow for every CG iteration
Gauss-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-Seidel Solution: alternate sweeps Symmetric even if it doesn’t converge 4 iterations sufficed Fast enough for use inside CG
Outline Time Discretization Spatial Discretization Collisions and Contact Discussion and Results
Results: varying stiffness High stiffness
Results: varying stiffness Medium stiffness
Results: varying stiffness Low stiffness
Results: rigid body collisions
Results: self-collisions
Singularities 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 tori
Conclusions 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 with Eran Guendelman, Frank Losasso, and Ron Fedkiw
Motivation 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(N 4 )
Solution: use both Uniform 3D Navier-Stokes near interface Coarsen elsewhere using tall cells uniform tall cells
Solution: use both
Related 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: 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 work Water likes to stay flat Only water-air interface is visible Vertical structure simpler than horizontal
Mixing 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 depth
Outline Grid structure Uniform solver Advection on tall cells Pressure solver on tall cells Parallel implementation Discussion and Results
Outline Grid structure Uniform solver Advection on tall cells Pressure solver on tall cells Parallel implementation Discussion and Results
Grid 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 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: pressure Two pressure samples per tall cell Linear interpolation between Allows
Grid structure: velocity Velocity corresponds to pressure gradients Horizontal velocity (u and w)Vertical velocity (v)
Grid structure: velocity Velocity corresponds to pressure gradients Horizontal velocity (u and w)Vertical velocity (v)
Refinement 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 velocity InterpolateLeast squares Main criterion: conserve momentum
Transferring velocity (cont) Interpolate: Least squares:
Outline Grid structure Uniform solver Advection on tall cells Pressure solver on tall cells Parallel implementation Discussion and Results
Uniform 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) Advect velocity and add gravity – use semi-Lagrangian for uniform cells (Stam 1999) Solve Laplace equation for pressure Apply pressure correction to velocity
Outline Grid structure Uniform solver Advection on tall cells Pressure solver on tall cells Parallel implementation Discussion and Results
Tall 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) Average to control volume face Compute flux based on upwind velocity Adjust velocities based on flux
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 issues Occasional instabilities near steep terrain Fix by clamping to affine combination
Outline Grid structure Uniform solver Advection on tall cells Pressure solver on tall cells Parallel implementation Discussion and Results
Pressure solve on tall cells Pressure projection is Need to define two operations: – Gradient (pressure to velocity) – Divergence (velocity to pressure)
Pressure solve: gradient Gradient is easy:
Pressure solve: divergence
Pressure 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
Outline 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 implementation
Results: splash (300 x 200) Optical depth equal to water depth
Results: splash (300 x 200) Optical depth 1/4 th water depth
Results: splash (300 x 200) fully refined 1/4 th refined
Results: splash (300 x 200) Optical depth 1/16 th water depth
Results: deep splash Water depth doubled
Results: boat (1500 x 300) Vortex particles from Selle et al. 2005
Matching bottom topography Tall cells match ground for free Octrees would require extra refinement Less important in very deep water
Results: river (2000 x 200)
Comparison 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.
Conclusion 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 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?
Acknowledgements 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 End Questions?