1 function [p0, p1] = get_edges(grid,gid)
2 %
function [p0, p1] = get_edges(grid,gid)
3 % method determining the world coordinates of the edges of a single
4 % element with global index
'gid'.
6 %
'i'-th edge goes from
'p0(:,i)' to
'p1(:,i)'
9 % gid: global index of element
for which edge coordinates are requested
12 % p0: lowest coordinate of the edge
13 % p1: highest coordinate of the edge
15 % @note vectorized version
for multiple elements not yet implemented
17 % Bernard Haasdonk 27.3.2007
21 % generate list of local coordinates to be connected
22 % idea: plot n-1 d bottom cube, its shifted top version and the
25 % dim = 2 => [1 2; 3,4; 1 3; 2 4]
26 % dim = 3 => [1 2; 3,4; 1 3; 2 4, 5 6; 7,8; 5 7; 6 8; 1 5 ; 2 6 ;
30 % assume li is local coordinate li of lower n-1 d patch
31 li = [li; li + 2^(i-1)];
32 % now li is local coordinate li of lower and upper n-1 d patch
33 li = [li; (1:2^(i-1))
' ,(1:2^(i-1))'+2^(i-1)];
36 %
get coordinates of elements vertices:
37 vi = grid.vertexindex(gid,:);
38 vertices = grid.vertex(vi,:);
40 p0 = vertices(li(:,1),:)
';
41 p1 = vertices(li(:,2),:)';