Introduction To Mesh in Matlab
Introduction To Mesh in Matlab
By Allan P. Engsig-Karup
Overview
!! Introduction to mesh generation !! Introduction to DistMesh for Matlab !! Goal: Introduce you to DistMesh for use with DG-FEM based models.
2/18
Example. Triangulation.
4/18
6/18
7/18
#!" d>0
9/18
Mesh
From this we can determine, e.g. >> K=size(t,1); >> Nv=size(p,1); >> Nfaces=size(t,2); >> VX = p(:,1); >> VY = p(:,2); >> EToV = t; %Number of elements %Number of vertices in mesh %Number of faces/element %Vertice x-coordinates %Vertice y-coordinates %Element to Vertice table
12/18
!! Vertices are numbered anti-clockwise. !! Faces are numbered anti-clockwise with the first face beeing the one that connects the first two vertices.
13/18
Size*h0
2.5
1.5
1 0.5
Mesh
>> fd = inline('ddiff(drectangle(p,-1,1,-1,1),dcircle(p,0,0,0.4))','p'); >> pfix = [-1,-1;-1,1;1,-1;1,1]; >> fh = inline(['min( sqrt( p(:,1).^2 + p(:,2).^2 ) , 1 )'],'p'); >> [p,t] = distmesh2d(fd,fh,0.125/2.5,[-1,-1;1,1],pfix);
14/18
2.5
Size*h0
1.5
1 0.5
Mesh
15/18
>> fdInner = inline(dcircle(p,0,0,0.4),p); >> nodesInner = find(abs(fdInner([p]))<1e-3); >> fdOuter = inline(drectangle(p,-1,1,-1,1),p); >> nodesOuter = find(abs(fdOuter([p]))<1e-3); >> nodesB = find(abs(fd([p]))<1e-3);
16/18
Final remarks
These notes together with example scripts for DistMesh can be found at my webpage: http://www.imm.dtu.dk/~apek/