rbmatlab  1.16.09
 All Classes Namespaces Files Functions Variables Modules Pages
gridpart.m
1 function gridp = gridpart(grid,eind)
2 %function gridp = gridpart(grid,eind)
3 % function extracting a part of a .triagrid defined by the given
4 % element indices in the vector 'eind'.
5 %
6 % @note The neighbour information of the new resulting boundaries is set to
7 % '-10'
8 %
9 % @note The properties gridbase.hmin, gridbase.alpha and the
10 % distance-information in the new boundary elements are simply copied. I.e.
11 % these fields do not completely meet the definition in the constructor. They
12 % might be chosen slightly different, such that the 'gridp' would be really
13 % identical to the result generated by the constructor on the subset of points.
14 %
15 % Parameters:
16 % eind: vector of cell indices which shall be extracted from the grid.
17 %
18 % Return values:
19 % gridp: the partial grid of type .gridbase with extracted cells 'eind'.
20 
21 % Bernard Haasdonk 15.5.2007
22 
23 gridp = triagrid(grid);
24 gridp.nelements = length(eind);
25 
26 % generate elementid translation map
27 new_el_id = zeros(1,grid.nelements);
28 new_el_id(eind) = 1:length(eind);
29 
30 % generate vertex translation map
31 new_vertex_id = zeros(1,grid.nvertices);
32 mask = zeros(1,grid.nvertices);
33 mask(grid.VI(eind,:))= 1;
34 vind = find(mask);
35 new_vertex_id(vind) = 1:length(vind);
36 
37 gridp.nvertices = max(new_vertex_id);
38 gridp.A = gridp.A(eind);
39 gridp.Ainv = gridp.Ainv(eind);
40 
41 gridp.X = grid.X(vind);
42 gridp.Y = grid.Y(vind);
43 
44 gridp.VI = grid.VI(eind,:); %: VI(i,j) is the global vertex index of j-th
45 gridp.VI = new_vertex_id(gridp.VI);
46 
47 gridp.CX = gridp.CX(eind);
48 gridp.CY = gridp.CY(eind);
49 
50 gridp.NBI = grid.NBI(eind,:);
51 i = find(gridp.NBI>0);
52 gridp.NBI(i) = new_el_id(gridp.NBI(i));
53 i = find(gridp.NBI == 0);
54 if ~isempty(i)
55  gridp.NBI(i)= -10;
56 end;
57 
58 gridp.INB = grid.INB(eind,:);
59 
60 gridp.EL = grid.EL(eind,:);
61 gridp.DC = grid.DC(eind,:);
62 gridp.NX = grid.NX(eind,:);
63 gridp.NY = grid.NY(eind,:);
64 gridp.ECX = grid.ECX(eind,:);
65 gridp.ECY = grid.ECY(eind,:);
66 gridp.SX = grid.SX(eind,:);
67 gridp.SY = grid.SY(eind,:);
68 gridp.ESX = grid.ESX(eind,:);
69 gridp.ESY = grid.ESY(eind,:);
70 gridp.DS = grid.DS(eind,:);
71 gridp.JIT = grid.JIT(eind,:,:);
72 
73 gridp.nedges_boundary = length(find(gridp.NBI<0));
74 gridp.nedges_interior = 0.5*(3*gridp.nelements - gridp.nedges_boundary);
A triangular conforming grid in two dimensions.
Definition: triagrid.m:17
alpha
geometry bound (simultaneously satisfying and
Definition: gridbase.m:237
Base class for all grid classes.
Definition: gridbase.m:17
hmin
minimal element-diameter
Definition: gridbase.m:230