%#########################################################################%
%					Numerics of Partial Differential Equations, Exercise 9.1				%
%		University of Konstanz, Winter semester 2016/2017, Prof. Dr. Volkwein	%
%		Author: Dennis Beermann, dennis.beermann@uni.kn												%
%#########################################################################%

function plot_solution( grid, u )
% Plot a grid function u belonging to the grid

  %% Check input:
  assert(isvector(u) && length(u)==grid.Np);
  
  %% Write the solution ndgrid:
  U = nan(size(grid.X1));
  linearInd    = sub2ind(size(U),grid.listP2X(1,:),grid.listP2X(2,:));
  U(linearInd) = u;
  
  %% Plot using the surface command:
  figure;
  surf(grid.X1,grid.X2,U);
  
end