rbmatlab  1.16.09
 All Classes Namespaces Files Functions Variables Modules Pages
plot_leafelement_data.m
1 function p = plot_leafelement_data(grid,data,params)
2 %function p = plot_leafelement_data(grid,data,params)
3 % plot method for piecewise constant data on the leaf level of the grid.
4 %
5 % Currently only implemented for 2D. A patch plot is performed.
6 %
7 % Return values:
8 % p: this is the list of handles to the graphics primitives
9 %
10 % see also: plot_element_data() for general possible options in params
11 
12 % Bernard Haasdonk 23.3.2007
13 
14 if nargin==1
15  params = [];
16  data = zeros(grid.nelements,1);
17 end;
18 
19 dim = grid.dimension;
20 
21 if (dim~=2)
22  error('plot_leafelement_data not yet implemented for other than 2D');
23 end;
24 
25 % determine elements to be plotted
26 ids = find(grid.isleaf);
27 
28 if isempty(ids)
29  disp('no elements on current level or grid empty')
30 end;
31 
32 % provide new grid structure, which is acceptable by plot_element_data
33 
34 elid = get(grid,'leafelements');
35 
36 gridtmp = cubegrid();
37 
38 gridtmp.nelements = length(elid);
39 gridtmp.nneigh = 4;
40 gridtmp.VI = grid.vertexindex(elid,[1 2 4 3]);
41 gridtmp.X = grid.vertex(:,1);
42 gridtmp.Y = grid.vertex(:,2);
43 
44 % get X coordinates of vertices as vector
45 XX = grid.vertex(gridtmp.VI(:),1);
46 % reshape to matrix
47 XX = reshape(XX,size(gridtmp.VI));
48 
49 % get Y coordinates of vertices as vector
50 YY = grid.vertex(gridtmp.VI(:),2);
51 % reshape to matrix
52 YY = reshape(YY,size(gridtmp.VI));
53 
54 gridtmp.CX = mean(XX,2);
55 gridtmp.CY = mean(YY,2);
56 
57 plot_element_data(gridtmp,data,params);
58 
59 end
60 
A hierarchical cubegrid of arbitrary dimension.
Definition: cubegrid.m:17
Definition: leaf.m:17