View
239
Download
1
Tags:
Embed Size (px)
Citation preview
computer graphics & visualization
Simulation and Animation
Soft Body Simulation
computer graphics & visualization
Simulation and Animation – SS07Jens Krüger – Computer Graphics and Visualization Group
MotivationApplications of Deformable Objects
• Entertainment– Movies
• Pixar: Shrek, Nemo, The Incredibles…– Computer games
• Virtual simulator– Medicine
• Surgery, therapy, registration – Computational science
• Buildings, bridges
computer graphics & visualization
Simulation and Animation – SS07Jens Krüger – Computer Graphics and Visualization Group
Deformation Models• The first physically realistic model was introduced to
computer graphics in 1987• Mathematically deformation can be described as a
time-varying vector valued function F(x, t)
x is the material coordinateF is the world coordinateu is the displacement vector
computer graphics & visualization
Simulation and Animation – SS07Jens Krüger – Computer Graphics and Visualization Group
Dynamic SimulationsLagrange Equation of Motion:
External forces are in equilibrium with internal forces composed of elastic force, damping force and acceleration force.
uMuCuKF K : Stiffness
C : Damping
M : Mass
computer graphics & visualization
Simulation and Animation – SS07Jens Krüger – Computer Graphics and Visualization Group
Mass-Spring systemsBody is modeled by masses linearly linked by springs with freely rotation springs.
computer graphics & visualization
Simulation and Animation – SS07Jens Krüger – Computer Graphics and Visualization Group
Mass-spring simulation• Spring Link
– Edge = spring– Vertex = mass– Hooke´s law– Scalar Spring stiffness D
l
lllDFi 0
0l
l
1F 2F
computer graphics & visualization
Simulation and Animation – SS07Jens Krüger – Computer Graphics and Visualization Group
Mass-spring simulation• Volume preservation
– Introduce volume forces– Scalar Volume stiffness Dv
FiFv
Fi
Fi
computer graphics & visualization
Simulation and Animation – SS07Jens Krüger – Computer Graphics and Visualization Group
Time Integration• Verlet Integration (per vertex) – explicit scheme
– Easy & fast
• Numerical accuracy is critical– Timesteps have to be small (explicit scheme)
Faster accumulation of rounding errors– Damping necessary
computer graphics & visualization
Simulation and Animation – SS07Jens Krüger – Computer Graphics and Visualization Group
Algorithm
Forever// Force calculationfor every vertex
calculate forceendfor
// Time integrationfor every vertex
update positionendfor
endfor
Positions
Forces
computer graphics & visualization
Simulation and Animation – SS07Jens Krüger – Computer Graphics and Visualization Group
Mass-Spring systems• Body is modeled by masses
linearly linked by springs• Advantage:
– Simple
• Disadvantages:– Realistic physical properties
difficult to model– Unstable Explicit Integration
for stiff materials
computer graphics & visualization
Simulation and Animation – SS07Jens Krüger – Computer Graphics and Visualization Group
Excursion
• Mass- Spring On the GPU
computer graphics & visualization
Simulation and Animation – SS07Jens Krüger – Computer Graphics and Visualization Group
Data structures
• How to store per-vertex adjacency information?– Incident Edges
• Calculation of volume forces problematic
– Incident tetrahedra• Calculation of spring and volume forces
– Store tetrahedra (edges) directly(not only indices into a shared edge/tetrahedra list)
• Memory consuming, but avoids additional dependency level
• Disadvantages– Tetrahedra are stored multiple times– #Neighbors is not constant
computer graphics & visualization
Simulation and Animation – SS07Jens Krüger – Computer Graphics and Visualization Group
Data structures (cont.)
computer graphics & visualization
Simulation and Animation – SS07Jens Krüger – Computer Graphics and Visualization Group
Data structures (cont.)• Sort vertices according
to their valence
• Stack of textures thatgets smaller to the top
• Reduces memory overhead
• Further optimization– Early z-test
computer graphics & visualization
Simulation and Animation – SS07Jens Krüger – Computer Graphics and Visualization Group
Force calculationfor every point p0
for every tetrahedron t incident on p0
// via four texture fetchesget center vertex coordinate p0get corner indices i1-3, get element stiffness esget rest spring lengths l1-3, get rest volume v
// via three dependent fetchesget coordinates of p1-3 through i1-3
calculate force on p0add to total force on p0
endforendfor
computer graphics & visualization
Simulation and Animation – SS07Jens Krüger – Computer Graphics and Visualization Group
Results
computer graphics & visualization
Simulation and Animation – SS07Jens Krüger – Computer Graphics and Visualization Group
Finite Stuff…
• FDM and FEM
computer graphics & visualization
Simulation and Animation – SS07Jens Krüger – Computer Graphics and Visualization Group
Finite difference method FDMRemember FDM from CFD
computer graphics & visualization
Simulation and Animation – SS07Jens Krüger – Computer Graphics and Visualization Group
• Discretization – Layout of grid points on a grid
• Location of discrete points across the domain
– Arbitrary grids can be employed• Structured or unstructured grids
– Implicit or explicit representation of topology (adjacency information)• Uniform grids: uniform spacing of grid points in x and y
y
x
x
y Pij
Pij+1
Pij-1
Pi+1j
Pi+1j+1
Pi+1j-1
Pi-1j
Pi-1j+1
Pi-1j-1
y = x
CFD – Computational Fluid Dynamics
computer graphics & visualization
Simulation and Animation – SS07Jens Krüger – Computer Graphics and Visualization Group
• Finite differences– Approximate partial derivatives by finite differences
between points
– Derived by considering the Taylor expansion
sdifferencecentralxOx
uu
sdifferencebackwardxOx
uu
sdifferenceforwardxOx
uu
x
u
jiji
jiij
ijji
ij
)(2
)(
)(
211
11
11
CFD – Computational Fluid Dynamics
computer graphics & visualization
Simulation and Animation – SS07Jens Krüger – Computer Graphics and Visualization Group
• Finite differences for higher order and mixed partial derivatives
22
11
2
2
)()(
2xO
x
uuu
x
u jiijji
ij
22111,111112
)(,)(4
yxOyx
uuuu
yx
u jijijiji
ij
CFD – Computational Fluid Dynamics
computer graphics & visualization
Simulation and Animation – SS07Jens Krüger – Computer Graphics and Visualization Group
• Difference equations - example– The 2D wave equation
02
2
2
22
2
2
y
u
x
uc
t
u
042 11112
2
11
yx
uuuuuc
t
uuu tij
tij
tij
tji
tji
tij
tij
tij
Partial Differential Equation
Discretization on a 2D Cartesian grids yields Difference Equation
CFD – Computational Fluid Dynamics
computer graphics & visualization
Simulation and Animation – SS07Jens Krüger – Computer Graphics and Visualization Group
Finite Elements method (FEM)?
computer graphics & visualization
Simulation and Animation – SS07Jens Krüger – Computer Graphics and Visualization Group
FEM• FEM is a method used for finding approximate solution
of partial differential equations (PDE)• Method: split the domain into a (possibly large) but
finite number of elements (triangles, rectangles, tetrahedra, hexahedra, etc.)
• Good for– complex domains (cars, planes, parts)– Dynamic domains (soft bodies, moving boundaries)– when the desired precision varies over the entire domain
computer graphics & visualization
Simulation and Animation – SS07Jens Krüger – Computer Graphics and Visualization Group
FEM1. Split into the domain into a finite number of elements2. Define shape functions (Interpolations- funktionen) in
elements (e.g. barycentric interpolation)3. Approximate PDE solution between the sample points by the
shape function with the sample points as variables.
4. Compute partial derivative based on interpolated solution
i
ii upNpu )()(
ii
i ux
pN
x
u )( e.g.
computer graphics & visualization
Simulation and Animation – SS07Jens Krüger – Computer Graphics and Visualization Group
FEM5. Multiply PDE with “test function”6. Spacial Integration (over p) over partial derivatives within
finite element7. Result: element equation (not dependent on p anymore)8. Combine element equations into a single global equation
system (via shared sample points)9. Solve this (possibly non linear) system
computer graphics & visualization
Simulation and Animation – SS07Jens Krüger – Computer Graphics and Visualization Group
FEM vs. FDM• FDM is an approximation to the differential equation; the finite element
method is an approximation to its solution. • FEM is its able to handle complex geometries (and boundaries), FDM in its
basic form is restricted to handle rectangular shapes and simple alterations thereof
• FDM can be very easy to implement. • FDM can be seen as a special case of the FEM approach• there are reasons to consider the mathematical foundation of the FEM more
sound, for instance, because the quality of the approximation between grid points is poor in FDM.
• The quality of a FEM approximation is often higher than in the corresponding FDM approach, but this is extremely problem dependent and several examples to the contrary can be provided
computer graphics & visualization
Simulation and Animation – SS07Jens Krüger – Computer Graphics and Visualization Group
Mass-spring systems• Pros
– Fast– No pre-process– GPU Implementation
• Cons– Volume not considered
• Physical laws violated!– Material Properties hard to
choose• Spring constants vs. elastic modulus
– Stable simulation requires very small time steps
• performance gets worse than expected• almost impossible for stiff material
computer graphics & visualization
Simulation and Animation – SS07Jens Krüger – Computer Graphics and Visualization Group
To the next level …
• Finite element soft bodies
computer graphics & visualization
Simulation and Animation – SS07Jens Krüger – Computer Graphics and Visualization Group
Elasticity theory
• : Total energy• u(x) : Displacement field• f(x) : External (surface) forces• g(x) : Volumetric forces (e.g. gravity)• (u) : Linearized notation strain tensor E• D : Material law (Hooke‘s law)
dsufdxugdxuDuu TTT )()(
2
1)(
uMuCuKF FuTKuuT
computer graphics & visualization
Simulation and Animation – SS07Jens Krüger – Computer Graphics and Visualization Group
Elasticity theory: Terms
• 2nd Term: (Distant) Volume Forcese.g. Gravity, Linear/Angular Momentum, magnetic/electric fields
• 3rd Term: (Direct) Surface Forcese.g. push/pull, collision/contact
dsufdxugdxuDuu TTT )()(
2
1)(
computer graphics & visualization
Simulation and Animation – SS07Jens Krüger – Computer Graphics and Visualization Group
Now consider only the first part …
Elastic Energy:
dsufdxugdxuDuu TTT )()(
2
1)(
computer graphics & visualization
Simulation and Animation – SS07Jens Krüger – Computer Graphics and Visualization Group
Elasticity theory cont.Strain (Dehnung) Tensor E
describes elongations ofinfinitesimal small volumeelement along coordinates axes
x
y
z
Eyy
Eyx
EyzExy
Exx
Exz
Ezy
Ezz
Ezx
computer graphics & visualization
Simulation and Animation – SS07Jens Krüger – Computer Graphics and Visualization Group
Elasticity theory cont.Stress (Spannung) Tensor internal forces acting on coordinate planes
x
y
z
yy
yx
yz
xy
xx
xz
zy
zz
zx
computer graphics & visualization
Simulation and Animation – SS07Jens Krüger – Computer Graphics and Visualization Group
Elasticity theory cont.Material Law • Strain Tensor E and Stress Tensor are
coupled via Hooke‘s law
• , : Lamé coefficients“elongation along axes”
“deformation”
computer graphics & visualization
Simulation and Animation – SS07Jens Krüger – Computer Graphics and Visualization Group
Elasticity theory cont.Lamé coefficients
– derived from elasticity modulus Em
and Poisson‘s ratio (Querkontraktion)
)1(2
)21)(1(
m
m
E
E
computer graphics & visualization
Simulation and Animation – SS07Jens Krüger – Computer Graphics and Visualization Group
Elastic Modulus Em …Material Elastic Modulus GPa
Rubber (small strain) 0.01-0.1Low density polyethylene 0.2Polypropylene 37377,00Bacteriophage capsids 39142,00Polyethylene terephthalate 38385,00Polystyrene 38414,00Nylon 39266,00Oak wood (along grain) 11,00High-strength concrete (under compression) 30,00Magnesium metal (Mg) 45,00Aluminium alloy 69,00Glass (all types) 72,00Brass and bronze 103-124Titanium (Ti) 105-120Carbon fiber reinforced plastic (unidirectional, along grain) 44105,00Wrought iron and steel 190-210Tungsten (W) 400-410Silicon carbide (SiC) 450,00Tungsten carbide (WC) 450-650Single carbon nanotube [1] 1,000+Diamond (C) 1,050-1,200
… is a measure of the stiffness of a given material, not of a given part.
computer graphics & visualization
Simulation and Animation – SS07Jens Krüger – Computer Graphics and Visualization Group
Poisson‘s ratio…material poisson's ratio
rubber 0.50saturated clay 0.40-0.50
magnesium 0.35titanium 0.34copper 0.33
aluminium-alloy 0.33
clay 0.30-0.45stainless steel 0.30-0.31
steel 0.27-0.30glass 0.24
cast iron 0.21-0.26sand 0.20-0.45
concrete 0.20Foam 0.10 to 0.40Cork ca. 0.00
auxetics negative
ll
dd
computer graphics & visualization
Simulation and Animation – SS07Jens Krüger – Computer Graphics and Visualization Group
Auxetic Materials
computer graphics & visualization
Simulation and Animation – SS07Jens Krüger – Computer Graphics and Visualization Group
Linearized Notation• E is a symmetric tensor
using only upper triangular part is sufficient
23
13
12
33
22
11
23
13
12
33
22
11
2
2
2
2
2
2
)(
E
E
E
E
E
E
uD
computer graphics & visualization
Simulation and Animation – SS07Jens Krüger – Computer Graphics and Visualization Group
Intuition: Elastic Energy
• We have
you can think if this integral as
dsufdxugdxuDuu TTT )()(
2
1)(
dxuDuT )()(
Forceextensionconstant springdistance SeeDe
computer graphics & visualization
Simulation and Animation – SS07Jens Krüger – Computer Graphics and Visualization Group
Strain Formulations• Cauchy strain (linear, constant matrix)
– BroNielsen ’96
• Corotated Cauchy strain (linear, dynamic matrix)– Rankin ’88, Müller ’02, Hauth ’04
• Green strain (non-linear, dynamic matrix)
computer graphics & visualization
Simulation and Animation – SS07Jens Krüger – Computer Graphics and Visualization Group
Linear approximation of Strain• Cauchy Strain
– ignores non linear part– looses rotational invariance
computer graphics & visualization
Simulation and Animation – SS07Jens Krüger – Computer Graphics and Visualization Group
Linear approximation of StrainLinear vs. non-linear vs. co-rotational strain
computer graphics & visualization
Simulation and Animation – SS07Jens Krüger – Computer Graphics and Visualization Group
Back to FEMSo far:• considered continuous elasticity
Now:• discretize to a finite number of cells/elements
Remember:• We are looking primarily for u (displacement
vector)
computer graphics & visualization
Simulation and Animation – SS07Jens Krüger – Computer Graphics and Visualization Group
FEMConsider the continuous u as:
• a set of supporting points (FEM vertices)• a continuum in between the supporting points
generated from the interpolation of u at the supporting points
big difference to finite differences here!!
computer graphics & visualization
Simulation and Animation – SS07Jens Krüger – Computer Graphics and Visualization Group
FEM Elements:
computer graphics & visualization
Simulation and Animation – SS07Jens Krüger – Computer Graphics and Visualization Group
Considering a single elementCan use tetrahedron barycentric interpolation
PBN
P
N
N
N
N
PPPP
i
B
1
4
3
2
1
4321
1P
3P
2P
4PP
computer graphics & visualization
Simulation and Animation – SS07Jens Krüger – Computer Graphics and Visualization Group
Remember this slide?1. Split into the domain into a finite number of elements2. Define shape functions in elements3. Approximate PDE solution between the sample points by the
shape function with the sample points as variables.
4. Compute partial derivative based on interpolated solution
i
ii upNpu )()(
ii
i ux
pN
x
u )( e.g.
computer graphics & visualization
Simulation and Animation – SS07Jens Krüger – Computer Graphics and Visualization Group
Tet - FEM
PBN
P
N
N
N
N
PPPP
i
B
1
4
3
2
1
4321 i
ii upNpu )()(
ii
i ux
pN
x
u )(
computer graphics & visualization
Simulation and Animation – SS07Jens Krüger – Computer Graphics and Visualization Group
How to solve for the deformations? is stationary (does not change over time)
thus it does not change over u either derivative for u must be zero
Consider only the first term in the lecture,other terms are processes analogously.
dsufdxugdxuDuu TTT )()(
2
1)(
computer graphics & visualization
Simulation and Animation – SS07Jens Krüger – Computer Graphics and Visualization Group
Solving the equation…Compute partial derivatives of u
dxuDuT )()(2
1
T
x
u
x
u
x
u
x
u
x
u
x
u
x
u
x
u
x
u
2
3
3
2
1
3
3
1
1
2
2
1
3
3
2
2
1
1 ,,,,,
i
ii upNpu )()(
computer graphics & visualization
Simulation and Animation – SS07Jens Krüger – Computer Graphics and Visualization Group
Solving the equation…Due to the linearity of ε can be rewritten as
e
T
Bu
x
u
x
u
x
u
x
u
x
u
x
u
x
u
x
u
x
u
2
3
3
2
1
3
3
1
1
2
2
1
3
3
2
2
1
1 ,,,,,
i
ii upNpu )()(
computer graphics & visualization
Simulation and Animation – SS07Jens Krüger – Computer Graphics and Visualization Group
Rewriting the equation
ee
eT
TeTTe
T
uK
udxDBB
xAxAxx
dxDBuBuu
dxuDuu
)(
2 )(2
1
)()(2
1
computer graphics & visualization
Simulation and Animation – SS07Jens Krüger – Computer Graphics and Visualization Group
We did it…
2
2
2 dt
uuuM
dt
uuCuKf
uMuCuKF
dtttdttdttdttdttdtt