rbmatlab 0.10.01
|
00001 function vols = get_volume(grid,gids) 00002 % function vols = get_volume(grid,gids) 00003 % method determining the volumes of a set of elements 00004 % 00005 % A simple product of edge-lengths is computed, i.e. the edges are assumed to 00006 % be axis-parallel. 00007 % 00008 % Parameters: 00009 % gids: Global indices 00010 % 00011 % Return values: 00012 % vols: The volumes for the elements given by 'gids'. 00013 % 00014 % @note The computation for multiple gids is trivially performed by a loop. 00015 % Vectorization must be done sometime!! 00016 00017 % Bernard Haasdonk 27.3.2007 00018 00019 vols = ones(size(gids)); 00020 dim = grid.dimension; 00021 00022 % determine edge indices, which are to be used: 00023 % 0D: eid(0) = [] of ne(0) = 0 edges 00024 % 1D. eid = [1] of ne(1) = 1 edges 00025 % 2D. eid = [1, 3] of ne(2) = 4 edges 00026 % 3D. eid = [1, 3, 9] of ne(3) = 12 edges 00027 % ND: eid(N) = [eid(N-1), 2* ne(N-1)+1] of ne(N) = 2*ne(N-1) + 2^(N-1) edges 00028 00029 eid = []; 00030 ne = 0; 00031 for i = 1:dim 00032 eid = [eid, 2*ne+1]; 00033 ne = 2* ne + 2^(i-1); 00034 end; 00035 00036 for gid = 1:length(gids); 00037 [p0,p1] = get_edges(grid,gids(gid)); 00038 diff = p0(:,eid)-p1(:,eid); 00039 len = sqrt(sum(diff.^2)); 00040 vols(gid) = prod(len); 00041 end; 00042 end 00043