function helmholtz_exact_test ( )

%*****************************************************************************80
%
%% helmholtz_exact_test() tests helmholtz_exact().
%
%  Licensing:
%
%    This code is distributed under the MIT license.
%
%  Modified:
%
%    08 July 2024
%
%  Author:
%
%    John Burkardt
%
  addpath ( '../helmholtz_exact' );

  timestamp ( );
  fprintf ( 1, '\n' );
  fprintf ( 1, 'helmholtz_exact_test():\n' );
  fprintf ( 1, '  MATLAB/Octave version %s\n', version ( ) );   
  fprintf ( 1, '  Test helmholtz_exact().\n' );

  m = 0;
  n = 1;
  helmholtz_exact_plot ( m, n );

  m = 1;
  n = 2;
  helmholtz_exact_plot ( m, n );

  m = 2;
  n = 3;
  helmholtz_exact_plot ( m, n );
%
%  Terminate.
%
  fprintf ( 1, '\n' );
  fprintf ( 1, 'helmholtz_exact_test():\n' );
  fprintf ( 1, '  Normal end of execution.\n' );
  fprintf ( 1, '\n' );
  timestamp ( );

  rmpath ( '../helmholtz_exact' );

  return
end
function helmholtz_exact_plot ( m, n )

%*****************************************************************************80
%
%% helmholtz_exact_plot() plots an exact solution of the Helmholtz equation.
%
%  Discussion:
%
%    The solution is assumed to have a simple form depending on the n-th
%    J Bessel function and its m-th root.
%
%  Licensing:
%
%    This code is distributed under the MIT license.
%
%  Modified:
%
%    08 July 2024
%
%  Author:
%
%    John Burkardt
%
%  Input:
%
%    integer m: the index of the root of the Bessel function J(n,x).
%
%    integer n: the index of the Bessel function.
%
  a = 1.5;

  alpha = 4.0;
  beta = 3.0;
  gamma = 2.0;

  nt = 48;
  nr = 20;
  t = linspace ( 0.0, 2.0 * pi, nt + 1 );
  t = t(1:nt);
  r = linspace ( 0.0, 1.0, nr );
  r = sqrt ( r );
  r = r * a;

  nxy = ( nr - 1 ) * nt + 1;
  X = zeros ( nxy, 1 );
  Y = zeros ( nxy, 1 );
  nxy = 0;
  for i = 1 : nt
    for j = 1 : nr
      if ( j == 1 && 1 < i )
        continue;
      else
        nxy = nxy + 1;
        X(nxy) = r(j) * cos ( t(i) );
        Y(nxy) = r(j) * sin ( t(i) );
      end
    end
  end
%
%  Evaluate the exact solution Z at the points (X,Y).
%
  Z = helmholtz_exact ( a, m, n, alpha, beta, gamma, nxy, X, Y );
%
%  Triangulate the (X,Y) points.
%
  T = delaunayn ( [ X(:), Y(:) ] );
%
%  Make a surface plot of Z(X,Y).
%
  trisurf ( T, X, Y, Z, 'FaceColor', 'interp', 'EdgeColor', 'none' );
  az = - 37.5;
  el = 30.0;
  view ( az, el );

  filename = sprintf ( 'helmholtz_exact_m%d_n%d.png', m, n );
  print ( '-dpng', filename );
  fprintf ( 1, '  Graphics saved as "%s"\n', filename );

  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 February 2003
%
%  Author:
%
%    John Burkardt
%
  t = now;
  c = datevec ( t );
  s = datestr ( c, 0 );
  fprintf ( 1, '%s\n', s );

  return
end

