-
Notifications
You must be signed in to change notification settings - Fork 1
/
DrawResults.m
95 lines (88 loc) · 3.62 KB
/
DrawResults.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
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
function DrawResults(phi, Theta, TriInfo, picName, data)
% Draws phi and Theta
phiProlonged = ProlongPhi(phi, TriInfo);
minX = min(TriInfo.x);
maxX = max(TriInfo.x);
minY = min(TriInfo.y);
maxY = max(TriInfo.y);
%% Draw phi
fig = figure('visible', 'off');
hold on;
trisurf(TriInfo.e2p, TriInfo.x, TriInfo.y, phiProlonged*(1:TriInfo.sizePhi)');
plot([minX maxX maxX minX minX], [minY minY maxY maxY minY], 'k');
view(2);
shading interp;
colormap(colormap(gray));
caxis([1 4]);
c = colorbar;
c.Ticks = [1 2 3 4];
c.TickLabels = {'Ge', 'SiN', 'SiO_2', 'air'};
set(gca,'xcolor',get(gcf,'color'));
set(gca,'xtick',[]);
set(gca,'ycolor',get(gcf,'color'));
set(gca,'ytick',[]);
saveas(fig, fullfile(picName, sprintf('Phi_Ref%d_%d.jpg', data.meshIndex-1, data.iterIn)));
%% Draw Theta
fig = figure('visible', 'off');
trisurf(TriInfo.e2p, TriInfo.x, TriInfo.y, Theta);
view(2);
shading interp;
colormap jet;
colorbar;
hold on;
set(gca,'xcolor',get(gcf,'color'));
set(gca,'xtick',[]);
set(gca,'ycolor',get(gcf,'color'));
set(gca,'ytick',[]);
if data.drawFixGe
% Draw boundary edges for fixGe
xEle = TriInfo.x(TriInfo.e2p);
yEle = TriInfo.y(TriInfo.e2p);
fixGeEle = sum(data.fixGe(TriInfo.e2p), 2) == 3;
xDraw = xEle(fixGeEle,:);
xDraw = xDraw(:,[1 1 2 2 3 3]);
xDraw = reshape(xDraw, [], 2);
yDraw = yEle(fixGeEle,:);
yDraw = yDraw(:,[1 1 2 2 3 3]);
yDraw = reshape(yDraw, [], 2);
sortIndex = (xDraw(:,1) > xDraw(:,2)) | (xDraw(:,1) == xDraw(:,2) & yDraw(:,1) > yDraw(:,2));
xDraw(sortIndex,:) = xDraw(sortIndex,[2 1]);
yDraw(sortIndex,:) = yDraw(sortIndex,[2 1]);
xyDraw = sortrows([xDraw yDraw]);
xyDiff1 = diff(xyDraw);
xyDiff2 = [ones(1, 4); xyDiff1];
xyDiff3 = [xyDiff1; ones(1, 4)];
xyUnique = sum(abs(xyDiff2),2)~=0 & sum(abs(xyDiff3),2)~=0;
if ~isempty(xyDraw)
xyDraw = xyDraw(xyUnique,:);
plot3(xyDraw(:,1:2)', xyDraw(:,3:4)', 2*max(Theta)*ones(size(xyDraw,1),2)', 'k--');
else
scatter3(TriInfo.x(data.fixGe), TriInfo.y(data.fixGe), 2*max(Theta)*ones(sum(data.fixGe),1), 'k', 'filled');
end
% Draw boundary edges for fixGePrev
xEle = TriInfo.x(TriInfo.e2p);
yEle = TriInfo.y(TriInfo.e2p);
fixGeEle = sum(data.fixGePrev(TriInfo.e2p), 2) == 3;
xDraw = xEle(fixGeEle,:);
xDraw = xDraw(:,[1 1 2 2 3 3]);
xDraw = reshape(xDraw, [], 2);
yDraw = yEle(fixGeEle,:);
yDraw = yDraw(:,[1 1 2 2 3 3]);
yDraw = reshape(yDraw, [], 2);
sortIndex = (xDraw(:,1) > xDraw(:,2)) | (xDraw(:,1) == xDraw(:,2) & yDraw(:,1) > yDraw(:,2));
xDraw(sortIndex,:) = xDraw(sortIndex,[2 1]);
yDraw(sortIndex,:) = yDraw(sortIndex,[2 1]);
xyDraw = sortrows([xDraw yDraw]);
xyDiff1 = diff(xyDraw);
xyDiff2 = [ones(1, 4); xyDiff1];
xyDiff3 = [xyDiff1; ones(1, 4)];
xyUnique = sum(abs(xyDiff2),2)~=0 & sum(abs(xyDiff3),2)~=0;
if ~isempty(xyDraw)
xyDraw = xyDraw(xyUnique,:);
plot3(xyDraw(:,1:2)', xyDraw(:,3:4)', 2*max(Theta)*ones(size(xyDraw,1),2)', 'k');
else
scatter3(TriInfo.x(data.fixGePrev), TriInfo.y(data.fixGePrev), 2*max(Theta)*ones(sum(data.fixGePrev),1), 'k');
end
end
saveas(fig, fullfile(picName, sprintf('Theta_Ref%d_%d.jpg', data.meshIndex-1, data.iterIn)));
end