function mesh2d_to_medit_test ( )

%*****************************************************************************80
%
%% mesh2d_to_medit_test() tests mesh2d_to_medit().
%
%  Licensing:
%
%    This code is distributed under the MIT license.
%
%  Modified:
%
%    18 December 2022
%
%  Author:
%
%    John Burkardt
%
  addpath ( '../mesh2d' );
  addpath ( '../mesh2d_to_medit' );

  timestamp ( );

  fprintf ( 1, '\n' );
  fprintf ( 1, 'mesh2d_to_medit_test():\n' );
  fprintf ( 1, '  MATLAB/Octave version %s\n', version ( ) );
  fprintf ( 1, '  mesh2d() will mesh the L-shaped region.\n' );
  fprintf ( 1, '  mesh2d_to_medit() will write the mesh to a medit() MESH file.\n' );

  warning ( 'off' );

  fprintf ( 1, '\n' );
  fprintf ( 1, '  Set maximum element size HDATA.HMAX = 0.1\n' );

  v = [ 0.0, 0.0; 2.0, 0.0; 2.0, 1.0; 1.0, 1.0; 1.0, 2.0; 0.0, 2.0 ];

  hdata = [];
  hdata.hmax = 0.1;

  [ p, t ] = mesh2d ( v, [], hdata );

  [ nv, ~ ] = size ( v );
  [ np, ~ ] = size ( p );
  [ nt, ~ ] = size ( t );
  fprintf ( 1, '  %d boundary vertices input, %d nodes and %d triangles created\n', nv, np, nt );
  pause
%
%  Now call MESH2D_TO_MEDIT to write the data to a file.
%
  filename = 'ell.mesh';
  mesh2d_to_medit ( p, t, filename );

  fprintf ( 1, '\n' );
  fprintf ( 1, '  Wrote mesh data to MEDIT mesh file "%s"\n', filename );
%
%  Terminate.
%
  fprintf ( 1, '\n' );
  fprintf ( 1, 'mesh2d_to_medit_test():\n' );
  fprintf ( 1, '  Normal end of execution.\n' );

  timestamp ( );

  rmpath ( '../mesh2d' );
  rmpath ( '../mesh2d_to_medit' );

  return
end
function h = hfun1 ( x, y )

%*****************************************************************************80
%
%% hfun1() is a size-function for the L-shaped region.
%
%  Discussion:
%
%    The smallest size is at (1.0,1.0), and sizes increase as their distance
%    from that point increases.
%
  h = 0.01 + 0.1 * sqrt ( ( x - 1.0 ).^2  + ( y - 1.0 ).^2 );

  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

