function ShowSolutionM(nodes,elem,u);
%ShowSolutionM(...)
%  shows a graph of a numerical solution of the PDE
%
%ShowSolutionM(nodes,elem,u);
%nodes, elem contain information about the mesh
%         see ReadMesh() for the description of the format
%u   contains the values of the solution at the nodes
%
%see also ReadMesh, ShowMesh, FEMEquation, FEMSolve, FEMValue

% the current version writes data to disk, to be read by Gnuplot

if (nargin!=3) 
  help("ShowSolutionM"); usage("ShowSolutionM(nodes,elem,u)");
endif

[fid,msg]=fopen("/tmp/meshdata.gnu","w");

% dummy line to prevent gnuplot from displaying a grid
fprintf(fid,"%g %g %g\n\n",  0,0,0 );

% the mesh
for k=1:length(elem);
  fprintf(fid,"%g %g %g\n",nodes(elem(k,1),1:2), u(elem(k,1)) );
  fprintf(fid,"%g %g %g\n",nodes(elem(k,2),1:2), u(elem(k,2)) );
  fprintf(fid,"%g %g %g\n",nodes(elem(k,3),1:2), u(elem(k,3)) );
  fprintf(fid,"%g %g %g\n\n",nodes(elem(k,1),1:2), u(elem(k,1)) );
endfor
fclose(fid);

gset view 60, 30
% gsplot  "/tmp/meshdata.gnu" with lines 3 ,"/tmp/meshdata.gnu" with points 12
gsplot  "/tmp/meshdata.gnu" with lines 3
endfunction

