From 1d2b8ec8c9cb2e7564fd095556b8bc2677e1be98 Mon Sep 17 00:00:00 2001
From: tokies <tobias.kies@fu-berlin.de>
Date: Sat, 10 Dec 2016 17:37:38 +0100
Subject: [PATCH] * Added documentation for plotGridFunction. * Added error in
 case of dimension != 2.

---
 pdeutils/functions/plotGridFunction.m | 23 ++++++++++++++++++-----
 1 file changed, 18 insertions(+), 5 deletions(-)

diff --git a/pdeutils/functions/plotGridFunction.m b/pdeutils/functions/plotGridFunction.m
index d7e6f66..22ebad1 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
 
-- 
GitLab