rbmatlab  1.16.09
 All Classes Namespaces Files Functions Variables Modules Pages
compute_edge_indices.m
Go to the documentation of this file.
1 function [gEI, in_edges, b_edges, i_ints_bigger, b_ints] = compute_edge_indices(grid)
2 % edge index matrix. This matrix maps each edge specified by the tuple
3 % '(element_id, local_edge_id)' to a unique and continuous edge index
4 % enumeration.
5 
6 gEI = zeros(grid.nelements, 4);
7 % I1 = inner intersections with left element id 'K' smaller than right id 'L'
8 i_ints_smaller = grid.NBI > 0 ...
9  & grid.NBI > repmat((1:grid.nelements)', 1, grid.nneigh);
10 % number of innter intersections
11 in_edges = sum(i_ints_smaller(:));
12 
13 % set half of the edge index matrix for all edges 'KL'
14 gEI(i_ints_smaller) = 1:in_edges;
15 
16 % for all inner edges, 'itmp' has the smaller element id 'K' of this edge ...
17 [itmp, jtmp] = find(i_ints_smaller);
18 % and 'neighbours' stores the larger element id 'L'.
19 neighbours = grid.NBI(i_ints_smaller);
20 
21 % jtmp stores the 'local edge id' for all edges 'LK', for this we create the
22 % logical matrix 'local_edges'.
23 local_edges = grid.NBI(neighbours, :) ...
24  == repmat(itmp, 1, grid.nneigh);
25 [itmp, jtmp] = find(local_edges);
26 
27 % I2 = inner intersections with left element id 'L' bigger than right id 'K'
28 i_ints_bigger = sub2ind(size(grid.NBI), neighbours, jtmp);
29 
30 % set other half of edge index matrix for all inner edges 'LK'
31 gEI(i_ints_bigger) = 1:in_edges;
32 
33 % boundary intersections
34 b_ints = grid.NBI < 0 & grid.NBI > -10;
35 b_edges = sum(b_ints(:));
36 gn_edges = in_edges + b_edges;
37 % set edge index matrix entries for all boundary edges
38 gEI(b_ints) = in_edges + 1:gn_edges;
39 
function [ gEI , in_edges , b_edges , i_ints_bigger , b_ints ] = compute_edge_indices(gridbase grid)
edge index matrix. This matrix maps each edge specified by the tuple (element_id, local_edge_id) to a...