forked from ksw851216/active_foam_junctional_fluctuation
-
Notifications
You must be signed in to change notification settings - Fork 0
/
ns_faceEdgeId.m
69 lines (63 loc) · 1.79 KB
/
ns_faceEdgeId.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
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
function fed=ns_faceEdgeId(edge,face,gmp,rg,fId)
fvr=face{2}{fId};
eVr=edge{1}(:,rg.ei(1):rg.ef(1));
if size(fvr,2)>2
fvrc=[fvr,fvr(1)];
fed=zeros(1,size(fvr,2));
for jj=1:size(fvrc,2)-1
if fvrc(jj)<fvrc(jj+1)
eid=find(ismember(eVr,fvrc(jj:jj+1),'rows')==1);
if size(eid,1)==1
fed(jj)=eid;
else
efid=edge{1}(eid(1),rg.ei(2):rg.ef(2));
efid=efid(efid==fId);
if isempty(efid)==1
fed(jj)=eid(2);
else
fed(jj)=eid(1);
end
end
else
eid=find(ismember(eVr,[fvrc(jj+1),fvrc(jj)],'rows')==1);
if size(eid,1)==1
fed(jj)=-eid;
else
efid=edge{1}(eid(1),rg.ei(2):rg.ef(2));
efid=efid(efid==fId);
if isempty(efid)==1
fed(jj)=-eid(2);
else
fed(jj)=-eid(1);
end
end
end
end
% cells with one neighbors only
elseif size(fvr,2)==2
if fvr(1)<fvr(2)
eId=find(ismember(eVr,fvr,'rows')==1 & ...
(edge{1}(:,3)==fId | edge{1}(:,4)==fId));
fedInd=[eId(1),-eId(2)];
else
eId=find(ismember(eVr,[fvr(2),fvr(1)],'rows')==1 & ...
(edge{1}(:,3)==fId | edge{1}(:,4)==fId));
fedInd=[-eId(1),eId(2)];
end
farInd=ns_faceArea(fedInd,edge{2},gmp.bs,gmp.sstn);
if farInd>0
fed=fedInd;
else
fed=[-fedInd(2),-fedInd(1)];
end
else
eId=find(ismember(eVr,[fvr(1),fvr(1)],'rows')==1);
fedInd=eId;
farInd=ns_faceArea(fedInd,edge{2},gmp.bs,gmp.sstn);
if farInd>0
fed=fedInd;
else
fed=-fedInd;
end
end
end