concept-collection / numbl-distmesh
numbl-distmesh / ex06_naca_airfoil.m
25 lines · 1010 BBlameHistoryRaw
1% ex06_naca_airfoil.m — NACA0012 airfoil in a circular far field.
2%
3% The domain is a large circle with the airfoil removed (ddiff). The size
4% function refines toward the leading and trailing edges; fixed points
5% pin the airfoil tip and a few far-field points. This is the heaviest
6% example — give it a few seconds.
8mip load --install distmesh
10hlead=0.01; htrail=0.04; hmax=2; circx=2; circr=4;
11a=.12/.2*[0.2969,-0.1260,-0.3516,0.2843,-0.1036];
13fd=@(p) ddiff(dcircle(p,circx,0,circr),(abs(p(:,2))-polyval([a(5:-1:2),0],p(:,1))).^2-a(1)^2*p(:,1));
14fh=@(p) min(min(hlead+0.3*dcircle(p,0,0,0),htrail+0.3*dcircle(p,1,0,0)),hmax);
16fixx=1-htrail*cumsum(1.3.^(0:4)');
17fixy=a(1)*sqrt(fixx)+polyval([a(5:-1:2),0],fixx);
18fix=[[circx+[-1,1,0,0]*circr; 0,0,circr*[-1,1]]'; 0,0; 1,0; fixx,fixy; fixx,-fixy];
19box=[circx-circr,-circr; circx+circr,circr];
20h0=min([hlead,htrail,hmax]);
22[p,t]=distmesh2d(fd,fh,h0,box,fix);
24title('NACA0012 airfoil');
25fprintf('mesh: %d nodes, %d triangles\n', size(p,1), size(t,1));