dca6671DistMesh examples: interactive numbl companionJeremy Magland 1% ex02_rectangle_hole.m — Rectangle with a circular hole.
2%
3% ddiff subtracts the circle from the rectangle to form the domain. The
4% size function fh grows with distance from the circle, so elements are
5% small at the hole and coarsen outward. The last argument fixes the four
6% corners so they stay put.
8mip load --install distmesh
10fd=@(p) ddiff(drectangle(p,-1,1,-1,1),dcircle(p,0,0,0.5));
11fh=@(p) 0.05+0.3*dcircle(p,0,0,0.5);
12[p,t]=distmesh2d(fd,fh,0.05,[-1,-1;1,1],[-1,-1;-1,1;1,-1;1,1]);
14title('Rectangle with circular hole');
15fprintf('mesh: %d nodes, %d triangles\n', size(p,1), size(t,1));