function p20_demo ( iteration_max, h ) %*****************************************************************************80 % %% P20_DEMO runs the 2D demo problem #20, with mesh size H. % % Licensing: % % This code is distributed under the GNU LGPL license. % % Modified: % % 26 April 2012 % % Author: % % John Burkardt % % Reference: % % Per-Olof Persson, 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. % % Input, real H, the mesh spacing parameter. % if ( nargin < 1 ) iteration_max = 2; fprintf ( 1, '\n' ); fprintf ( 1, 'P20_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 = 2.0; fprintf ( 1, '\n' ); fprintf ( 1, 'P20_DEMO - Note:\n' ); fprintf ( 1, ' No value of H was supplied.\n' ); fprintf ( 1, ' The default value H = %f will be used.\n', h ); end % % Choose the uniform or nonuniform mesh option. % uniform = 1; % % 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 20:\n' ); fprintf ( 1, ' ICAM / Wright House, h = %f\n', h ) if ( uniform ) fprintf ( 1, ' UNIFORM mesh spacing requested.\n' ); else fprintf ( 1, ' NONUNIFORM mesh spacing requested.\n' ); end fd = @p20_fd; if ( uniform) fh = @p20_uniform_fh; else fh = @p20_nonuniform_fh; end box = [ 0.00, 0.00; 41.00, 98.00 ]; fixed = [ ... 7.25, 0.25; ... % Lower left corner of R1. 14.75, 0.25; ... 14.75, 7.75; ... 13.00, 7.75; ... 13.00, 8.25; ... 25.00, 8.25; ... 25.00, 7.75; ... 15.25, 7.75; ... 15.25, 0.25; ... % Lower left corner of R2. 28.75, 0.25; ... 28.75, 7.75; ... 28.75, 8.25; ... 29.25, 8.25; ... 29.25, 7.75; ... 29.25, 0.25; ... % Lower left corner of R3. 40.75, 0.25; ... 40.75, 7.75; ... 33.00, 7.75; ... 33.00, 8.25; ... 33.25, 8.25; ... % Lower left corner of R5. 40.75, 8.25; ... 40.75, 17.75; ... 33.25, 17.75; ... 33.25, 12.00; ... 32.75, 12.00; ... 32.75, 21.75; ... 20.75, 21.75; ... 20.75, 22.25; ... 21.25, 22.25; ... % Lower left corner of R8. 32.75, 22.25; ... 32.75, 25.25; ... 35.75, 25.25; ... 35.75, 34.75; ... 32.75, 34.75; ... 32.75, 37.75; ... 21.25, 37.75; ... 21.25, 26.00; ... 20.75, 26.00; ... 20.75, 38.25; ... 25.75, 38.25; ... 26.25, 38.25; ... % Lower left corner of R11. 32.75, 38.25; ... 32.75, 45.75; ... 26.25, 45.75; ... 26.25, 41.75; ... 25.75, 41.75; ... 25.75, 46.25; ... 26.25, 46.25; ... % Lower left corner of R15. 32.75, 46.25; ... 32.75, 53.75; ... 26.25, 53.75; ... 26.25, 49.25; ... 25.75, 49.25; ... 25.75, 53.75; ... 23.75, 53.75; ... 23.75, 62.75; ... 23.75, 97.75; ... 16.25, 97.25; ... 16.25, 88.00; ... 15.75, 88.00; ... 15.75, 97.25; ... 0.25, 97.25; ... 0.25, 75.25; ... % Lower left corner of R21 15.75, 75.25; ... 15.75, 85.00; ... 16.25, 85.00; ... 16.25, 74.75; ... 0.25, 74.75; ... 0.25, 63.25; ... % Lower left corner of R19 16.25, 63.25; ... 16.25, 62.75; ... 16.25, 58.25; ... % Lower left corner of R18 19.25, 58.25; ... 19.25, 54.25; ... 20.25, 54.25; ... 20.25, 53.75; ... 20.25, 50.75; ... % Lower left corner of R16. 23.25, 50.75; ... 23.25, 41.75; ... 17.25, 41.75; ... 16.75, 41.75; ... 16.75, 53.75; ... 7.25, 53.75; ... 7.25, 38.25; ... 17.25, 38.25; ... 17.25, 37.75; ... 7.25, 37.75; ... 7.25, 22.25; ... 16.75, 22.25; ... 16.75, 34.25; ... 17.25, 34.25; ... 17.25, 21.75; ... 7.25, 21.75; ... 7.25, 8.25; ... % Lower left corner of R4. 9.00, 8.25; ... 9.00, 7.75; ... 7.25, 7.75 ]; [ p, t ] = distmesh_2d ( fd, fh, h, box, iteration_max, fixed ); if ( 0 ) post_2d ( p, t, fh ) end % % Write the nodes and triangles of the mesh to a file. % if ( 1 ) [ node_num, junk ] = size ( p ); [ tri_num, junk ] = size ( t ); if ( uniform ) r8mat_write ( 'p20_uniform_nodes.txt', 2, node_num, p' ); i4mat_write ( 'p20_uniform_elements.txt', 3, tri_num, t' ); else r8mat_write ( 'p20_nonuniform_nodes.txt', 2, node_num, p' ); i4mat_write ( 'p20_nonuniform_elements.txt', 3, tri_num, t' ); end end return end