-
Notifications
You must be signed in to change notification settings - Fork 1
/
PlotResults.m
77 lines (74 loc) · 2.06 KB
/
PlotResults.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
function PlotResults(X,T,sol,elem,degree)
h=figure(4);
if ishandle(h)
clf(4,'reset');
end
if elem == 1 && degree == 1
figure(4);
trisurf(T,X(:,1),X(:,2),sol,'FaceColor','interp');
elseif degree == 0
nElem = size(T,1);
if elem == 0
nen = 4;
else
nen = 3;
end
figure(4); hold on
for ielem = 1:nElem
Te = T(ielem,1:nen);
Xe = X(Te,:);
zz = sol(ielem)*ones(nen,1);
patch(Xe(:,1),Xe(:,2),zz,zz)
end
else
[nElem,nen] = size(T);
if elem == 11
ngeom = nen-1;
else
ngeom = nen;
end
if elem == 0
npt = 2*degree+1;
x = linspace(-1,1,npt);
[x,y] = meshgrid(x,x);
pts = [reshape(x,npt^2,1), reshape(y,npt^2,1)];
ptsEdge = [
linspace(-1,1,npt)' -ones(npt,1)
ones(npt,1) linspace(-1,1,npt)'
flipud(linspace(-1,1,npt)') ones(npt,1)
-ones(npt,1) flipud(linspace(-1,1,npt)')
];
else
npt = 2*degree+1;
x = linspace(0,1,npt);
[x,y] = meshgrid(x,x);
pts = [reshape(x,npt^2,1), reshape(y,npt^2,1)];
ind = pts(:,2) <= 1 - pts(:,1);
pts = pts(ind,:);
ptsEdge = [
linspace(0,1,npt)' 1-linspace(0,1,npt)'
flipud(linspace(0,1,npt)') zeros(npt,1)
zeros(npt,1) linspace(0,1,npt)'
];
end
tri = delaunay(pts(:,1), pts(:,2));
N = ShapeFunc(elem,degree,pts);
NEdge = ShapeFunc(elem,degree,ptsEdge);
figure(4); hold on;
for ielem = 1:nElem
Te = T(ielem,:);
Xe = X(Te(1:ngeom),:);
sol_e = sol(Te);
xx = N(:,1:ngeom)*Xe(:,1);
yy = N(:,1:ngeom)*Xe(:,2);
zz = N*sol_e;
xEdge = NEdge(:,1:ngeom)*Xe(:,1);
yEdge = NEdge(:,1:ngeom)*Xe(:,2);
zEdge = NEdge*sol_e;
trisurf(tri,xx, yy, zz,'FaceColor','interp','EdgeColor','none')
plot3(xEdge,yEdge,zEdge,'k');
end
end
grid on
view(3); axis tight
set(gca,'FontSize',12)