function convective_rolls_test ( )

%*****************************************************************************80
%
%% convective_rolls_test plots data computed by FreeFem++.
%
%  Discussion:
%
%    Free convection problem between two parallel plates.
%
%  Licensing:
%
%    Copyright (C) 2018 Chloros2 <chloros2@gmx.de>
%
%    This program is free software: you can redistribute it and/or modify it
%    under the terms of the GNU General Public License as published by
%    the Free Software Foundation, either version 3 of the License, or
%    (at your option) any later version.
%
%    This program is distributed in the hope that it will be useful, but
%    WITHOUT ANY WARRANTY; without even the implied warranty of
%    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
%    GNU General Public License for more details.
%
%    You should have received a copy of the GNU General Public License
%    along with this program.  If not, see
%    <https://www.gnu.org/licenses/>.
%
%  Modified:
%
%    2018-05-13
%
%  Author:
%
%    Chloros2 <chloros2@gmx.de>
%    Modifications by John Burkardt.
%
  addpath ( '../ffmatlib' );

  timestamp ( );
  fprintf ( 1, '\n' );
  fprintf ( 1, 'convective_rolls_test:\n' );
  fprintf ( 1, '  MATLAB/Octave version %s\n', version ( ) );
  fprintf ( 1, '  Make plots of the solution to the Laplace equation\n' );
  fprintf ( 1, '  for convective rolls of a fluid heated from below,\n' );
  fprintf ( 1, '  as computed by FreeFem++, using the ffmatlib ( ) interface.\n' );

  clear ( 'all' );
%
%  Reads the FreeFem++ data.
%
  [ p, b, t ] = ffreadmesh ( 'convective_rolls.msh' );
  [ vh ] = ffreaddata ( 'convective_rolls_vh.txt' );
  [ qh ] = ffreaddata ( 'convective_rolls_qh.txt' );
  [ Tfluid ] = ffreaddata ( 'convective_rolls_temperature.txt' );
  [ psi ] = ffreaddata ( 'convective_rolls_psi.txt' );
  [ vx, vy ] = ffreaddata ( 'convective_rolls_ux_uy.txt' );

  figure ( ...
    'Resize','off', ...
    'ToolBar','none', ...
    'MenuBar','none', ...
    'Position',[50 50 1000 460] );
%
%  Combine Patch and Contour with different data
%  Scalar data overlayed with extra contour data from a different origin
%  like a weather forecast plot employing a temperature patch plot
%  with overlayed isolevel pressure values.
%
%  Patch plot of a temperature
%
  subplot ( 2, 1, 1 );

  ffpdeplot ( p, b, t, ...
    'vhseq',qh, ...
    'XYData',Tfluid, ...
    'ColorMap','jet', ...
    'CBTitle','T[degC]', ...
    'Title','Stream lines + Temperature' );

  hold ( 'on' );
%
%  Add stream lines.
%
  ffpdeplot ( p, b, t, ...
    'vhseq',qh, ...
    'XYData',psi, ...
    'XYStyle','off', ...
    'Contour','on', ...
    'CGridParam',[150, 150], ...
    'CStyle','dashedneg', ...
    'ColorMap','off', ...
    'ColorRange','off', ...
    'ColorBar','off' );

  ylabel ( 'y' );
  xlabel ( 'x' );
  axis ( 'tight' );
%
%  Combine Quiver and Patch.
%
  subplot ( 2, 1, 2 );

  ffpdeplot ( p, b, t, ...
    'vhseq',qh, ...
    'XYData',Tfluid, ...
    'ColorMap','jet', ...
    'CBTitle','T[degC]', ...
    'Title','Velocity + Temperature' );

  hold ( 'on' );

  ffpdeplot ( p, b, t, ...
    'vhseq',vh, ...
    'FlowData',[vx, vy], ...
    'FGridParam',[60, 15] );

  ylabel ( 'y' );
  xlabel ( 'x' );
  axis ( 'tight' );

  filename = 'convective_rolls_vector.png';
  print ( '-dpng', filename );
  fprintf ( 1, '  Graphics saved as "%s"\n', filename );
%
%  Contour plot
%
  figure ( ...
    'Resize','off', ...
    'ToolBar','none', ...
    'MenuBar','none', ...
    'Position',[50 50 1000 460] );

  subplot ( 2, 1, 1 );

  ffpdeplot ( p, b, t, ...
    'vhseq',qh, ...
    'XYData',psi, ...
    'Contour','on', ...
    'XYStyle','off', ...
    'CGridParam',[150, 150], ...
    'ColorMap','jet', ...
    'CColor','flat', ...
    'CBTitle','psi [(m^3/s)/m]', ...
    'Title','Streamlines' );

  ylabel ( 'y' );
  xlabel ( 'x' );
  axis ( 'tight' );

  subplot ( 2, 1, 2 );
%
%  Isotherms
%
  ffpdeplot ( p, b, t, ...
    'vhseq',qh, ...
    'XYData',Tfluid, ...
    'Contour','on', ...
    'ColorMap','jet', ...
    'CStyle','solid', ...
    'CColor','k', ...
    'CGridParam',[150, 150], ...
    'CBTitle','dT [K]', ...
    'Title','Isotherms' );

  ylabel ( 'y' );
  xlabel ( 'x' );
  axis ( 'tight' );

  filename = 'convective_rolls_contour.png';
  print ( '-dpng', filename );
  fprintf ( 1, '  Graphics saved as "%s"\n', filename );
%
%  Terminate.
%
  fprintf ( 1, '\n' );
  fprintf ( 1, 'convective_rolls_test:\n' );
  fprintf ( 1, '  Normal end of execution.\n' );
  timestamp ( );

  rmpath ( '../ffmatlib' );

  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

