function poisson_ell_test ( )

%*****************************************************************************80
%
%% poisson_ell_test() plots data computed by FreeFem++.
%
%  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, 'poisson_ell_test():\n' );
  fprintf ( 1, '  MATLAB/Octave version %s\n', version ( ) );
  fprintf ( 1, '  Make plots of the solution to the Poisson equation\n' );
  fprintf ( 1, '  in the L-shaped region, as computed by FreeFem++,\n' );
  fprintf ( 1, '  using the ffmatlib ( ) interface.\n' );

  clear ( 'all' );
%
%  Read the data from the FreeFem++ computation.
%
  [ p, b, t ] = ffreadmesh ( 'poisson_ell.msh' );
  [ vhseq ] = ffreaddata ( 'poisson_ell_vh.txt' );
  [ u, vx, vy ] = ffreaddata ( 'poisson_ell_data.txt' );
%
%  2D Mesh Plot
%
  figure ( );
  ffpdeplot ( p, b, t, ...
    'Mesh','on', ...
    'Title','Mesh without boundary' );

  filename = 'poisson_ell_plot01.png';
  print ( '-dpng', filename );
  fprintf ( 1, '  Graphics saved as "%s"\n', filename );
  close ( );
%
%  2D Mesh Plot including Boundary
%
  figure ( );
  ffpdeplot ( p, b, t, ...
    'Mesh','on', ...
    'Boundary','on', ...
    'Title','Mesh with boundary' );

  filename = 'poisson_ell_plot02.png';
  print ( '-dpng', filename );
  fprintf ( 1, '  Graphics saved as "%s"\n', filename );
  close ( );
%
%  Boundary only
%
  figure ( );
  ffpdeplot ( p, b, t, ...
    'Boundary','on', ...
    'Title','Boundary only' );

  filename = 'poisson_ell_plot03.png';
  print ( '-dpng', filename );
  fprintf ( 1, '  Graphics saved as "%s"\n', filename );
  close ( );
%
%  2D PDE Map Plot
%
  figure ( );
  ffpdeplot ( p, b, t, ...
    'XYData',u, ...
    'VhSeq',vhseq, ...
    'Title','2D Density Plot' );

  filename = 'poisson_ell_plot04.png';
  print ( '-dpng', filename );
  fprintf ( 1, '  Graphics saved as "%s"\n', filename );
  close ( );
%
%  2D PDE ColorMap Plot
%
  figure ( );
  mymap = 'jet';
  ffpdeplot ( p, b, t, ...
    'XYData',u, ...
    'VhSeq',vhseq, ...
    'ColorMap',mymap, ...
    'Title',strcat('2D Density Plot - ColMap: ',mymap) );

  filename = 'poisson_ell_plot05.png';
  print ( '-dpng', filename );
  fprintf ( 1, '  Graphics saved as "%s"\n', filename );
  close ( );
%
%  2D PDE Map Plot - customized HSV Map
%
  figure ( );
  hsv = [ ...
    4./6., 1.0, 0.5; ...
    4./6., 1.0, 1.0; ...
    5./6., 1.0, 1.0; ...
    1,     1.0, 1.0; ...
    1,     0.5, 1.0 ];

  [sz1,~] = size(hsv);
  cm_data = interp1(linspace(0,1,sz1),hsv,linspace(0,1,64));
  usedmap = hsv2rgb(cm_data);
  ffpdeplot ( p, b, t, ...
    'XYData',u,'VhSeq',vhseq, ...
    'ColorMap',usedmap, ...
    'Title','2D Density Plot HSV custom MAP' );

  filename = 'poisson_ell_plot06.png';
  print ( '-dpng', filename );
  fprintf ( 1, '  Graphics saved as "%s"\n', filename );
  close ( );
%
%  2D PDE Map Plot with Mesh
%
  figure ( );
  ffpdeplot ( p, b, t, ...
    'XYData',u, ...
    'VhSeq',vhseq, ...
    'Mesh','on', ...
    'Title','2D Density Plot with Mesh' );

  filename = 'poisson_ell_plot07.png';
  print ( '-dpng', filename );
  fprintf ( 1, '  Graphics saved as "%s"\n', filename );
  close ( );
%
%  2D PDE Map Plot with Mesh
%
  figure ( );
  ffpdeplot ( p, b, t, ...
    'XYData',u, ...
    'VhSeq',vhseq, ...
    'Mesh','on', ...
    'XYStyle', 'off', ...
    'ColorBar','off', ...
    'ColorMap','off', ...
    'ColorRange','off', ...
    'Title','2D Density Plot with Mesh without color (XYStyle)' );

  filename = 'poisson_ell_plot08.png';
  print ( '-dpng', filename );
  fprintf ( 1, '  Graphics saved as "%s"\n', filename );
  close ( );
%
%  2D PDE Map Plot with Mesh without Colorbar
%
  figure ( );
  ffpdeplot ( p, b, t, ...
    'XYData',u, ...
    'VhSeq',vhseq, ...
    'Mesh','on', ...
    'ColorBar','off', ...
    'Title','2D Density Plot with Mesh without Colbar' );

  filename = 'poisson_ell_plot09.png';
  print ( '-dpng', filename );
  fprintf ( 1, '  Graphics saved as "%s"\n', filename );
  close ( );
%
%  2D PDE Map Plot with Mesh with Colorbar North
%
  figure ( );
  ffpdeplot ( p, b, t, ...
    'XYData',u, ...
    'VhSeq',vhseq, ...
    'Mesh','on', ...
    'ColorBar','on', ...
    'ColorBar','northoutside', ...
    'Title','2D Density Plot with Mesh Colbar north' );

  filename = 'poisson_ell_plot10.png';
  print ( '-dpng', filename );
  fprintf ( 1, '  Graphics saved as "%s"\n', filename );
  close ( );
%
%  3D Surface
%
  figure ( );
  ffpdeplot ( p, b, t, ...
    'XYData',u, ...
    'VhSeq',vhseq, ...
    'ZStyle','continuous', ...
    'Title','Classic 3D Surf Plot' );

  filename = 'poisson_ell_plot11.png';
  print ( '-dpng', filename );
  fprintf ( 1, '  Graphics saved as "%s"\n', filename );
  close ( );
%
%  3D Surface Lighting
%
  figure ( );
  ffpdeplot ( p, b, t, ...
    'XYData',u, ...
    'VhSeq',vhseq, ...
    'ZStyle','continuous', ...
    'Title','Classic 3D Surf Plot Gouraud' );

  lighting ( 'gouraud' );
  view ( [-166,40] );
  camlight ( 'left' );
  grid ( 'on' );

  filename = 'poisson_ell_plot12.png';
  print ( '-dpng', filename );
  fprintf ( 1, '  Graphics saved as "%s"\n', filename );
  close ( );
%
%  3D Surface Map-Patch including Mesh
%
  figure ( );
  ffpdeplot ( p, b, t, ...
    'XYData',u, ...
    'VhSeq',vhseq, ...
    'ZStyle','continuous', ...
    'Mesh','on', ...
    'Title','3D Surf Plot including Mesh' );

  filename = 'poisson_ell_plot13.png';
  print ( '-dpng', filename );
  fprintf ( 1, '  Graphics saved as "%s"\n', filename );
  close ( );
%
%  3D Mesh monochrome
%
  figure ( );
  ffpdeplot ( p, b, t, ...
    'XYData',u, ...
    'VhSeq',vhseq, ...
    'ZStyle','continuous', ...
    'Mesh','on', ...
    'XYStyle','off', ...
    'ColorBar','off', ...
    'ColorMap','off', ...
    'ColorRange','off', ...
    'Title','3D Mesh Plot - Monochrome (XYStyle)' );

  filename = 'poisson_ell_plot14.png';
  print ( '-dpng', filename );
  fprintf ( 1, '  Graphics saved as "%s"\n', filename );
  close ( );
%
%  Contour Plot wo patch monochrome
%
  figure ( );
  ffpdeplot ( p, b, t, ...
    'XYData',u, ...
    'VhSeq',vhseq, ...
    'Boundary','on', ...
    'Contour','on', ...
    'XYStyle', 'off', ...
    'CColor', [0,0,1], ...
    'ColorBar','off', ...
    'ColorMap','off', ...
    'ColorRange','off', ...
    'Title','Monochrome (blue) Contour without patch' );

  filename = 'poisson_ell_plot15.png';
  print ( '-dpng', filename );
  fprintf ( 1, '  Graphics saved as "%s"\n', filename );
  close ( );
%
%  Contour Plot without patch flat (colored isolevels)
%
  figure ( );
  ffpdeplot ( p, b, t, ...
    'XYData',u, ...
    'VhSeq',vhseq, ...
    'Boundary','on', ...
    'Contour','on', ...
    'XYStyle', 'off', ...
    'CColor', 'flat', ...
    'ColorMap','jet', ...
    'Title','Flat Contour without patch (colored isolevels)' );

  filename = 'poisson_ell_plot16.png';
  print ( '-dpng', filename );
  fprintf ( 1, '  Graphics saved as "%s"\n', filename );
  close ( );
%
%  Contour Plot Mixed with 2D Patch
%
  figure ( );
  ffpdeplot ( p, b, t, ...
    'XYData',u, ...
    'VhSeq',vhseq, ...
    'Boundary','on', ...
    'Contour','on', ...
    'Title','Contour mixed with Patch Plot' );

  filename = 'poisson_ell_plot17.png';
  print ( '-dpng', filename );
  fprintf ( 1, '  Graphics saved as "%s"\n', filename );
  close ( );
%
%  Contour Plot Mixed with 2D Patch dashed lines
%
  figure ( );
  ffpdeplot ( p, b, t, ...
    'XYData',u, ...
    'VhSeq',vhseq, ...
    'Boundary','on', ...
    'Contour','on',  ...
    'CStyle', 'dashed', ...
    'Title','Contour mixed with Patch Plot - dashed lines' );

  filename = 'poisson_ell_plot18.png';
  print ( '-dpng', filename );
  fprintf ( 1, '  Graphics saved as "%s"\n', filename );
  close ( );
%
%  Contour Plot
%
  figure ( );
  ffpdeplot ( p, b, t, ...
    'XYData',u, ...
    'VhSeq',vhseq, ...
    'Boundary','on', ...
    'Contour','on', ...
    'CGridParam',[10,10], ...
    'CLevels',15, ...
    'Title','Contour Plot with ugly set GridParam' );

  filename = 'poisson_ell_plot19.png';
  print ( '-dpng', filename );
  fprintf ( 1, '  Graphics saved as "%s"\n', filename );
  close ( );
%
%  Contour Plot with Labels
%
  figure ( );
  [ handles, clab ] = ffpdeplot ( p, b, t, ...
    'XYData',u, ...
    'VhSeq',vhseq, ...
    'Boundary','on', ...
    'Contour','on', ...
    'CLevels',5, ...
    'Title','Contour mixed with Patch Plot with Labels' );

  texth = clabel(clab,handles(3),'fontsize', 8);
  for i = 1 : size(texth)
    textstr = get(texth(i),'String');
    textnum = str2double(textstr);
    textstrnew = sprintf('%0.3f', textnum);
    set ( texth(i), 'String', textstrnew );
  end

  filename = 'poisson_ell_plot20.png';
  print ( '-dpng', filename );
  fprintf ( 1, '  Graphics saved as "%s"\n', filename );
  close ( );
%
%  2D PDE Map Plot axis limits
%
  figure ( );
  ffpdeplot ( p, b, t, ...
    'XYData',u, ...
    'VhSeq',vhseq, ...
    'XLim',[-0.25 0.75], ...
    'YLim',[0.25 1.25], ...
    'Title','2D Map Patch Plot with Limits' );

  filename = 'poisson_ell_plot21.png';
  print ( '-dpng', filename );
  fprintf ( 1, '  Graphics saved as "%s"\n', filename );
  close ( );
%
%  3D Surface axis limits
%
  figure ( );
  ffpdeplot ( p, b, t, ...
    'XYData',u, ...
    'VhSeq',vhseq, ...
    'ZStyle','continuous', ...
    'XLim',[-0.25 0.75], ...
    'YLim',[0.25 1.25], ...
    'ZLim',[-0.1 0.1], ...
    'Title','3D Plot with xy and z-Limits' );

  filename = 'poisson_ell_plot22.png';
  print ( '-dpng', filename );
  fprintf ( 1, '  Graphics saved as "%s"\n', filename );
  close ( );
%
%  3D Surface aspect ratio
%
  figure ( );
  ffpdeplot ( p, b, t, ...
    'XYData',u, ...
    'VhSeq',vhseq, ...
    'ZStyle','continuous', ...
    'DAspect',[1 1 0.02], ...
    'Title','3D Plot Aspect ratio' );

  filename = 'poisson_ell_plot23.png';
  print ( '-dpng', filename );
  fprintf ( 1, '  Graphics saved as "%s"\n', filename );
  close ( );
%
%  2D PDE Map Plot ColorRange
%
  figure ( );
  ffpdeplot ( p, b, t, ...
    'XYData',u, ...
    'VhSeq',vhseq, ...
    'ColorRange',[0 0.1], ...
    'Title','3D Plot Color Range set Test' );

  filename = 'poisson_ell_plot24.png';
  print ( '-dpng', filename );
  fprintf ( 1, '  Graphics saved as "%s"\n', filename );
  close ( );
%
%  Autorange cropped section.
%
  figure ( );
  ffpdeplot ( p, b, t, ...
    'XYData',u, ...
    'VhSeq',vhseq, ...
    'ColorRange','cropminmax', ...
    'XLim',[0.00, 0.20], ...
    'YLim',[0.75, 1.25], ...
    'Title','Autorange Cropped Section' );

  filename = 'poisson_ell_plot25.png';
  print ( '-dpng', filename );
  fprintf ( 1, '  Graphics saved as "%s"\n', filename );
  close ( );
%
%  Autorange cropped section, symmetric o.
%
  figure ( );
  ffpdeplot ( p, b, t, ...
    'XYData',u, ...
    'VhSeq',vhseq, ...
    'ColorRange','cropcentered', ...
    'XLim',[0 0.2], ...
    'YLim',[0.75 1.25], ...
    'Title','Autorange Cropped Section, symmetric 0' );

  filename = 'poisson_ell_plot26.png';
  print ( '-dpng', filename );
  fprintf ( 1, '  Graphics saved as "%s"\n', filename );
  close ( );
%
%  Symmetric o
%
  figure ( );
  ffpdeplot ( p, b, t, ...
    'XYData',u, ...
    'VhSeq',vhseq, ...
    'ColorRange','centered', ...
    'Title','Symmetric o' );

  filename = 'poisson_ell_plot27.png';
  print ( '-dpng', filename );
  fprintf ( 1, '  Graphics saved as "%s"\n', filename );
  close ( );
%
%  Quiver
%
  figure ( );
  ffpdeplot ( p, b, t, ...
          'FlowData',[vx,vy],'VhSeq',vhseq,'Boundary','on', ...
          'Title','Quiver default' );

  axis ( 'tight' );

  filename = 'poisson_ell_plot28.png';
  print ( '-dpng', filename );
  fprintf ( 1, '  Graphics saved as "%s"\n', filename );
  close ( );
%
%  Quiver
%
  figure ( );
  ffpdeplot ( p, b, t, ...
    'FlowData',[vx,vy], ...
    'VhSeq',vhseq, ...
    'FGridParam',[26,30], ...
    'Boundary','on', ...
    'Title','Quiver Plot with GridParam' );

  axis ( 'tight' );

  filename = 'poisson_ell_plot29.png';
  print ( '-dpng', filename );
  fprintf ( 1, '  Graphics saved as "%s"\n', filename );
  close ( );
%
%  Superposition Quiver + 2D
%
  figure ( );

  ffpdeplot ( p, b, t, ...
    'XYData',u, ...
    'FlowData',[vx,vy], ...
    'VhSeq',vhseq, ...
    'FGridParam',[26,30], ...
    'Boundary','on', ...
    'Title','Quiver Plot combined with 2D Map Patch Plot' );

  axis ( 'tight' );

  filename = 'poisson_ell_plot30.png';
  print ( '-dpng', filename );
  fprintf ( 1, '  Graphics saved as "%s"\n', filename );
  close ( );
%
%  Terminate.
%
  fprintf ( 1, '\n' );
  fprintf ( 1, 'poisson_ell_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

