function meshdemo_2d %% MESHDEMO_2D displays some 2D examples of the use of DISTMESH. % % Copyright: % % (C) 2004 Per-Olof Persson. % See COPYRIGHT.TXT for details. % % Modified: % % 06 February 2006 % % Reference: % % Per-Olof Persson and Gilbert Strang, % A Simple Mesh Generator in MATLAB, % SIAM Review, % Volume 46, Number 2, June 2004, pages 329-345. % % Local parameters: % % Local, integer ITERATION_MAX, the maximum number of iterations that DISTMESH % should take. (The program might take fewer iterations if it detects convergence.) % % Local, real H, the desired initial spacing. If a uniform mesh density is used, % this is the approximate spacing throughout the region. % % Local, pointer FH, an inline formula, or the name of an M file, which calculates % the mesh density function. % timestamp; fprintf ( 1, '\n' ); fprintf ( 1, 'MESHDEMO_2D\n' ); fprintf ( 1, ' Demonstrations of the use of DISTMESH.\n' ); % % Problem 1, the circle, with spacings H = 0.4, 0.2, 0.1. % iteration_max = 200; h = 0.40; p01_demo ( iteration_max, h ); iteration_max = 200; h = 0.20; p01_demo ( iteration_max, h ); iteration_max = 200; h = 0.10; p01_demo ( iteration_max, h ); % % Problem 2, unit circle with a hole. % iteration_max = 200; h = 0.10; p02_demo ( iteration_max, h ) % % Problem 3, square with a hole, uniform density. % iteration_max = 200; h = 0.15; fh = @p03_fh; p03_demo ( iteration_max, h, fh ) % % Problem 3, square with a hole, finer density near the hole. % iteration_max = 300; h = 0.05; fh = inline ( 'min(4*sqrt(sum(p.^2,2))-1,2)', 'p' ); p03_demo ( iteration_max, h, fh ) % % Problem 4, hexagon with a hexagonal hole. % iteration_max = 200; h = 0.1; p04_demo ( iteration_max, h ); % % Problem 5, the horn. % iteration_max = 200; h = 0.020; p05_demo ( iteration_max, h ); % % Problem 6, the superellipse. % iteration_max = 200; h = 0.08; p06_demo ( iteration_max, h ); % % Problem 7, the bicycle seat. % iteration_max = 200; h = 0.75; p07_demo ( iteration_max, h ); % % Problem 8, the holey pie slice, uniform density. % iteration_max = 200; h = 0.025; fh = @huniform; p08_demo ( iteration_max, h, fh ); % % Problem 8, the holey pie slice, variable density. % iteration_max = 200; h = 0.005; fh = @p08_fh; p08_demo ( iteration_max, h, fh ); % % Problem 9, Jeff Borggaard's square with two hexagonal holes. % iteration_max = 200; h = 0.08; p09_demo ( iteration_max, h ); % % Problem 10, a simple square. % iteration_max = 200; h = 0.10; p10_demo ( iteration_max, h ) % % Problem 11, the L-shaped region. % iteration_max = 200; h = 0.10; p11_demo ( iteration_max, h ) % % Problem 12, John Shadid's H-shaped region. % iteration_max = 200; h = 0.05; p12_demo ( iteration_max, h ) % % Problem 13, the Sandia Fork. % iteration_max = 200; h = 0.025; p13_demo ( iteration_max, h ) % % Problem 14, Lake Alpha with Beta island. % iteration_max = 50; h = 20.0; fh = @huniform; p14_demo ( iteration_max, h, fh ) % % Problem 14, Marcus Garvie's Lake Alpha with Beta island. % iteration_max = 50; h = 10.0; fh = @p14_fh; p14_demo ( iteration_max, h, fh ) % % Problem 15, Sangbum Kim's forward step problem. % iteration_max = 50; h = 0.2; p15_demo ( iteration_max, h ) fprintf ( 1, '\n' ); fprintf ( 1, 'MESHDEMO_2D\n' ); fprintf ( 1, ' Normal end of execution.\n' ); fprintf ( 1, '\n' ); timestamp;