function p24_demo ( iteration_max, h, fh ) %*****************************************************************************80 % %% P24_DEMO runs the 2D demo problem #24, with mesh size H. % % Licensing: % % This code is distributed under the GNU LGPL license. % % Modified: % % 18 January 2016 % % Reference: % % Per-Olof Persson and Gilbert Strang, % A Simple Mesh Generator in MATLAB, % SIAM Review, % Volume 46, Number 2, June 2004, pages 329-345. % % Parameters: % % Input, integer ITERATION_MAX, the maximum number of iterations that DISTMESH % should take. (The program might take fewer iterations if it detects convergence.) % % Input, real H, the mesh spacing parameter. % % Input, external FH, the mesh density function. % if ( nargin < 1 ) iteration_max = 50; fprintf ( 1, '\n' ); fprintf ( 1, 'P24_DEMO - Note:\n' ); fprintf ( 1, ' No value of ITERATION_MAX was supplied.\n' ); fprintf ( 1, ' The default value ITERATION_MAX = %d will be used.\n', ... iteration_max ); end if ( nargin < 2 ) h = 0.015; fprintf ( 1, '\n' ); fprintf ( 1, 'P24_DEMO - Note:\n' ); fprintf ( 1, ' No value of H was supplied.\n' ); fprintf ( 1, ' The default value H = %g will be used.\n', h ); end if ( nargin < 3 ) fh = @p24_fh; fprintf ( 1, '\n' ); fprintf ( 1, 'P24_DEMO - Note:\n' ); fprintf ( 1, ' No value of FH was supplied.\n' ); fprintf ( 1, ' The default variable density function will be used.\n', h ); end % % Put the random number generator into a fixed initial state. % rand ( 'state', 111 ); % % Set the rendering method for the current figure to Z-buffering. % set ( gcf, 'rend', 'z' ); fprintf ( 1, '\n' ); fprintf ( 1, 'Problem 24:\n' ); fprintf ( 1, ' The mysterious hand, h = %f\n', h ) fd = @p24_fd; box = [ 0.2130, 0.2086; 0.6449, 0.8855 ]; fixed = [ ... 0.496200, 0.208600; ... 0.557100, 0.319900; ... 0.606100, 0.415800; ... 0.644900, 0.500900; ... 0.627100, 0.534400; ... 0.593200, 0.512700; ... 0.568900, 0.469200; ... 0.539800, 0.424000; ... 0.500500, 0.433900; ... 0.486000, 0.501800; ... 0.481700, 0.569700; ... 0.493500, 0.663800; ... 0.495700, 0.733500; ... 0.496800, 0.783300; ... 0.489800, 0.840300; ... 0.477900, 0.855700; ... 0.461800, 0.850200; ... 0.457500, 0.822200; ... 0.456900, 0.770600; ... 0.456400, 0.736200; ... 0.448300, 0.678300; ... 0.437500, 0.612200; ... 0.418100, 0.595000; ... 0.405200, 0.642100; ... 0.396100, 0.714500; ... 0.381500, 0.773300; ... 0.369100, 0.862000; ... 0.351400, 0.885500; ... 0.329800, 0.866500; ... 0.334700, 0.817600; ... 0.348700, 0.744300; ... 0.354600, 0.688200; ... 0.372400, 0.586000; ... 0.360500, 0.586000; ... 0.339000, 0.641200; ... 0.314200, 0.701800; ... 0.279800, 0.811300; ... 0.272200, 0.815800; ... 0.256100, 0.808600; ... 0.249600, 0.786900; ... 0.256100, 0.754300; ... 0.287300, 0.656600; ... 0.297000, 0.622200; ... 0.322800, 0.537100; ... 0.312600, 0.530800; ... 0.288400, 0.557900; ... 0.251800, 0.626700; ... 0.231300, 0.657500; ... 0.215100, 0.656600; ... 0.213000, 0.621300; ... 0.235100, 0.572400; ... 0.250700, 0.535300; ... 0.289400, 0.461100; ... 0.299100, 0.420400; ... 0.306100, 0.363300; ... 0.313100, 0.319000; ... 0.323900, 0.264700; ... 0.336300, 0.235700 ]; [ p, t ] = distmesh_2d ( fd, fh, h, box, iteration_max, fixed ); post_2d ( p, t, fh ) % % Write a PostScript image of the triangulation. % [ node_num, junk ] = size ( p ); [ tri_num, junk ] = size ( t ); p = p'; t = t'; node_show = 0; triangle_show = 1; triangulation_order3_plot ( 'p24_mesh.eps', node_num, p, tri_num, ... t, node_show, triangle_show ); % % Write a text file containing the nodes. % r8mat_write ( 'p24_nodes.txt', 2, node_num, p ); % % Write a text file containing the triangles. % i4mat_write ( 'p24_elements.txt', 3, tri_num, t ); return end