Skip to content

Commit f772b3a

Browse files
authored
Merge pull request #145 from peter-nekrasov/farfield_flex
far field kernels and demos
2 parents 05e71bd + 924115b commit f772b3a

File tree

4 files changed

+728
-0
lines changed

4 files changed

+728
-0
lines changed

chunkie/+chnk/+flex2d/kern.m

Lines changed: 112 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -228,6 +228,37 @@
228228

229229
end
230230

231+
% clamped plate kernels for far field evaluation
232+
if strcmpi(type, 'clamped_plate_eval_ff')
233+
234+
submat = zeros(nt,2*ns);
235+
236+
srcnorm = srcinfo.n;
237+
srctang = srcinfo.d;
238+
nx = repmat(srcnorm(1,:),nt,1);
239+
ny = repmat(srcnorm(2,:),nt,1);
240+
dx = repmat(srctang(1,:),nt,1);
241+
dy = repmat(srctang(2,:),nt,1);
242+
ds = sqrt(dx.*dx+dy.*dy);
243+
244+
taux = dx./ds;
245+
tauy = dy./ds;
246+
247+
[~, ~, hess, third] = chnk.flex2d.hkdiffgreen_ff(zk, src, targ); % Hankel part
248+
249+
K1 = -(1/(2*zk^2).*(third(:, :, 1).*(nx.*nx.*nx) + third(:, :, 2).*(3*nx.*nx.*ny) +...
250+
third(:, :, 3).*(3*nx.*ny.*ny) + third(:, :, 4).*(ny.*ny.*ny)) ) - ...
251+
(3/(2*zk^2).*(third(:, :, 1).*(nx.*taux.*taux) + third(:, :, 2).*(2*nx.*taux.*tauy + ny.*taux.*taux) +...
252+
third(:, :, 3).*(nx.*tauy.*tauy + 2*ny.*taux.*tauy) + third(:, :, 4).*(ny.*tauy.*tauy))); % G_{ny ny ny} + 3G_{ny tauy tauy}
253+
254+
K2 = -(1/(2*zk^2).*(hess(:, :, 1).*(nx.*nx) + hess(:, :, 2).*(2*nx.*ny) + hess(:, :, 3).*(ny.*ny)))+...
255+
(1/(2*zk^2).*(hess(:, :, 1).*(taux.*taux) + hess(:, :, 2).*(2*taux.*tauy) + hess(:, :, 3).*(tauy.*tauy))); % -G_{ny ny} + G_{tauy tauy}
256+
257+
submat(:,1:2:end) = K1;
258+
submat(:,2:2:end) = K2;
259+
260+
end
261+
231262

232263
%%% FREE PLATE KERNELS
233264

@@ -425,6 +456,35 @@
425456

426457
end
427458

459+
% free plate kernels for far field evaluation
460+
if strcmpi(type, 'free_plate_eval_ff')
461+
srcnorm = srcinfo.n;
462+
srctang = srcinfo.d;
463+
nu = varargin{1};
464+
465+
[val,grad] = chnk.flex2d.hkdiffgreen_ff(zk,src,targ);
466+
nx = repmat(srcnorm(1,:),nt,1);
467+
ny = repmat(srcnorm(2,:),nt,1);
468+
469+
dx = repmat(srctang(1,:),nt,1);
470+
dy = repmat(srctang(2,:),nt,1);
471+
472+
ds = sqrt(dx.*dx+dy.*dy);
473+
474+
taux = dx./ds;
475+
tauy = dy./ds;
476+
477+
K1 = (-1/(2*zk^2).*(grad(:, :, 1).*(nx) + grad(:, :, 2).*ny));
478+
K1H = ((1 + nu)/2).*(-1/(2*zk^2).*(grad(:, :, 1).*(taux) + grad(:, :, 2).*tauy)); % G_{tauy}
479+
K2 = 1/(2*zk^2).*val;
480+
481+
submat = zeros(nt,3*ns);
482+
submat(:,1:3:end) = K1;
483+
submat(:,2:3:end) = K1H;
484+
submat(:,3:3:end) = K2;
485+
486+
end
487+
428488
%%% SUPPORTED PLATE KERNELS
429489

430490
% boundary conditions applied to a point source
@@ -727,6 +787,58 @@
727787

728788
end
729789

790+
% supported plate kernels for far field evaluation
791+
if strcmpi(type, 'supported_plate_eval_ff')
792+
srcnorm = srcinfo.n;
793+
srctang = srcinfo.d;
794+
srcd2 = srcinfo.d2;
795+
coefs = varargin{1};
796+
nu = coefs(1);
797+
798+
nx = repmat(srcnorm(1,:),nt,1);
799+
ny = repmat(srcnorm(2,:),nt,1);
800+
801+
dx = repmat(srctang(1,:),nt,1);
802+
dy = repmat(srctang(2,:),nt,1);
803+
804+
ds = sqrt(dx.*dx+dy.*dy);
805+
806+
taux = dx./ds;
807+
tauy = dy./ds;
808+
809+
dx1 = repmat(srctang(1,:),nt,1);
810+
dy1 = repmat(srctang(2,:),nt,1);
811+
812+
d2x1 = repmat(srcd2(1,:),nt,1);
813+
d2y1 = repmat(srcd2(2,:),nt,1);
814+
815+
denom = sqrt(dx1.^2+dy1.^2).^3;
816+
numer = dx1.*d2y1-d2x1.*dy1;
817+
818+
kappa = numer./denom;
819+
820+
kp = repmat(srcinfo.data(1,:),nt,1);
821+
822+
a1 = 2-nu;
823+
a2 = (-1+nu)*(7+nu)/(3 - nu);
824+
a3 = (1-nu)*(3+nu)/(1+nu);
825+
826+
[~, grad, hess, third] = chnk.flex2d.hkdiffgreen_ff(zk, src, targ, false);
827+
828+
K1 = -1/(2*zk^2)*(third(:,:,1).*nx.^3 + 3*third(:,:,2).*nx.^2.*ny + 3*third(:,:,3).*nx.*ny.^2 + third(:,:,4).*ny.^3) + ...
829+
-a1/(2*zk^2)*(third(:,:,1).*nx.*taux.^2 + third(:,:,2).*(ny.*taux.^2 + 2*nx.*taux.*tauy) + third(:,:,3).*(nx.*tauy.^2 + 2*ny.*taux.*tauy) + third(:,:,4).*ny.*tauy.^2) + ...
830+
a2*kappa./(2*zk^2).*(hess(:,:,1).*nx.^2 + 2*hess(:,:,2).*nx.*ny + hess(:,:,3).*ny.^2) + ...
831+
-a3*kp./(2*zk^2).*(grad(:,:,1).*taux + grad(:,:,2).*tauy);
832+
833+
K2 = -1/(2*zk^2).*(grad(:,:,1).*nx + grad(:,:,2).*ny);
834+
835+
submat = zeros(nt,2*ns);
836+
837+
submat(:,1:2:end) = K1;
838+
submat(:,2:2:end) = K2;
839+
840+
end
841+
730842
end
731843

732844

Lines changed: 183 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,183 @@
1+
%DEMO_CLAMPED_PLATE_SCATTER_FAR_FIELD
2+
%
3+
% Define an exterior scattering problem on a starfish-shaped domain and
4+
% solve
5+
%
6+
7+
% planewave vec
8+
9+
kvec = [8;0];
10+
zk = norm(kvec);
11+
nu = 1/3;
12+
13+
14+
% discretize domain
15+
16+
cparams = [];
17+
cparams.eps = 1.0e-6;
18+
cparams.nover = 0;
19+
cparams.maxchunklen = 4.0/zk; % setting a chunk length helps when the
20+
% frequency is known
21+
22+
pref = [];
23+
pref.k = 16;
24+
narms = 3;
25+
amp = 0.25;
26+
start = tic; chnkr = chunkerfunc(@(t) starfish(t,narms,amp),cparams,pref);
27+
t1 = toc(start);
28+
29+
fprintf('%5.2e s : time to build geo\n',t1)
30+
31+
% plot geometry and data
32+
33+
figure(1)
34+
clf
35+
plot(chnkr,'-x')
36+
hold on
37+
quiver(chnkr)
38+
axis equal
39+
40+
% assembling system matrix
41+
42+
fkern = @(s,t) chnk.flex2d.kern(zk, s, t, 'clamped_plate');
43+
44+
kappa = signed_curvature(chnkr);
45+
kappa = kappa(:);
46+
47+
opts = [];
48+
opts.sing = 'log';
49+
50+
start = tic;
51+
sys = chunkermat(chnkr,fkern, opts);
52+
sys = sys - 0.5*eye(2*chnkr.npt);
53+
sys(2:2:end,1:2:end) = sys(2:2:end,1:2:end) + kappa.*eye(chnkr.npt);
54+
55+
t1 = toc(start);
56+
fprintf('%5.2e s : time to assemble matrix\n',t1)
57+
58+
% building RHS
59+
60+
[r1, grad] = planewave(kvec, chnkr.r);
61+
62+
nx = chnkr.n(1,:);
63+
ny = chnkr.n(2,:);
64+
65+
normalderiv = grad(:, 1).*(nx.')+ grad(:, 2).*(ny.'); % Dirichlet and Neumann BC(Clamped BC)
66+
67+
firstbc = -r1;
68+
secondbc = -normalderiv;
69+
70+
rhs = zeros(2*chnkr.npt, 1); rhs(1:2:end) = firstbc ; rhs(2:2:end) = secondbc;
71+
72+
% Solving linear system
73+
74+
start = tic; sol = gmres(sys,rhs,[],1e-12,100); t1 = toc(start);
75+
fprintf('%5.2e s : time for dense gmres\n',t1)
76+
77+
% evaluate at targets and plot
78+
79+
rmin = min(chnkr); rmax = max(chnkr);
80+
xl = rmax(1)-rmin(1);
81+
yl = rmax(2)-rmin(2);
82+
nplot = 200;
83+
xtarg = linspace(rmin(1)-xl/2,rmax(1)+xl/2,nplot);
84+
ytarg = linspace(rmin(2)-yl/2,rmax(2)+yl/2,nplot);
85+
[xxtarg,yytarg] = meshgrid(xtarg,ytarg);
86+
targets = zeros(2,length(xxtarg(:)));
87+
targets(1,:) = xxtarg(:); targets(2,:) = yytarg(:);
88+
89+
start = tic; in = chunkerinterior(chnkr,{xtarg,ytarg}); t1 = toc(start);
90+
out = ~in;
91+
92+
fprintf('%5.2e s : time to find points in domain\n',t1)
93+
94+
ikern = @(s,t) chnk.flex2d.kern(zk, s, t, 'clamped_plate_eval'); % build the kernel of evaluation
95+
96+
start1 = tic;
97+
uscat = chunkerkerneval(chnkr, ikern,sol, targets(:,out));
98+
t2 = toc(start1);
99+
fprintf('%5.2e s : time for kernel eval (for plotting)\n',t2)
100+
101+
uin = planewave(kvec,targets(:,out));
102+
utot = uscat(:)+uin(:);
103+
104+
maxu = max(abs(uin(:)));
105+
106+
figure(2)
107+
clf
108+
109+
t = tiledlayout(1,3,'TileSpacing','compact');
110+
111+
nexttile
112+
zztarg = nan(size(xxtarg));
113+
zztarg(out) = uin;
114+
h=pcolor(xxtarg,yytarg,imag(zztarg),"FaceColor","interp");
115+
set(h,'EdgeColor','none')
116+
clim([-maxu,maxu])
117+
colormap(redblue);
118+
hold on
119+
plot(chnkr,'k','LineWidth',2)
120+
axis equal tight
121+
set(gca, "box","off","Xtick",[],"Ytick",[]);
122+
title('$u^{\textrm{inc}}$','Interpreter','latex','FontSize',12)
123+
124+
nexttile
125+
zztarg = nan(size(xxtarg));
126+
zztarg(out) = uscat;
127+
h=pcolor(xxtarg,yytarg,imag(zztarg),"FaceColor","interp");
128+
set(h,'EdgeColor','none')
129+
clim([-maxu,maxu])
130+
colormap(redblue);
131+
hold on
132+
plot(chnkr,'k','LineWidth',2)
133+
axis equal tight
134+
set(gca, "box","off","Xtick",[],"Ytick",[]);
135+
title('$u^{\textrm{scat}}$','Interpreter','latex','FontSize',12)
136+
137+
nexttile
138+
zztarg = nan(size(xxtarg));
139+
zztarg(out) = utot;
140+
h=pcolor(xxtarg,yytarg,imag(zztarg),"FaceColor","interp");
141+
set(h,'EdgeColor','none')
142+
clim([-maxu,maxu])
143+
colormap(redblue);
144+
hold on
145+
plot(chnkr,'k','LineWidth',2)
146+
axis equal tight
147+
set(gca, "box","off","Xtick",[],"Ytick",[]);
148+
colorbar
149+
title('$u^{\textrm{tot}}$','Interpreter','latex','FontSize',12)
150+
title(t,"Clamped Plate BCs")
151+
152+
153+
% evaluate the far field representation
154+
155+
ts = linspace(-pi,pi,300);
156+
ts = ts(1:end-1);
157+
158+
targets_ff = [cos(ts); sin(ts)];
159+
160+
ikern_ff = @(s,t) chnk.flex2d.kern(zk, s, t, 'clamped_plate_eval_ff', nu);
161+
162+
start1 = tic;
163+
uscat = chunkerkerneval(chnkr, ikern_ff,sol,targets_ff);
164+
t2 = toc(start1);
165+
fprintf('%5.2e s : time for kernel eval (for plotting)\n',t2)
166+
167+
figure(3)
168+
clf
169+
170+
t = tiledlayout(1,3,'TileSpacing','compact');
171+
title(t,'Clamped Plate Far Field Pattern')
172+
173+
nexttile
174+
plot(ts,real(uscat));
175+
title('Real')
176+
177+
nexttile
178+
plot(ts,imag(uscat));
179+
title('Imag')
180+
181+
nexttile
182+
plot(ts,abs(uscat));
183+
title('Abs')

0 commit comments

Comments
 (0)