1 function ret =
get(grid,propertyname, varargin)
2 %
function ret =
get(grid,propertyname, varargin)
3 %
get-method
for cubegrids
6 % propertyname: A
property name of the grid which can be one of the following
7 % -
'level' :
get vector of levels of all elements
8 % -
'dimension' :
get dimension of grid
9 % -
'nvertices' :
get number of vertices of grid
10 % -
'nelements' :
get number of elements of grid
11 % -
'isleaf' :
get vector of isleaf-indices of all elements
12 % -
'vertexindex' returns a matrix
'(i,j)' index of
'j'-th vertex of element
'i'
13 % a further optional argument with element indices can be passed,
14 % then only the vertices of these elements are returned,
15 % @code
get(grid,
'vertexindex',[2,3]) @endcode returns a
16 %
'2 x nvertices_per_element' matrix with indices
17 % -
'vertex' : returns a matrix of all vertex coordinates, i.e.
18 % ret(i,j) => j-th coordinate of i-th vertex point
19 % optionally, a subset of vertex-indices can be determined as
20 % further parameter, i.e.
21 % @code
get(grid,
'vertex',[2 3 4]) @endcode produces a
'3 x dim'
22 % matrix with the coordinates of the points
24 % or property can be equal to one of the following strings returning
25 % quantities which are derived from the above grid properties
26 % -
'nleafelements' :
get number of
leaf elements of grid
27 % -
'leafelements' :
get vector of indices of elements that are
leaf elements
28 % -
'leafcogs' : returns a matrix of all centers of gravity of the
leaf
29 % elements.
'ret(i,j)' is the
'j'-th coordinate of the
'i'-th
leaf
31 % varargin: An optional list of arguments as described above.
33 % Bernard Haasdonk 1.3.2007
40 switch lower(propertyname)
50 ret = sum(grid.isleaf);
56 ret = grid.numintervals;
59 ids = 1:grid.nelements;
63 ret = grid.vertexindex(ids,:);
66 ids = 1:grid.nvertices;
70 ret = grid.vertex(ids,:);
72 ret = find(grid.isleaf);
74 nleafelements = sum(grid.isleaf);
75 ids = 1:nleafelements;
76 ret = zeros(nleafelements,grid.dimension);
77 leafvind = grid.vertexindex(find(grid.isleaf),:);
79 % fill all components of ret:
81 C = grid.vertex(leafv,i);
82 CC = reshape(C,size(leafvind));
83 ret(:,i) = mean(CC,2);
86 error('Propertyname not supported!');