Resources:
Part 2: The Core of PBD
In this section, we will
- present the basic idea and the simulation algorithm of PBD
- discuss how to solve the system of constraints that are described to be simulated
The simulated objects:
- a set of N particles
- a set of M constraints
- a stiffness parameter kβ[0,1]: the strength of the constraint
πΒ Time Algorithm
Algorithm 1 Position-based dynamics: Given this data and a time step Ξt
1: for all vertices i do
2: ββinitialise xiβ=xi0β,viβ=vi0β,wiβ=1/miβ
3: end for
4: loop
5: ββfor all vertices i do viββviβ+Ξtwiβfextβ(xiβ)
6: ββdampVelocities(v1β,β¦,vNβ)
7: ββfor all vertices i do piββxiβ+Ξtviβ
8: ββfor all vertices i do genCollConstraints(xiββpiβ)
9: ββloop solverIteration times
10: ββββprojectConstraints(C1β,β¦,CM+Mcollββ,p1β,β¦,pNβ)
11: ββend loop
12: ββfor all vertices i do
13: ββββviββ(piββxiβ)/Ξt
14: ββββxiββpiβ
15: ββend for
16: ββvelocityUpdate(v1β,β¦,vNβ)
17: end loop
(1) - (3) specify the positions and the velocities of the particles
(5) - (7) perform a simple symplectic Euler integration step on the velocities and positions, the new locations piβ are used as predictions
(8) generate non-permanent external constraints, such as collision constraints
(9) - (11) iteratively corrects the predicted positions such that they satisfy the Mcollβ external as well as the M internal constraints
(12) - (15) Use the corrected positions piβ to update the velocities and positions
πΒ Solver
The system problem: a set of M equations for the 3N unknown position components, where M is the total number of constraints.
Solving a non-symmetric, non-linear system with equalities and inequalities is a tough problem.
Let x be the concatenation x=[x1Tβ,β¦,xNTβ]T,
C1β(x)β»0...CMβ(x)β»0
where the symbol β» denotes either = or β₯.
The Newton-Raphson iteration
is a method to solve non-linear
symmetric systems with equalities only. It starts with a first guess of a solution. Each constraint function is then linearized
in the neighborhood of the current solution using
C(x+Ξx)=C(x)+βC(x)β
Ξx+O(β£Ξxβ£2)=0
This yields a linear system for the global correction vector Ξx
βC1β(x)β
Ξx=βC1β(x)...βCMβ(x)β
Ξx=βCMβ(x)
where βCjβ(x) is the 1ΓN dimensional vector containing the derivatives of the function Cjβ w.r.t. all its parameters, i.e. the N components of x. Both, the rows βCjβ(x) and the right-hand side scalars βCjβ(x) are constant as they are evaluated at the location x before the system is solved.
When M=3N and only equalities are present, the system can be solved by any linear solver, e.g., a preconditioned conjugate gradient method.
Non-linear Gauss-Seidel Solver
: it solves each constraint equation C(x)β»0 separately
Given x , we want to find a correction Ξx such that C(x+Ξx)β»0. The constraint equation is approximated by
C(x+Ξx)βC(x)+βC(x)β
Ξxβ»0ββ
Based on the linear and angular momentum conservation requirements, Ξx is restricted in the direction of βC .
With a scalar Lagrange multiplier Ξ» :
Ξx=Ξ»Mβ1βC(x)ββ
where M=diag(m1β,m2β,β¦,mNβ) and wiβ=1/miβ. The correction vector of a single particle i
Ξxiβ=Ξ»wiββxiββC(x)ββ
Ξ»=βjβwjββ£βxjββC(x)β£2C(x)βββ
Formulated for the concatenated vector x of all positions, we get:
Ξ»=βC(x)TMβ1βC(x)C(x)βββ
The Gauss-Seidel method
- stable and easy to implement
- converges significantly slower than global solvers. The main reason is that error corrections are propagated only locally from constraint to constraint.
Hierarchical Solver: increase the convergence rate of the Gauss-Seidel method
Figure 2: The construction of a mesh hierarchy: A fine level l is composed of all the particles shown and the dashed constraints. The next coarser level, l + 1, contains the proper subset of black particles and the solid constraints. Each fine white particle needs to be connected to at least k (=2) black particles β its parents β shown by the arrows.
The main idea is to create a hierarchy of meshes in which the coarse meshes make sure that error corrections propagate fast across the domain.
Hierarchical Position-Based Dynamics (HPBD):
- define the original simulation mesh to be the finest mesh of the hierarchy
- create coarser meshes by only keeping a subset of the particles of the previous mesh.
- The hierarchy is traversed only once from the coarsest to the finest level. Therefore, they only need to define a prolongation operator.
β¨Β Connection to Implicit Methods
By considering backward Euler as a constrained minimization over positions. Starting from the traditional implicit Euler time discretization of the equations of motion
xn+1vn+1β=xn+Ξtvn+1=vn+ΞtMβ1(Fextβ+kβCn+1)ββ
where C is the vector of constraint potentials; k is the stiffness. We can eliminate velocity to give:
M(xn+1β2xn+xn+1βΞt2Mβ1Fextβ)=Ξt2kβCn+1ββ
Equation (12) can be seen as the first-order optimality condition for the following minimization:
xminβ21β(xn+1βx~)TM(xn+1βx~)βΞt2kCn+1ββ
where x~ is the predicted position, given by:
x~β=2xnβxnβ1+Ξt2Mβ1Fextβ=xn+Ξtvn+Ξt2Mβ1Fextβββ
Taking the limit as kββ we obtain the constrained minimization:
xminβ21β(xn+1βx~)TM(xn+1βx~)s.t.Ciβ(xn+1)=0,i=1,...,n.βββ
We can interpret this minimization problem as finding the closest point on the constraint manifold to the predicted position.
To solve this minimization, PBD employs a variant of the fast projection algorithm but modifies the projection step by linearizing constraints one at a time using a Gauss-Seidel approach.
β¨Β Second Order Methods
the second-order accurate BDF update equations
xn+1vn+1β=34βxnβ31βxnβ1+32βΞtvn+1=34βvnβ31βvnβ1+32βΞtMβ1(Fextβ+kβCn+1)ββ
Eliminating velocity and re-arranging gives
M(xn+1βx~)=94βΞt2kβCn+1ββ
where the inertial position x~ is given by:
x~β=34βxnβ31βxnβ1+98βΞtvnβ92βΞtvnβ1+94βΞt2Mβ1Fextβββ
Equation (19) can again be considered as the optimality condition for a minimization of the same form as (16).
Once the constraints have been solved, the updated velocity is obtained according to (17)
vn+1=Ξt1β[23βxn+1β2xn+21βxnβ1]ββ