function paraheat_functional_test ( )

%*****************************************************************************80
%
%% paraheat_functional_test() tests paraheat_functional().
%
%  Discussion:
%
%    This program sets up sample parameters sets "vc" as input to the
%    paraheat_functional() program, and saves the resulting sensor
%    measurements "vs".  
%
%    The sets of pairs (vc,vs) are written out to a file.
%
%    The "vc" values specify a piecewise constant diffusivity function,
%    which is used when solving a steady heat equation in a 2D domain with
%    zero Dirichlet boundary conditions and a right hand side function f(x,y).
%    The computed solution is then sampled at 50 sensor locations, which
%    are returned as the values "vs".
%
%    For details, see the paraheat_functional() program.
%
%  Licensing:
%
%    This code is distributed under the MIT license.
%
%  Modified:
%
%    17 April 2019
%
%  Author:
%
%    John Burkardt
%
  addpath ( '../paraheat_functional' );

  timestamp ( );
  fprintf ( 1, '\n' );
  fprintf ( 1, 'paraheat_functional_test():\n' );
  fprintf ( 1, '  MATLAB/Octave version %s\n', version ( ) );
  fprintf ( 1, '  Test paraheat_functional\n' );
  fprintf ( 1, '  which accepts diffusivity parameters as input,\n' );
  fprintf ( 1, '  solves a certain steady heat equation problem\n' );
  fprintf ( 1, '  and returns the solution value at selected locations.\n' );

  sample_num = 5;
  sample_num = 2;
  diffusivity_seed = 123456789;
  nxc = 4;
  nyc = 4;
  ns = 50;

  fprintf ( 1, '\n' );
  fprintf ( 1, '  Generating %d random diffusivity cases.\n', sample_num );
  fprintf ( 1, '  The initial random number seed is %d\n', diffusivity_seed );
  fprintf ( 1, '  Each case involves:\n' );
  fprintf ( 1, '    1 diffusivity seed,\n' );
  fprintf ( 1, '    %d diffusivity parameters,\n', nxc * nyc );
  fprintf ( 1, '    %d sensor readings.\n', ns );

  data = zeros ( sample_num, 1 + nxc * nyc + ns );

  for i = 1 : sample_num

    rng ( diffusivity_seed );
    fprintf ( 1, '\n' );
    fprintf ( 1, '  Case %d, diffusivity_seed = %d\n', i, diffusivity_seed );

    vc = 0.5 + 5.0 * rand ( nxc, nyc );

    vs = paraheat_functional ( vc );

    vc = reshape ( vc, 1, nxc * nyc );
    vs = reshape ( vs, 1, ns );
    data(i,:) = [ diffusivity_seed, vc, vs ];

    diffusivity_seed = diffusivity_seed + 1;

  end

  filename = 'paraheat_data.txt';
  save ( filename, 'data', '-ascii' );

  fprintf ( 1, '\n' );
  fprintf ( 1, '  %d by %d array of data written to "%s"\n', ...
    sample_num, 1 + nxc * nyc + ns, filename );
%
%  Terminate.
%
  fprintf ( 1, '\n' );
  fprintf ( 1, 'paraheat_functional_test():\n' );
  fprintf ( 1, '  Normal end of execution.\n' );
  fprintf ( 1, '\n' );
  timestamp ( );

  rmpath ( '../paraheat_functional' );

  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
