rbmatlab 0.10.01
|
00001 function gridp = gridpart(grid,eind) 00002 %function gridp = gridpart(grid,eind) 00003 % function extracting a part of a .triagrid or .rectgrid defined by the given 00004 % element indices in the vector 'eind'. 00005 % 00006 % @note The neighbour information of the new resulting boundaries is set to 00007 % '-10' 00008 % 00009 % @note The properties gridbase.hmin, gridbase.alpha and the 00010 % distance-information in the new boundary elements are simply copied. I.e. 00011 % these fields do not completely meet the definition in the constructor. They 00012 % might be chosen slightly different, such that the 'gridp' would be really 00013 % identical to the result generated by the constructor on the subset of points. 00014 % 00015 % Parameters: 00016 % eind: vector of cell indices which shall be extracted from the grid. 00017 % 00018 % Return values: 00019 % gridp: the partial grid of type .gridbase with extracted cells 'eind'. 00020 00021 % Bernard Haasdonk 15.5.2007 00022 00023 gridp = copy(grid); 00024 gridp.nelements = length(eind); 00025 00026 % generate elementid translation map: T \mapsto T_{local} 00027 new_el_id = zeros(1,grid.nelements); 00028 new_el_id(eind) = 1:length(eind); 00029 00030 % generate vertex translation map: V \mapsto V_{local} 00031 new_vertex_id = zeros(1,grid.nvertices); 00032 mask = zeros(1,grid.nvertices); 00033 mask(grid.VI(eind,:))= 1; 00034 vind = find(mask); 00035 new_vertex_id(vind) = 1:length(vind); 00036 00037 % set number of vertices, area vector, and inverse area vector 00038 gridp.nvertices = max(new_vertex_id); 00039 gridp.A = gridp.A(eind); 00040 gridp.Ainv = gridp.Ainv(eind); 00041 00042 % set vertex coordinates 00043 gridp.X = grid.X(vind); 00044 gridp.Y = grid.Y(vind); 00045 00046 % set VI map 00047 gridp.VI = grid.VI(eind,:); %: VI(i,j) is the global vertex index of j-th 00048 gridp.VI = new_vertex_id(gridp.VI); 00049 00050 % set coordinates of elements' barycenters 00051 gridp.CX = gridp.CX(eind); 00052 gridp.CY = gridp.CY(eind); 00053 00054 % ATTENTION! Set neighbour indices 00055 gridp.NBI = grid.NBI(eind,:); 00056 i = find(gridp.NBI>0); 00057 gridp.NBI(i) = new_el_id(gridp.NBI(i)); 00058 i = find(gridp.NBI == 0); 00059 if ~isempty(i) 00060 gridp.NBI(i)= -10; 00061 end; 00062 00063 gridp.INB = grid.INB(eind,:); 00064 00065 gridp.EL = grid.EL(eind,:); 00066 gridp.DC = grid.DC(eind,:); 00067 gridp.NX = grid.NX(eind,:); 00068 gridp.NY = grid.NY(eind,:); 00069 gridp.ECX = grid.ECX(eind,:); 00070 gridp.ECY = grid.ECY(eind,:); 00071 gridp.SX = grid.SX(eind,:); 00072 gridp.SY = grid.SY(eind,:); 00073 gridp.ESX = grid.ESX(eind,:); 00074 gridp.ESY = grid.ESY(eind,:); 00075 gridp.DS = grid.DS(eind,:); 00076