diff --git a/pdeutils/functions/plotGridFunction.m b/pdeutils/functions/plotGridFunction.m index d7e6f662a5f93aaca00a472306b0435ec26edc9a..22ebad123f340db9602a0aa438fcd4b9b0165b10 100644 --- a/pdeutils/functions/plotGridFunction.m +++ b/pdeutils/functions/plotGridFunction.m @@ -1,11 +1,24 @@ function plotGridFunction(grid, basis, u) +%plotGridFunction Plots a discrete finite element function. +% WARNING: +% Currently this function only works with the nodal P1/Q1 bases. +% +% Inputs: +% grid Grid of the finite element space. +% basis Basis of the finite element space. +% u Vector representation of discrete function with respect +% to the given basis and grid. +% -dim = size(grid.nodes,1); + dim = size(grid.nodes,1); -if (dim==2) -% referenceElement = generateGrid([0 0; 1 0; 0 1]', [1 2 3]'); + if (dim==2) + n_nodes = size(grid.nodes, 2); + trisurf(grid.elements(1:3,:)', grid.nodes(1,:)', grid.nodes(2,:)', u(1:n_nodes), u(1:n_nodes)); + else + error( 'Plotting in dim=%d is not supported.', ... + dim ); + end - n_nodes = size(grid.nodes, 2); - trisurf(grid.elements(1:3,:)', grid.nodes(1,:)', grid.nodes(2,:)', u(1:n_nodes), u(1:n_nodes)); end