-
Notifications
You must be signed in to change notification settings - Fork 0
/
PostProcessing.m
168 lines (155 loc) · 6.89 KB
/
PostProcessing.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
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
function UU = PostProcessing(EvaluationPts, coord, connect, ...
inletelem, elemDofNum, ...
DirichletElem, NeumannElem, ...
FieldPts, NormalV, Weights, BasisFn, ...
unodal, Telem, ...
grx, grw, gtx, gtw, mu, numGaussPoints, ...
numDofPerNode, numDofPerElem)
%% Post-Processing
%%
numPts = size(EvaluationPts,2); % Total number of points
numDirichletElem = length(DirichletElem);
numNeumannElem = length(NeumannElem);
%%
UU = zeros(numPts*numDofPerNode,1);
%%
found_mex_RegularIntegrals_GN = ...
~isempty(which('Integration/RegularIntegrals_GN'));
found_mex_RegularIntegrals_KN_K = ...
~isempty(which('Integration/RegularIntegrals_KN_K'));
found_mex_NearlySingularIntegrals_GxpN = ...
~isempty(which('Integration/NearlySingularIntegrals_GxpN'));
found_mex_NearlySingularIntegrals_KxpN = ...
~isempty(which('Integration/NearlySingularIntegrals_KxpN'));
parfor mm = 1:length(inletelem)
m = inletelem(mm);
ind = numGaussPoints^2*(m-1) + (1:numGaussPoints^2);
xi = FieldPts(:,ind);
wJ = Weights(ind);
GNInlet = zeros(numPts*numDofPerNode,numDofPerElem);
xi_e = coord(:,connect(:,m));
l1 = norm(xi_e(:,6) - xi_e(:,9)) + norm(xi_e(:,9) - xi_e(:,8));
l2 = norm(xi_e(:,7) - xi_e(:,9)) + norm(xi_e(:,9) - xi_e(:,5));
LengE = max(l1,l2);
for c = 1:numPts
nodeDofNum = (c-1)*numDofPerNode + (1:numDofPerNode);
chi = EvaluationPts(:,c);
[dmin, dind] = min(sqrt(sum((xi_e - chi).^2,1)));
if dmin/LengE < 1
zetap = closest_zeta_9nodequad(chi, xi_e, dmin, dind);
if found_mex_NearlySingularIntegrals_GxpN
GN = NearlySingular_ElementIntegrals_GxpN...
(xi_e, chi, mu, ...
grx, grw, gtx, gtw, ...
zetap(1), zetap(2));
else
GN = NearlySingular_ElementIntegrals_GxpN_M...
(xi_e, chi, mu, ...
grx, grw, gtx, gtw, ...
zetap(1), zetap(2));
end
else
if found_mex_RegularIntegrals_GN
GN = RegularIntegrals_GN(chi,xi,wJ,BasisFn,mu);
else
GN = RegularIntegrals_GN_M(chi,xi,wJ,BasisFn,mu,...
numDofPerNode,numDofPerElem);
end
end
GNInlet(nodeDofNum, :) = GN;
end
UU = UU + GNInlet * Telem(:,m);
end
%%
parfor mm = 1:numNeumannElem
m = NeumannElem(mm);
ind = numGaussPoints^2*(m-1) + (1:numGaussPoints^2);
xi = FieldPts(:,ind);
nhat = NormalV(:,ind);
wJ = Weights(ind);
KNNeuman = zeros(numPts*numDofPerNode,numDofPerElem);
xi_e = coord(:,connect(:,m));
l1 = norm(xi_e(:,6) - xi_e(:,9)) + norm(xi_e(:,9) - xi_e(:,8));
l2 = norm(xi_e(:,7) - xi_e(:,9)) + norm(xi_e(:,9) - xi_e(:,5));
LengE = max(l1,l2);
for c = 1:numPts
nodeDofNum = (c-1)*numDofPerNode + (1:numDofPerNode);
chi = EvaluationPts(:,c);
[dmin, dind] = min(sqrt(sum((xi_e - chi).^2,1)));
if dmin/LengE < 1
zetap = closest_zeta_9nodequad(chi, xi_e, dmin, dind);
if found_mex_NearlySingularIntegrals_KxpN
KNi = NearlySingular_ElementIntegrals_KxpN...
(xi_e, chi, ...
grx, grw, gtx, gtw, ...
zetap(1), zetap(2));
else
KNi = NearlySingular_ElementIntegrals_KxpN_M...
(xi_e, chi, ...
grx, grw, gtx, gtw, ...
zetap(1), zetap(2));
end
% Can we improve accuracy of K when it is nearly singular.
if found_mex_RegularIntegrals_KN_K
[~,K] = RegularIntegrals_KN_K(chi,xi,nhat,wJ,BasisFn);
else
[~,K] = RegularIntegrals_KN_K_M(chi,xi,nhat,wJ, ...
BasisFn,numDofPerNode, ...
numDofPerElem)
end
Nzetap = interpolate_9nodequad(zetap(1), zetap(2))';
KN = reshape(K(:)*Nzetap, numDofPerNode, numDofPerElem) + KNi;
else
if found_mex_RegularIntegrals_KN_K
[KN, ~] = RegularIntegrals_KN_K(chi,xi,nhat,wJ,BasisFn);
else
[KN, ~] = RegularIntegrals_KN_K_M(chi,xi,nhat,wJ, ...
BasisFn,numDofPerNode, ...
numDofPerElem)
end
end
KNNeuman(nodeDofNum, :) = KN;
end
UU = UU - KNNeuman * unodal(elemDofNum(:,m));
end
%%
parfor mm = 1:numDirichletElem
m = DirichletElem(mm);
ind = numGaussPoints^2*(m-1) + (1:numGaussPoints^2);
xi = FieldPts(:,ind);
wJ = Weights(ind);
GNDirichlet = zeros(numPts*numDofPerNode,numDofPerElem);
xi_e = coord(:,connect(:,m));
l1 = norm(xi_e(:,6) - xi_e(:,9)) + norm(xi_e(:,9) - xi_e(:,8));
l2 = norm(xi_e(:,7) - xi_e(:,9)) + norm(xi_e(:,9) - xi_e(:,5));
LengE = max(l1,l2);
for c = 1:numPts
nodeDofNum = (c-1)*numDofPerNode + (1:numDofPerNode);
chi = EvaluationPts(:,c);
[dmin, dind] = min(sqrt(sum((xi_e - chi).^2,1)));
if dmin/LengE < 1
zetap = closest_zeta_9nodequad(chi, xi_e, dmin, dind);
if found_mex_NearlySingularIntegrals_GxpN
GN = NearlySingular_ElementIntegrals_GxpN...
(xi_e, chi, mu, ...
grx, grw, gtx, gtw, ...
zetap(1), zetap(2));
else
GN = NearlySingular_ElementIntegrals_GxpN_M...
(xi_e, chi, mu, ...
grx, grw, gtx, gtw, ...
zetap(1), zetap(2));
end
else
if found_mex_RegularIntegrals_GN
GN = RegularIntegrals_GN(chi,xi,wJ,BasisFn,mu);
else
GN = RegularIntegrals_GN_M(chi,xi,wJ,BasisFn,mu,...
numDofPerNode,numDofPerElem);
end
end
GNDirichlet(nodeDofNum, :) = GN;
end
UU = UU + GNDirichlet * Telem(:,m);
end
UU = reshape(UU,size(EvaluationPts,1),size(EvaluationPts,2));