function mesh_boundary_test ( )

%*****************************************************************************80
%
%% mesh_boundary_test() tests mesh_boundary().
%
%  Licensing:
%
%    This code is distributed under the MIT license.
%
%  Modified:
%
%    17 December 2022
%
%  Author:
%
%    John Burkardt
%
  addpath ( '../mesh_boundary' );

  timestamp ( );
  fprintf ( 1, '\n' );
  fprintf ( 1, 'mesh_boundary_test():\n' );
  fprintf ( 1, '  MATLAB/Octave version %s\n', version ( ) );
  fprintf ( 1, '  Test mesh_boundary()\n' );

  mesh_boundary_test_square ( );
  mesh_boundary_test_beam ( );
  mesh_boundary_test_ell ( );
%
%  Terminate.
%
  fprintf ( 1, '\n' );
  fprintf ( 1, 'mesh_boundary_test():\n' );
  fprintf ( 1, '  Normal end of execution.\n' );
  fprintf ( 1, '\n' );
  timestamp ( );

  rmpath ( '../mesh_boundary' );

  return
end
function mesh_boundary_test_square ( )

%*****************************************************************************80
%
%% mesh_boundary_test_square() tests a simple quadrilateral mesh.
%
%  Discussion:
%
%    Consider the following simple quadrilateral mesh:
%
%      1---2---3
%      |   |   |
%      4---5---6
%      |   |   |
%      7---8---9
%
%    for which the element array is:
%
%      element_node = [
%        [ 4, 5, 2, 1 ],
%        [ 5, 6, 3, 2 ],
%        [ 7, 8, 5, 4 ],
%        [ 8, 9, 6, 5 ] ]
%
%    The boundary segments array should be computed as: 
%
%      boundary_segments = [
%        [ 1, 4 ]
%        [ 4, 7 ],
%        [ 7, 8 ],
%        [ 8, 9 ],
%        [ 9, 6 ],
%        [ 6, 3 ],
%        [ 3, 2 ],
%        [ 2, 1 ] ]
%
%  Licensing:
%
%    This code is distributed under the MIT license.
%
%  Modified:
%
%    17 December 2022
%
%  Author:
%
%    John Burkardt
%
  fprintf ( 1, '\n' );
  fprintf ( 1, 'mesh_boundary_test_square():\n' );
  fprintf ( 1, '  Boundary of a 4-quadrilateral mesh.\n' );
  element_node = [ ...
    4, 5, 2, 1; ...
    5, 6, 3, 2; ...
    7, 8, 5, 4; ...
    8, 9, 6, 5 ];

  fprintf ( 1, '\n' );
  fprintf ( 1, '  element_node array:\n' );
  disp ( element_node );

  boundary_segments = mesh_boundary ( element_node );

  fprintf ( 1, '\n' );
  fprintf ( 1, '  boundary segments returned by mesh_boundary():\n' );
  disp ( boundary_segments );

  return
end
function mesh_boundary_test_beam ( )

%*****************************************************************************80
%
%% mesh_boundary_test_beam() tests a beam quadrilateral mesh.
%
%  Discussion:
%
%    This example is available as mfem file beam-quad.mesh
%
%    Consider the following simple quadrilateral mesh:
%
%      9--10--11--12--13--14--15--16--17
%      |   |   |   |   |   |   |   |   |
%      0---1---2---3---4---5---6---7---8
%
%    for which the element array is:
%
%      element_node = [
%        0,  1, 10,  9; ...
%        1,  2, 11, 10; ...
%        2,  3, 12, 11; ...
%        3,  4, 13, 12; ...
%        4,  5, 14, 13; ...
%        5,  6, 15, 14; ...
%        6,  7, 16, 15; ...
%        7,  8, 17, 16 ]
%
%    The boundary segments array should be computed as: 
%
%      boundary_segments = [
%        [  0,  1 ]
%        [  1,  2 ],
%        [  2,  3 ],
%        [  3,  4 ],
%        [  4,  5 ],
%        [  5,  6 ],
%        [  6,  7 ],
%        [  7,  8 ],
%        [  8, 17 ]
%        [ 17, 16 ],
%        [ 16, 15 ],
%        [ 15, 14 ],
%        [ 14, 13 ],
%        [ 13, 12 ],
%        [ 12, 11 ],
%        [ 11, 10 ],
%        [ 10,  9 ],
%        [  9,  0 ] ]
%
%  Licensing:
% 
%    This code is distributed under the MIT license.
%
%  Modified:
%
%    17 December 2022
%
%  Author:
%
%    John Burkardt
%
  fprintf ( 1, '\n' );
  fprintf ( 1, 'mesh_boundary_test_beam():\n' );
  fprintf ( 1, '  Boundary of an 8-quadrilateral mesh.\n' );

  element_node = [ ...
    0,  1, 10,  9; ...
    1,  2, 11, 10; ...
    2,  3, 12, 11; ...
    3,  4, 13, 12; ...
    4,  5, 14, 13; ...
    5,  6, 15, 14; ...
    6,  7, 16, 15; ...
    7,  8, 17, 16 ];

  fprintf ( 1, '\n' );
  fprintf ( 1, '  element_node array:\n' );
  disp ( element_node );

  boundary_segments = mesh_boundary ( element_node );

  fprintf ( 1, '\n' );
  fprintf ( 1, '  boundary segments returned by mesh_boundary():\n' );
  disp ( boundary_segments );

  return
end
function mesh_boundary_test_ell ( )

%*****************************************************************************80
%
%% mesh_boundary_test_ell() tests a triangular mesh.
%
%  Discussion:
%
%    Consider the following triangular mesh of the L-shaped region:
%
%      5--10--15
%      | \ | \ |
%      4---9--14
%      | \ | \ |
%      3---8--13--18--21--24
%      | \ | \ | \ | \ | \ |
%      2---7--12--17--20--23
%      | \ | \ | \ | \ | \ |
%      1---6--11--16--19--22
%
%    for which the element array is:
%
%      element_node = [
%        1,  6,  2;
%        7,  2,  6;
%        2,  7,  3;
%        8,  3,  7;
%        3,  8,  4;
%        9,  4,  8;
%        4,  9,  5;
%       10,  5,  9;
%        6, 11,  7;
%       12,  7, 11;
%        7, 12,  8;
%       13,  8, 12;
%        8, 13,  9;
%       14,  9, 13;
%        9, 14, 10;
%       15, 10, 14;
%       11, 16, 12;
%       17, 12, 16;
%       12, 17, 13;
%       18, 13, 17;
%       16, 19, 17;
%       20, 17, 19;
%       17, 20, 18;
%       21, 18, 20;
%       19, 22, 20;
%       23, 20, 22;
%       20, 23, 21;
%       24, 21, 23 ]
%
%    The boundary segments array should be computed as: 
%
%      boundary_segments = [
%        [  1,  6 ]
%        [  6, 11 ],
%        [ 11, 16 ],
%        [ 16, 19 ],
%        [ 19, 22 ],
%        [ 22, 23 ],
%        [ 23, 24 ],
%        [ 24, 21 ],
%        [ 21, 18 ]
%        [ 18, 13 ],
%        [ 13, 14 ],
%        [ 14, 15 ],
%        [ 15, 10 ],
%        [ 10,  5 ],
%        [  5,  4 ],
%        [  4,  3 ],
%        [  3,  2 ],
%        [  2,  1 ],
%
%  Licensing:
% 
%    This code is distributed under the MIT license.
%
%  Modified:
%
%    17 December 2022
%
%  Author:
%
%    John Burkardt
%
  fprintf ( 1, '\n' );
  fprintf ( 1, 'mesh_boundary_test_ell():\n' );
  fprintf ( 1, '  Boundary of an 24-triangle mesh.\n' );

  element_node = [ ...
     1,  6,  2; ...
     7,  2,  6; ...
     2,  7,  3; ...
     8,  3,  7; ...
     3,  8,  4; ...
     9,  4,  8; ...
     4,  9,  5; ...
    10,  5,  9; ...
     6, 11,  7; ...
    12,  7, 11; ...
     7, 12,  8; ...
    13,  8, 12; ...
     8, 13,  9; ...
    14,  9, 13; ...
     9, 14, 10; ...
    15, 10, 14; ...
    11, 16, 12; ...
    17, 12, 16; ...
    12, 17, 13; ...
    18, 13, 17; ...
    16, 19, 17; ...
    20, 17, 19; ...
    17, 20, 18; ...
    21, 18, 20; ...
    19, 22, 20; ...
    23, 20, 22; ...
    20, 23, 21; ...
    24, 21, 23 ];

  fprintf ( 1, '\n' );
  fprintf ( 1, '  element_node array:\n' );
  disp ( element_node );

  boundary_segments = mesh_boundary ( element_node );

  fprintf ( 1, '\n' );
  fprintf ( 1, '  boundary segments returned by mesh_boundary():\n' );
  disp ( boundary_segments );

  return
end
function timestamp ( )

%*****************************************************************************80
%
%% timestamp() prints the current YMDHMS date as a timestamp.
%
%  Licensing:
%
%    This code is distributed under the MIT license.
%
%  Modified:
%
%    14 November 2022
%
%  Author:
%
%    John Burkardt
%
  t = now ( );
  c = datevec ( t );
  s = datestr ( c, 0 );
  fprintf ( 1, '%s\n', s );

  return
end

