rbmatlab  1.13.10
 All Classes Namespaces Files Functions Variables Groups Pages
onedgrid_gridpart_old.m
1 function gpart = onedgrid_gridpart(grid,eind);
2 %function gpart = onedgrid_gridpart(grid,eind);
3 %
4 % function extracting a subgrid of grid with given indices and
5 % correct neighbour information.
6 if (sort(eind)~=eind)
7  error('eind not sorted!');
8 end;
9 gpart.nelements = length(eind);
10 gpart.eind = eind;
11 % initally mark all neighbours to non-existing
12 gpart.NBI = -10 * ones(length(eind),2);
13 % set existing right neighbours
14 ndiff = [eind(2:end),0] - eind; % ndiff==1 if left neighbour in eind
15 i = find(ndiff==1);
16 gpart.NBI(i,1) = i+1;
17 % set existing left neighbours
18 ndiff = eind - [1e10, eind(1:end-1)]; % ndiff==1 if left neighbour in eind
19 i = find(ndiff==1);
20 gpart.NBI(i,2) = i-1;
21 % set existing dirichlet-boundary
22 if eind(1) == 1
23  gpart.NBI(1,2)= grid.NBI(1,2);
24 end;
25 if eind(end) == grid.nelements
26  gpart.NBI(end,1)= grid.NBI(end,1);
27 end;