Download - Meshing
![Page 1: Meshing](https://reader034.vdocuments.net/reader034/viewer/2022052617/547641d1b4af9f4e5a8b457f/html5/thumbnails/1.jpg)
Tips and Tricks for Lazy MeshingGetting Started
Kenny [email protected]
Department of Computer ScienceUniversity of Copenhagen
2010
![Page 2: Meshing](https://reader034.vdocuments.net/reader034/viewer/2022052617/547641d1b4af9f4e5a8b457f/html5/thumbnails/2.jpg)
Delaunay Triangulation
Matlab got Delaunay triangulation (both in 2D and 3D)
1 X = rand(10,1);2 Y = rand(10,1);3 T = delaunay(X,Y);4 triplot(T,X,Y);
Results in
2
![Page 3: Meshing](https://reader034.vdocuments.net/reader034/viewer/2022052617/547641d1b4af9f4e5a8b457f/html5/thumbnails/3.jpg)
Constrained Delaunay TriangulationMatlab got Delaunay triangulation (both in 2D and 3D)
1 P = [0 0; 16 0; 16 2; 2 2; 2 3; 8 3; 8 5; 0 5];2 C = [1 2; 2 3; 3 4; 4 5; 5 6; 6 7; 7 8; 8 1];3 T = DelaunayTri(P, C);4 triplot(T);5 hold on;6 plot(P(C'),P(C'+size(P,1)),'−r', 'LineWidth', 2);7 hold off;
Results in
3
![Page 4: Meshing](https://reader034.vdocuments.net/reader034/viewer/2022052617/547641d1b4af9f4e5a8b457f/html5/thumbnails/4.jpg)
DistMesh - A Simple Mesh Generator in MATLAB
From http://math.mit.edu/~persson/mesh/
4
![Page 5: Meshing](https://reader034.vdocuments.net/reader034/viewer/2022052617/547641d1b4af9f4e5a8b457f/html5/thumbnails/5.jpg)
DistMesh - Example
Using
1 fd = inline('ddiff(drectangle(p,−1,1,−1,1),dcircle(p,0,0,0.5))','p');2 fh = inline('min(4*sqrt(sum(p.ˆ2,2))−1,2)','p');3 [p,t] = distmesh2d(fd,fh,0.05,[−1,−1;1,1],[−1,−1;−1,1;1,−1;1,1]);
Results in
5
![Page 7: Meshing](https://reader034.vdocuments.net/reader034/viewer/2022052617/547641d1b4af9f4e5a8b457f/html5/thumbnails/7.jpg)
Create a Signed Distance Map
Writing
1 I = read bw( 'EG WEB logo.jpg');2 phi = bw2phi( I );3 imagesc(phi);
Converts left image into right image
This is a signed distance map.
7
![Page 8: Meshing](https://reader034.vdocuments.net/reader034/viewer/2022052617/547641d1b4af9f4e5a8b457f/html5/thumbnails/8.jpg)
Create Random Particles
Writing
1 [M N] = size(phi);2 Y = rand(1,K)*(M−6) + 3;3 X = rand(1,K)*(N−6) + 3;4 plot(X,Y,'r+')
Creates a bunch of particles
8
![Page 9: Meshing](https://reader034.vdocuments.net/reader034/viewer/2022052617/547641d1b4af9f4e5a8b457f/html5/thumbnails/9.jpg)
Project ParticlesWriting
1 [GX,GY] = meshgrid( 1:N,1:M);2 d = interp2(GX,GY,phi,X,Y);3 [dx,dy] = gradient(phi);4 nx = interp2(GX,GY,dx,X,Y);5 ny = interp2(GX,GY,dy,X,Y);6 dx = d.*nx; dy = d.*ny;7 X(d>0) = X(d>0) − dx(d>0);8 Y(d>0) = Y(d>0) − dy(d>0);
Particles are now only inside object
9
![Page 10: Meshing](https://reader034.vdocuments.net/reader034/viewer/2022052617/547641d1b4af9f4e5a8b457f/html5/thumbnails/10.jpg)
Project Particles
Particles are not placed nice! So
Spread particles using a mass spring system (or some otherphysical simulation)
Project particles again to make sure they are kept inside
Repeat until you are satisfied
10
![Page 11: Meshing](https://reader034.vdocuments.net/reader034/viewer/2022052617/547641d1b4af9f4e5a8b457f/html5/thumbnails/11.jpg)
Get The TrianglesUse Delaunay triangulation
Make tend random points inside each triangle
If all random points are inside then keep the triangle
Now we got some red triangles representing our object
11
![Page 12: Meshing](https://reader034.vdocuments.net/reader034/viewer/2022052617/547641d1b4af9f4e5a8b457f/html5/thumbnails/12.jpg)
Marching Triangles – Make a Grid
Do case-by-case analysis of each cell
12
![Page 13: Meshing](https://reader034.vdocuments.net/reader034/viewer/2022052617/547641d1b4af9f4e5a8b457f/html5/thumbnails/13.jpg)
Marching Triangles – Case 1
13
![Page 14: Meshing](https://reader034.vdocuments.net/reader034/viewer/2022052617/547641d1b4af9f4e5a8b457f/html5/thumbnails/14.jpg)
Marching Triangles – Case 2
14
![Page 15: Meshing](https://reader034.vdocuments.net/reader034/viewer/2022052617/547641d1b4af9f4e5a8b457f/html5/thumbnails/15.jpg)
Marching Triangles – Case 3
15
![Page 16: Meshing](https://reader034.vdocuments.net/reader034/viewer/2022052617/547641d1b4af9f4e5a8b457f/html5/thumbnails/16.jpg)
Marching Triangles – Case 4
16
![Page 17: Meshing](https://reader034.vdocuments.net/reader034/viewer/2022052617/547641d1b4af9f4e5a8b457f/html5/thumbnails/17.jpg)
Marching Triangles – Final Result
17
![Page 18: Meshing](https://reader034.vdocuments.net/reader034/viewer/2022052617/547641d1b4af9f4e5a8b457f/html5/thumbnails/18.jpg)
Further ReadingJ. R. Shewchuk: What Is a Good Linear Finite Element?Interpolation, Conditioning, Anisotropy, and QualityMeasures, unpublished preprint, 2002.N. Molino, R. Bridson, J. Teran, and R. Fedkiw: A crystalline,red green strategy for meshing highly deformable objects withtetrahedra, Proc. International Meshing Roundtable 2003.P.-O. Persson, G. Strang, A Simple Mesh Generator inMATLAB. SIAM Review, Volume 46 (2), pp. 329-345, June2004.J. Spillmann, M. Wagner, M. Teschner: Robust TetrahedralMeshing of Triangle Soups, Proc. Vision, Modeling,Visualization. 2006M. K. Misztal, J. A. Bærentzen, F. Anton and K. Erleben,Tetrahedral Mesh Improvement Using Multi-faceRetriangulation, 18th International Meshing Roundtable,2009.
18
![Page 19: Meshing](https://reader034.vdocuments.net/reader034/viewer/2022052617/547641d1b4af9f4e5a8b457f/html5/thumbnails/19.jpg)
Study Group
List different quality measures with pros and cons
List different methods for creating tetrahedral meshes
Discuss what is meant by a “good” mesh?
Explain the DistMesh method to your fellow students
Search the web for a paper about “marching tetrahedra”explain the algorithm to each other.
Look at the Matlab code try to re-implement the 2Dmarching tetrahedra code to return a discrete manifold.
Extend the functionality of the marching triangle code byadding the equilibrate and project methods to fit the trianglemesh better.
Examine your mesh results, are they “good” meshes?
19
![Page 20: Meshing](https://reader034.vdocuments.net/reader034/viewer/2022052617/547641d1b4af9f4e5a8b457f/html5/thumbnails/20.jpg)
Programming Exercise
Find two or more quality measures from the Shewchuck paperthat you believe will be good measures.
Create 3-4 different tetrahedra meshes (use complexgeometries – high curvature – non-convex) using differentmesh generators
DistMeshMatlab’s delaunay functionYour own generator from your study group work(If you up for a challenge try to include TetGen in yourportfolio)
For each of the meshes created compare histograms of qualitymeasures and evaluate which method works best
20