function p14_demo ( iteration_max, h, fh ) %*****************************************************************************80 % %% P14_DEMO runs the 2D demo problem #14, with mesh size H. % % Licensing: % % This code is distributed under the GNU LGPL license. % % 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. % % 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, 'P14_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 = 10.0; fprintf ( 1, '\n' ); fprintf ( 1, 'P14_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 if ( nargin < 3 ) fh = @p14_fh; fprintf ( 1, '\n' ); fprintf ( 1, 'P14_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 14:\n' ); fprintf ( 1, ' Marcus Garvie''s Lake Alpha, with Beta Island, h = %f\n', h ) fd = @p14_fd; box = [ 100.0, 145.0; 634.0, 799.0 ]; fixed = [ ... 316.43027, 404.47559; ... 291.04946, 400.70917; ... 265.16504, 409.77890; ... 241.46794, 402.40310; ... 216.55145, 396.52064; ... 163.28492, 411.37102; ... 142.81752, 391.16355; ... 111.95404, 346.70264; ... 100.03538, 325.72710; ... 103.98723, 302.51587; ... 128.72978, 285.72802; ... 147.49111, 266.23345; ... 196.65261, 242.24055; ... 213.56835, 221.67192; ... 226.49969, 198.09326; ... 248.37126, 183.50473; ... 262.21952, 165.39102; ... 278.42330, 149.91715; ... 300.71846, 145.82601; ... 311.12698, 166.71094; ... 326.66315, 184.58335; ... 359.78574, 225.48049; ... 357.08892, 252.88958; ... 358.76685, 285.34403; ... 361.50834, 303.71287; ... 371.68926, 314.92452; ... 380.49890, 324.58632; ... 396.37634, 328.88990; ... 412.59116, 327.25238; ... 425.48394, 315.28623; ... 435.84305, 302.44664; ... 458.34025, 297.55121; ... 479.66439, 288.99238; ... 493.09812, 270.20636; ... 518.87309, 264.56427; ... 547.18014, 268.18846; ... 600.49708, 240.62570; ... 625.96183, 238.40347; ... 633.90530, 260.70629; ... 621.50451, 285.88914; ... 576.87224, 322.14121; ... 570.51915, 348.85423; ... 567.16400, 378.24075; ... 558.00668, 406.86552; ... 565.19008, 435.75599; ... 567.56437, 465.33407; ... 550.87626, 490.96358; ... 532.98174, 515.84491; ... 500.66817, 551.89078; ... 478.75120, 562.17222; ... 430.03371, 583.94286; ... 401.20454, 587.69910; ... 368.32214, 581.10110; ... 354.26303, 585.86085; ... 346.75200, 601.10367; ... 332.85137, 628.74602; ... 308.02188, 645.84180; ... 295.52344, 647.18525; ... 286.51519, 651.60328; ... 285.98846, 662.07339; ... 298.93455, 665.66316; ... 301.70226, 682.79570; ... 278.65857, 689.63850; ... 266.25737, 712.11005; ... 287.28701, 732.77147; ... 318.19548, 736.85151; ... 343.83067, 753.60957; ... 375.53164, 758.35231; ... 405.73444, 768.98687; ... 406.33873, 785.59001; ... 378.35436, 789.44240; ... 350.02151, 795.02238; ... 338.68030, 788.87325; ... 325.67930, 786.10177; ... 319.05995, 798.04657; ... 301.78158, 795.34254; ... 280.69272, 773.86634; ... 254.55844, 758.02898; ... 234.07759, 737.42090; ... 218.38337, 711.41500; ... 220.99086, 682.17833; ... 224.50640, 651.96297; ... 240.25971, 631.36117; ... 259.86174, 612.60253; ... 291.85381, 556.70385; ... 315.52139, 537.56387; ... 341.63663, 520.12519; ... 351.37130, 458.75372; ... 349.33183, 431.31454; ... 328.80465, 412.43055; ... 238.64853, 266.58978; ... 235.14026, 287.95183; ... 238.20736, 303.46785; ... 250.13902, 303.71290; ... 258.51675, 297.46973; ... 274.55300, 291.27357; ... 284.66230, 280.72063; ... 279.73288, 267.83455; ... 270.68478, 255.55440; ... 255.73801, 249.16872; ... 241.72690, 256.73448 ]; [ 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 ( 'p14_mesh.eps', node_num, p, tri_num, ... t, node_show, triangle_show ); % % Write a text file containing the nodes. % r8mat_write ( 'p14_nodes.txt', 2, node_num, p ); % % Write a text file containing the triangles. % i4mat_write ( 'p14_elements.txt', 3, tri_num, t ); return end