ECCV TutorialECCV TutorialMesh ProcessingMesh Processing
NumericsNumerics
Bruno LévyBruno LévyINRIA - ALICEINRIA - ALICE
OverviewOverview
1. Numerical Problems 1. Numerical Problems
2. Linear and Quadratic 2. Linear and Quadratic
3. Non-linear 3. Non-linear
Motivations:Motivations:
1970’s1970’s
2000’s2000’s
Need for Need for scalabilityscalability in GP in GP
1. Numerical Problems in GP1. Numerical Problems in GPMesh ParameterizationMesh Parameterization
ii
jj11
jj22jj……
UUii = = a ai,ji,jUUjj
j j N Nii
i,j ai,j ai,ji,j > 0 > 0aai,ii,i = - = - a ai,ji,j
The border is mapped toThe border is mapped toa convex polygona convex polygon
[Tutte], [Floater][Tutte], [Floater]
1. Numerical Problems in GP1. Numerical Problems in GPDiscrete FairingDiscrete Fairing
ii
jj11
jj22jj……
F(p)=F(p)= ppii - - a ai,ji,jppjj
22
j j N Niiii
[Mallet], [Kobbelt], [Sorkine]…[Mallet], [Kobbelt], [Sorkine]…
1. Numerical Problems in GP1. Numerical Problems in GPNeighborhoodsNeighborhoods
F = sum of terms, attached to neighborhoodsF = sum of terms, attached to neighborhoods
Discrete fairingDiscrete fairing[Kobbelt98, Mallet95][Kobbelt98, Mallet95]ParameterizationParameterization[Desbrun02][Desbrun02]DeformationsDeformations[CohenOr], [Sorkine][CohenOr], [Sorkine]
Curv. EstimationCurv. Estimation[Cohen-Steiner 03][Cohen-Steiner 03]Texture mappingTexture mapping[Levy01][Levy01]Discrete fairingDiscrete fairing[Desbrun], ...[Desbrun], ...
ParameterizationParameterization[Haker00][Haker00][Levy02][Levy02]
[Eck][Eck]
2. Linear and Quadratic GP2. Linear and Quadratic GPRemoving degrees of freedomRemoving degrees of freedom
F(xf) = F(xf) = xfxf
xlxl
[ Af [ Af AlAl] - b] - b
22
F(x) = A x - bF(x) = A x - b22
2. Linear and Quadratic GP2. Linear and Quadratic GPRemoving degrees of freedomRemoving degrees of freedom
F(xf) = A.x - d = Al.xl + Af.xf - d F(xf) = A.x - d = Al.xl + Af.xf - d2 2
F(xf) minimumF(xf) minimum Aft.Af.xf = Af
t.d - AftAl.xl Af
t.Af.xf = Aft.d - Af
tAl.xl
M.x = b M.x = b
}} }}
The problem: (1) construct a linear system (2) solve a linear system
2. Linear and Quadratic GP2. Linear and Quadratic GPThe OpenNL approach The OpenNL approach
(http://alice.loria.fr/software)(http://alice.loria.fr/software)
The problem: (1) construct a linear system (2) solve a linear system
NlLockVariable(i1, val1)NlLockVariable(i1, val1)NlLockVariable(i2, val2)NlLockVariable(i2, val2)……For each stencil instance (one-rings):For each stencil instance (one-rings): NlBeginRow();NlBeginRow(); NlAddCoefficient(i, a);NlAddCoefficient(i, a); … … NlEndRow();NlEndRow();
NlSolve()NlSolve()
Need forNeed for• Dynamic Matrix DSDynamic Matrix DS• Updating formulaUpdating formula
2. Linear and Quadratic GP2. Linear and Quadratic GPDirect Solvers (LU)Direct Solvers (LU)
A Textbook solver: LU factorization (and Cholesky)
M =M =UL
UL x = b
L Y = b (1) solve
U x = Y(2) solve
a ‘small’ problem: O(n3) !!n=100 0.01 sn=106 10 centuries
2. Linear and Quadratic GP2. Linear and Quadratic GPSuccessive Over-Relaxation (Gauss-Seidel)Successive Over-Relaxation (Gauss-Seidel)
=
….
ci
….
xfnf
xf1
mi,jmi,1 mi,n… …
m1,jm1,1 m1,n… …
mn,jmn,1 mn,n… …
….
….
….
….
….
….
xfi
….
….
xfixfimi,imi,i
j = ij = i mi,j xfjmi,j xfjci-ci-(( )) used in [Taubin95]used in [Taubin95]
……
2. Linear and Quadratic DGP2. Linear and Quadratic DGPSuccessive Over-Relaxation (Gauss-Seidel)Successive Over-Relaxation (Gauss-Seidel)
1000 iterations S.O.R.
2. Linear and Quadratic GP2. Linear and Quadratic GPWhite Magic: White Magic: The Conjugate GradientThe Conjugate Gradient
inline int solve_conjugate_gradient(inline int solve_conjugate_gradient( const SparseMatrix &A, const Vector& b, Vector& const SparseMatrix &A, const Vector& b, Vector& x, x, double eps, int max_iterdouble eps, int max_iter ){ ){ int N = A.n() ;int N = A.n() ; double t, tau, sig, rho, gam;double t, tau, sig, rho, gam; double bnorm2 = BLAS::ddot(N,b,1,b,1) ; double bnorm2 = BLAS::ddot(N,b,1,b,1) ; double err=eps*eps*bnorm2 ; double err=eps*eps*bnorm2 ; mult(A,x,g);mult(A,x,g); BLAS::daxpy(N,-1.,b,1,g,1);BLAS::daxpy(N,-1.,b,1,g,1); BLAS::dscal(N,-1.,g,1);BLAS::dscal(N,-1.,g,1); BLAS::dcopy(N,g,1,r,1);BLAS::dcopy(N,g,1,r,1); while ( BLAS::ddot(N,g,1,g,1)>err && its < while ( BLAS::ddot(N,g,1,g,1)>err && its < max_iter) { max_iter) { mult(A,r,p);mult(A,r,p); rho=BLAS::ddot(N,p,1,p,1);rho=BLAS::ddot(N,p,1,p,1); sig=BLAS::ddot(N,r,1,p,1);sig=BLAS::ddot(N,r,1,p,1); tau=BLAS::ddot(N,g,1,r,1);tau=BLAS::ddot(N,g,1,r,1); t=tau/sig;t=tau/sig; BLAS::daxpy(N,t,r,1,x,1);BLAS::daxpy(N,t,r,1,x,1); BLAS::daxpy(N,-t,p,1,g,1);BLAS::daxpy(N,-t,p,1,g,1); gam=(t*t*rho-tau)/tau;gam=(t*t*rho-tau)/tau; BLAS::dscal(N,gam,r,1);BLAS::dscal(N,gam,r,1); BLAS::daxpy(N,1.,g,1,r,1);BLAS::daxpy(N,1.,g,1,r,1); ++its;++its; }} return its ;return its ;}}
Only simpleOnly simplevector ops (BLAS)vector ops (BLAS)
Complicated ops:Complicated ops:Matrix x vectorMatrix x vector(see course notes)(see course notes)
[Shewchuck: CG without the agonizing pain][Shewchuck: CG without the agonizing pain]
Iterative SolversIterative Solvers•Successive Over-Relaxation •Sparse C.G. >100x speedup
5
2.5
0 900 45
- log|G.x + c |
Time(s)
Precond.Conj. Grad.
S.O.R.
Conj. Grad.
Iterative SolversIterative Solvers
j, gi,j
Sparse storage of G = AftAf Sparse storage of G = AftAf
The Sparse Conjugate Gradient Solver
Demo
Interactive solver !!!
White magic: MultigridWhite magic: Multigrid
Sparse Conjugate Gradient is O(n2) !!
Remember: direct solver is O(n3)
That’s much better, but …
… we want even more efficiency !!
White magic: MultigridWhite magic: Multigrid
[Lee],[Schroeder],[Kobbelt],[Hackbuch]
1
1
2
2
3
3
4
4
Cascadic multigrid
Coarse to fine[Bornemann96]
White magic: MultigridWhite magic: Multigrid
Step 2: Cascadic multigrid
[MIPS, HLSCM, ABF++…]
White Magic: MultigridWhite Magic: Multigrid
direct solver : O(n3)Sparse CG : O(n2)
Multigrid : O(n) !!
Black Magic: Black Magic: Sparse DirectSparse Direct[ ]
We started from O(n3)We achieved O(n)
Can we do better ?
-- Interactivity ---- Ease of implementation --
[Sheffer et.al] SuperLU for ABF[Sheffer et.al] SuperLU for ABF[Botsch et.al] Interactive mesh deformation[Botsch et.al] Interactive mesh deformation
2. Linear and Quadratic DGP2. Linear and Quadratic DGPBlack Magic: Black Magic: Sparse Direct SolversSparse Direct Solvers
Direct method’s revenge: Super-Nodal data structure
M =M =UL
j, gi,j
Super-nodal: [Demmel et.al 96]Multi-frontal:[Lexcellent et.al 98] [Toledo et.al]
TAUCS, SuperLU, CHOLDMODTAUCS, SuperLU, CHOLDMOD
Black Magic: Black Magic: Sparse directSparse direct[ ]
Demos
Interactivity
TAUCS, SuperLU, CHOLDMODTAUCS, SuperLU, CHOLDMOD
2. Linear and Quadratic GP2. Linear and Quadratic GPOpenNL architectureOpenNL architecture
NlLockVariables(i,a)NlLockVariables(i,a)……
NlBeginRow()NlBeginRow()NlAddCoefficient(i,a)NlAddCoefficient(i,a)……NlEndRow()NlEndRow()
NlSolve()NlSolve()
j, gi,j
LS with LS with reducedreduceddegrees ofdegrees offreedomfreedom
•Built-in (CG, GMRES, BICGSTAB)Built-in (CG, GMRES, BICGSTAB)•SuperLUSuperLU•MUMPSMUMPS•TAUCSTAUCS•……
2. Linear and Quadratic GP2. Linear and Quadratic GPApplicationsApplications
Gocad:Gocad:Meshing forMeshing foroil-explorationoil-exploration
MayaMaya
VSP-TechnologyVSP-TechnologyATARI-InfogrammesATARI-Infogrammes
Blender Blender (OpenSource)(OpenSource)
2. Linear and Quadratic GP2. Linear and Quadratic GPApplicationsApplications
OpenNL in SILOOpenNL in SILO
3. Non-Linear GP3. Non-Linear GP
MIPS MIPS [Hormann], Stretch [Sander][Hormann], Stretch [Sander] ABF ABF [Sheffer][Sheffer], ABF++ , ABF++ [Sheffer & Lévy][Sheffer & Lévy] PGP [Ray,Levy,Li,Sheffer,Alliez]PGP [Ray,Levy,Li,Sheffer,Alliez] Circle Packings/Patterns Circle Packings/Patterns [Bobenko], [Bobenko],
[Karevych][Karevych]
Conquer the non-linear worldConquer the non-linear world
We want to optimize a function F(x)What can we do when F is non-linear ?
Newton’s method:
Conquer the non-linear worldConquer the non-linear world
Non-linear shapes functionals Connectivity shapes Angle Based Flattening ++
Demos
ConclusionsConclusionsa map to the solvers junglea map to the solvers jungle
Numerical Solvers
Direct Iterative
Multi-grid
Sparse C.G.
S.O.R. [ ] Naive
sparse direct
ConclusionsConclusions
Sparse C.G.
Multi-grid
Sparse direct
Non-linear
100x speedup w.r.t. S.O.R.simple to implement
Linear O(n) !!! (1000x)
best for huge objects
Ultra-fast (best for interactivity) (10000x) Big memory overhead
Difficult to tune …
ConclusionConclusionTake home messageTake home message
In most cases, TAUCS + OOC will do the job.In most cases, TAUCS + OOC will do the job.
For small datasets, PreCG has a good For small datasets, PreCG has a good simplicity/mem. requirement/efficientcy ratio.simplicity/mem. requirement/efficientcy ratio.
Use OpenNL for Matrix Assembly - Solver Use OpenNL for Matrix Assembly - Solver AbstractionAbstraction
ResourcesResources
Source code & papersSource code & papers
on http://alice.loria.fr/WIKIon http://alice.loria.fr/WIKI
– GraphiteGraphite– CGALCGAL– OpenMeshOpenMesh– OpenNLOpenNL
ConclusionConclusionMesh Processing: a wide topicMesh Processing: a wide topicData structuresData structuresMesh repairMesh repairMesh analysisMesh analysisSmoothingSmoothingParameterizationParameterizationMesh simplificationMesh simplificationRemeshingRemeshingFreeform modeling ...Freeform modeling ...
SIGGRAPH and EUROGRAPHICS tutorials SIGGRAPH and EUROGRAPHICS tutorials (with M. Botsch, M. Pauly, L. Kobbelt and P. Alliez)(with M. Botsch, M. Pauly, L. Kobbelt and P. Alliez)
http://alice.loria.fr/WIKI/http://alice.loria.fr/WIKI/
Top Related