forked from fangq/iso2mesh
-
Notifications
You must be signed in to change notification settings - Fork 0
/
removeisolatednode.m
29 lines (28 loc) · 922 Bytes
/
removeisolatednode.m
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
function [no,el]=removeisolatednode(node,elem)
%
% [no,el]=removeisolatednode(node,elem)
%
% remove isolated nodes: nodes that are not included in any element
%
% author: Qianqian Fang, <q.fang at neu.edu>
%
% input:
% node: list of node coordinates
% elem: list of elements of the mesh
%
% output:
% no: node coordinates after removing the isolated nodes
% el: element list of the resulting mesh
%
% -- this function is part of iso2mesh toolbox (http://iso2mesh.sf.net)
%
oid=1:size(node,1); % old node index
idx=setdiff(oid,elem(:)); % indices to the isolated nodes
idx=sort(idx);
delta=zeros(size(oid));
delta(idx)=1;
delta=-cumsum(delta); % calculate the new node index after removing the isolated nodes
oid=oid+delta; % map to new index
el=oid(elem); % element list in the new index
no=node;
no(idx,:)=[]; % remove the isolated nodes