-
Notifications
You must be signed in to change notification settings - Fork 0
/
get_value.m
152 lines (86 loc) · 2.75 KB
/
get_value.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
function u = get_value(x,geo,pd_u,pd_l,mu,open_or_closed )
% this function gets the value of the field for the bump problem
delta = 0.005;
u = 0;
Ns = 0;
Nt = geo.get_N_total;
xp = [];
for p=1:geo.n_parts
prt = geo.get_part(p);
xp = [xp;prt.x];
dw = [dw;prt.dw];
end
if strcmp (open_or_closed,'closed')
isin = inpolygon(x(:,1),x(:,2),xp(:,1),xp(:,2));
else strcmp (open_or_closed,'open')
isin = inpolygon(x(:,1),x(:,2),[xp(:,1);xp(end,1);xp(1,1);xp(1,1)],[xp(:,2);-1e5;-1e5;xp(1,2)]);
end
%% only for the square
for p=1:geo.n_parts
prt = geo.get_part(p);
[dist,xc,wc,rep] = prt.dist(x);
if ~isin %rep==1
k = pd_u.k;
coef =1;
else
k = pd_l.k;
coef =-1;
end
Np = prt.Np;
if dist>delta
D = DL(k,x,prt);
S = SL(k,x,prt);
u = u + coef*[D -S]*[prt.win.*mu(Ns+(1:Np));prt.win.*mu(Nt+Ns+(1:Np))];
else
ub = mu(Ns + 1:Np);
ub = [ub(1);ub;ub(end)];
w = [0;prt.w;2*pi];
u = spline(w,ub,wc);
return
end
Ns = Ns + prt.Np;
end
end
%-------------------------------------------------------------------------%
function DL = DL(k,x,prt_i)
Npe = size(x,1);
Npi = prt_i.Np;
% Evaluation point
x1 = x(:,1);
x2 = x(:,2);
x_1 = repmat(x1,1,Npi);
x_2 = repmat(x2,1,Npi);
% Integration point
xp1 = prt_i.x(:,1);
xp2 = prt_i.x(:,2);
dxp1 = prt_i.dx(:,1);
dxp2 = prt_i.dx(:,2);
xp_1 = repmat(xp1.',Npe,1);
xp_2 = repmat(xp2.',Npe,1);
dxp_1 = repmat(dxp1.',Npe,1);
dxp_2 = repmat(dxp2.',Npe,1);
%%%
r = sqrt((x_1-xp_1).^2+(x_2-xp_2).^2);
dW = repmat(prt_i.dw.',Npe,1);
DL = (1i*k/4*besselh(1,k*r)./r.*((x_1-xp_1).*dxp_2-(x_2-xp_2).*dxp_1)*pi/prt_i.N).*dW;
end
function SL = SL(k,x,prt_i)
Npi = prt_i.Np;
Npe = size(x,1);
x1 = x(:,1);
x2 = x(:,2);
xp1 = prt_i.x(:,1);
xp2 = prt_i.x(:,2);
dxp1 = prt_i.dx(:,1);
dxp2 = prt_i.dx(:,2);
xp_1 = repmat(xp1.',Npe,1);
xp_2 = repmat(xp2.',Npe,1);
x_1 = repmat(x1,1,Npi);
x_2 = repmat(x2,1,Npi);
dxp_1 = repmat(dxp1.',Npe,1);
dxp_2 = repmat(dxp2.',Npe,1);
r = sqrt((x_1-xp_1).^2+(x_2-xp_2).^2);
tau = sqrt(dxp_1.^2+dxp_2.^2);
dW = repmat(prt_i.dw.',Npe,1);
SL = (1i/4.*besselh(0,k*r) .* tau * pi/prt_i.N).*dW;
end