rbmatlab 0.10.01
grid/@triagrid/gridpart.m
00001 function gridp = gridpart(grid,eind)
00002 %function gridp = gridpart(grid,eind)
00003 % function extracting a part of a .triagrid 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 = triagrid(grid);
00024 gridp.nelements = length(eind);
00025 
00026 % generate elementid translation map
00027 new_el_id = zeros(1,grid.nelements);
00028 new_el_id(eind) = 1:length(eind);
00029 
00030 % generate vertex translation map
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 gridp.nvertices = max(new_vertex_id);
00038 gridp.A = gridp.A(eind);
00039 gridp.Ainv = gridp.Ainv(eind);
00040 
00041 gridp.X = grid.X(vind);
00042 gridp.Y = grid.Y(vind);
00043 
00044 gridp.VI = grid.VI(eind,:); %: VI(i,j) is the global vertex index of j-th
00045 gridp.VI = new_vertex_id(gridp.VI);
00046 
00047 gridp.CX = gridp.CX(eind);
00048 gridp.CY = gridp.CY(eind);
00049 
00050 gridp.NBI = grid.NBI(eind,:);
00051 i = find(gridp.NBI>0);
00052 gridp.NBI(i) = new_el_id(gridp.NBI(i));
00053 i = find(gridp.NBI == 0);
00054 if ~isempty(i)
00055   gridp.NBI(i)= -10;
00056 end;
00057 
00058 gridp.INB = grid.INB(eind,:);
00059 
00060 gridp.EL = grid.EL(eind,:);
00061 gridp.DC = grid.DC(eind,:);
00062 gridp.NX = grid.NX(eind,:);
00063 gridp.NY = grid.NY(eind,:);
00064 gridp.ECX = grid.ECX(eind,:);
00065 gridp.ECY = grid.ECY(eind,:);
00066 gridp.SX = grid.SX(eind,:);
00067 gridp.SY = grid.SY(eind,:);
00068 gridp.ESX = grid.ESX(eind,:);
00069 gridp.ESY = grid.ESY(eind,:);
00070 gridp.DS = grid.DS(eind,:);
00071 gridp.JIT = grid.JIT(eind,:,:);
00072 
All Classes Namespaces Files Functions Variables