rbmatlab 0.10.01
|
00001 function [p0, p1] = get_edges(grid,gid) 00002 %function [p0, p1] = get_edges(grid,gid) 00003 % method determining the world coordinates of the edges of a single 00004 % element with global index 'gid'. 00005 % 00006 % 'i'-th edge goes from 'p0(:,i)' to 'p1(:,i)' 00007 % 00008 % parameters: 00009 % gid: global index of element for which edge coordinates are requested 00010 % 00011 % return values: 00012 % p0: lowest coordinate of the edge 00013 % p1: highest coordinate of the edge 00014 % 00015 % @note vectorized version for multiple elements not yet implemented 00016 00017 % Bernard Haasdonk 27.3.2007 00018 00019 dim = grid.dimension; 00020 00021 % generate list of local coordinates to be connected 00022 % idea: plot n-1 d bottom cube, its shifted top version and the 00023 % connecting lines: 00024 % dim = 1 => [1 2] 00025 % dim = 2 => [1 2; 3,4; 1 3; 2 4] 00026 % dim = 3 => [1 2; 3,4; 1 3; 2 4, 5 6; 7,8; 5 7; 6 8; 1 5 ; 2 6 ; 00027 % 3 7 ; 4 8] 00028 li = [1 2]; 00029 for i = 2:dim 00030 % assume li is local coordinate li of lower n-1 d patch 00031 li = [li; li + 2^(i-1)]; 00032 % now li is local coordinate li of lower and upper n-1 d patch 00033 li = [li; (1:2^(i-1))' ,(1:2^(i-1))'+2^(i-1)]; 00034 end; 00035 00036 % get coordinates of elements vertices: 00037 vi = grid.vertexindex(gid,:); 00038 vertices = grid.vertex(vi,:); 00039 00040 p0 = vertices(li(:,1),:)'; 00041 p1 = vertices(li(:,2),:)'; 00042 00043 end 00044