Skip to content

Commit 5125903

Browse files
committed
Merge branch 'quasi_periodic_shapes' of https://github.com/fastalgorithms/chunkie into quasi_periodic_shapes
2 parents 499bcf6 + cd84461 commit 5125903

File tree

18 files changed

+817
-286
lines changed

18 files changed

+817
-286
lines changed

chunkie/+chnk/+axissymhelm2d/kern.m

Lines changed: 13 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,9 @@
6868
zk2 = zks(2);
6969
end
7070

71-
if strcmpi(type, 'd')
71+
switch lower(type)
72+
73+
case {'d', 'double'}
7274
srcnorm = srcinfo.n(:,:);
7375
[~, grad] = chnk.axissymhelm2d.green(zk, src, targ, origin);
7476
nx = repmat(srcnorm(1,:), nt, 1);
@@ -91,9 +93,8 @@
9193
end
9294
end
9395
end
94-
end
9596

96-
if strcmpi(type, 'sprime')
97+
case {'sp', 'sprime'}
9798
targnorm = targinfo.n(:,:);
9899
[~, grad] = chnk.axissymhelm2d.green(zk, src, targ, origin);
99100

@@ -118,9 +119,7 @@
118119
end
119120
end
120121

121-
end
122-
123-
if strcmpi(type, 's')
122+
case {'s', 'single'}
124123
submat = chnk.axissymhelm2d.green(zk, src, targ, origin);
125124
fker = @(x, s, t) fslp(x, zk, s, t, origin);
126125
for j=1:ns
@@ -140,15 +139,11 @@
140139
end
141140
end
142141

143-
end
144-
145-
146-
if strcmpi(type, 'sdiff')
142+
case {'sdiff', 's_diff'}
147143
ifdiff = 1;
148144
submat = chnk.axissymhelm2d.green(zk, src, targ, origin, ifdiff);
149-
end
150145

151-
if strcmpi(type, 'c')
146+
case {'c', 'combined'}
152147
srcnorm = srcinfo.n(:,:);
153148
coef = ones(2,1);
154149
if (nargin == 6); coef = varargin{1}; end
@@ -175,10 +170,8 @@
175170
end
176171
end
177172
end
178-
end
179173

180-
181-
if strcmpi(type, 'dprime')
174+
case {'dp', 'dprime'}
182175
targnorm = targinfo.n(:,:);
183176
srcnorm = srcinfo.n(:,:);
184177
[~,~,hess] = chnk.axissymhelm2d.green(zk, src, targ, origin);
@@ -188,10 +181,8 @@
188181
nytarg = repmat((targnorm(2,:)).',1,ns);
189182
submat = hess(:,:,4).*nxsrc.*nxtarg - hess(:,:,5).*nysrc.*nxtarg ...
190183
- hess(:,:,6).*nxsrc.*nytarg + hess(:,:,3).*nysrc.*nytarg;
191-
end
192-
193-
if strcmpi(type, 'dprime_re_diff')
194184

185+
case {'dp_re_diff', 'dprime_re_diff'}
195186
targnorm = targinfo.n(:,:);
196187
srcnorm = srcinfo.n(:,:);
197188
ifdiff = 2;
@@ -213,11 +204,7 @@
213204

214205
submat = submat1-submat2;
215206

216-
end
217-
218-
219-
220-
if strcmpi(type, 'dprimediff')
207+
case {'dpdiff', 'dp_diff', 'dprimediff', 'dprime_diff'}
221208
targnorm = targinfo.n(:,:);
222209
srcnorm = srcinfo.n(:,:);
223210
ifdiff = 1;
@@ -246,9 +233,7 @@
246233
end
247234
end
248235

249-
end
250-
251-
if strcmpi(type, 'neu_rpcomb')
236+
case {'neu_rpcomb'}
252237
targnorm = targinfo.n(:,:);
253238
srcnorm = srcinfo.n(:,:);
254239
[~,gk,~,sikmat,gik,~,~,~,hessdiff] = ...
@@ -314,14 +299,8 @@
314299
submat(1:3:end, 3:3:end) = c2*spikmat;
315300
submat(2:3:end, 1:3:end) = -sikmat;
316301
submat(3:3:end, 1:3:end) = -spikmat;
317-
318-
319-
320-
321-
322-
323-
324-
302+
otherwise
303+
error('Unknown axissymmetric Helmholtz kernel type ''%s''.', type);
325304
end
326305

327306
end

chunkie/+chnk/+elast2d/kern.m

Lines changed: 12 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -67,14 +67,15 @@
6767
r2 = x.^2 + y.^2;
6868
r4 = r2.^2;
6969

70-
if (strcmpi(type,'s'))
70+
switch lower(type)
71+
case {'s', 'single'}
7172
logr = beta*log(r2)/2;
7273
rirjor2 = (kron(gamma*x./r2,[1 0; 1 0]) + ...
7374
kron(gamma*y./r2,[0 1; 0 1])).* ...
7475
(kron(x,[1 1; 0 0]) + kron(y,[0 0; 1 1]));
7576
mat = kron(logr+gamma/2,eye(2)) + rirjor2;
76-
end
77-
if (strcmpi(type,'strac'))
77+
78+
case {'strac'}
7879
dirx = t.n(1,:); dirx = dirx(:);
7980
diry = t.n(2,:); diry = diry(:);
8081
rdotv = dirx(:).*x + diry(:).*y;
@@ -85,8 +86,8 @@
8586
kron(y.*dirx./r2,[0 -1; 1 0]) + ...
8687
kron(rdotv./r2,[1 0; 0 1]));
8788
mat = term1+term2;
88-
end
89-
if (strcmpi(type,'sgrad'))
89+
90+
case {'sgrad', 'sg'}
9091
mat = zeros(4*m,2*n);
9192
tmp = beta*x./r2;
9293
mat(1:4:end,1:2:end) = tmp;
@@ -116,8 +117,7 @@
116117
tmp = gamma*(2*r2.*y-y.^2.*(2*y))./r4;
117118
mat(4:4:end,2:2:end) = mat(4:4:end,2:2:end) + tmp;
118119

119-
end
120-
if (strcmpi(type,'d'))
120+
case {'d', 'double'}
121121
dirx = s.n(1,:); dirx = dirx(:).';
122122
diry = s.n(2,:); diry = diry(:).';
123123
rdotv = x.*dirx + y.*diry;
@@ -128,9 +128,8 @@
128128
kron(y.*dirx./r2,[0 1; -1 0]) + ...
129129
kron(rdotv./r2,[1 0; 0 1]));
130130
mat = -(term1+term2);
131-
end
132131

133-
if (strcmpi(type,'dalt'))
132+
case {'dalt'}
134133
dirx = s.n(1,:); dirx = dirx(:).';
135134
diry = s.n(2,:); diry = diry(:).';
136135
rdotv = x.*dirx + y.*diry;
@@ -139,9 +138,8 @@
139138
(kron(x,[1 1; 0 0]) + kron(y,[0 0; 1 1]));
140139
term1 = eta*(kron(rdotv./r2,[2 0; 0 2]));
141140
mat = -(term1+term2);
142-
end
143141

144-
if (strcmpi(type,'daltgrad'))
142+
case {'daltgrad', 'daltg'}
145143
dirx = s.n(1,:); dirx = dirx(:).';
146144
diry = s.n(2,:); diry = diry(:).';
147145
rdotv = x.*dirx + y.*diry;
@@ -185,9 +183,7 @@
185183
-2*eta*(diry./r2 - 2*rdotv.*y./r4);
186184
mat(4:4:end,2:2:end) = aij_xl;
187185

188-
end
189-
190-
if (strcmpi(type,'dalttrac'))
186+
case {'dalttrac'}
191187
dirx = s.n(1,:); dirx = dirx(:).';
192188
diry = s.n(2,:); diry = diry(:).';
193189
rdotv = x.*dirx + y.*diry;
@@ -239,7 +235,8 @@
239235
tmp = mu*(matg(2:4:end,:) + matg(3:4:end,:));
240236
mat(1:2:end,:) = mat(1:2:end,:) + tmp.*n2 + 2*mu*matg(1:4:end,:).*n1;
241237
mat(2:2:end,:) = mat(2:2:end,:) + tmp.*n1 + 2*mu*matg(4:4:end,:).*n2;
242-
238+
otherwise
239+
error('Unknown elasticity kernel type ''%s''.', type);
243240
end
244241

245242
end

chunkie/+chnk/+flex2d/kern.m

Lines changed: 13 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -98,14 +98,13 @@
9898

9999
%%% STANDARD LAYER POTENTIALS
100100

101-
if strcmpi(type, 's') % flexural wave single layer
101+
switch lower(type)
102+
case {'s', 'single'} % flexural wave single layer
102103

103104
val = chnk.flex2d.hkdiffgreen(zk,src,targ);
104105
submat = 1/(2*zk^2).*val;
105106

106-
end
107-
108-
if strcmpi(type, 'sprime') % normal derivative of flexural wave single layer
107+
case {'sp', 'sprime'} % normal derivative of flexural wave single layer
109108

110109
targnorm = targinfo.n;
111110
nxtarg = repmat((targnorm(1,:)).',1,ns);
@@ -114,12 +113,10 @@
114113
[~,grad] = chnk.flex2d.hkdiffgreen(zk,src,targ);
115114
submat = 1/(2*zk^2).*(grad(:,:,1).*nxtarg + grad(:,:,2).*nytarg);
116115

117-
end
118-
119116
%%% CLAMPED PLATE KERNELS
120117

121118
% boundary conditions applied to a point source
122-
if strcmpi(type, 'clamped_plate_bcs')
119+
case {'clamped_plate_bcs'}
123120
nxtarg = targinfo.n(1,:).';
124121
nytarg = targinfo.n(2,:).';
125122
submat = zeros(2*nt,ns);
@@ -131,10 +128,9 @@
131128

132129
submat(1:2:end,:) = firstbc;
133130
submat(2:2:end,:) = secondbc;
134-
end
135131

136132
% kernels for the clamped plate integral equation
137-
if strcmpi(type, 'clamped_plate')
133+
case {'clamped_plate'}
138134
srcnorm = srcinfo.n;
139135
srctang = srcinfo.d;
140136
targnorm = targinfo.n;
@@ -195,10 +191,9 @@
195191

196192
submat(2:2:end,1:2:end) = K21;
197193
submat(2:2:end,2:2:end) = K22;
198-
end
199194

200195
% clamped plate kernels for plotting
201-
if strcmpi(type, 'clamped_plate_eval')
196+
case {'clamped_plate_eval'}
202197

203198
submat = zeros(nt,2*ns);
204199

@@ -226,13 +221,11 @@
226221
submat(:,1:2:end) = K1;
227222
submat(:,2:2:end) = K2;
228223

229-
end
230-
231224

232225
%%% FREE PLATE KERNELS
233226

234227
% boundary conditions applied to a point source
235-
if strcmpi(type, 'free_plate_bcs')
228+
case {'free_plate_bcs'}
236229
targnorm = targinfo.n;
237230
targtang = targinfo.d;
238231
targd2 = targinfo.d2;
@@ -274,10 +267,8 @@
274267
submat(1:2:end,:) = firstbc;
275268
submat(2:2:end,:) = secondbc;
276269

277-
end
278-
279270
% kernels for the free plate integral equation
280-
if strcmpi(type, 'free_plate')
271+
case {'free_plate'}
281272
srcnorm = srcinfo.n;
282273
srctang = srcinfo.d;
283274
targnorm = targinfo.n;
@@ -394,10 +385,8 @@
394385
submat(3:4:end,1:2:end) = K11H;
395386
submat(4:4:end,1:2:end) = K21H;
396387

397-
end
398-
399388
% free plate kernels used for plotting
400-
if strcmpi(type, 'free_plate_eval')
389+
case {'free_plate_eval'}
401390
srcnorm = srcinfo.n;
402391
srctang = srcinfo.d;
403392
nu = varargin{1};
@@ -423,12 +412,10 @@
423412
submat(:,2:3:end) = K1H;
424413
submat(:,3:3:end) = K2;
425414

426-
end
427-
428415
%%% SUPPORTED PLATE KERNELS
429416

430417
% boundary conditions applied to a point source
431-
if strcmpi(type, 'supported_plate_bcs')
418+
case {'supported_plate_bcs'}
432419
nxtarg = targinfo.n(1,:).';
433420
nytarg = targinfo.n(2,:).';
434421
dx = targinfo.d(1,:).';
@@ -450,11 +437,10 @@
450437

451438
submat(1:2:end,:) = firstbc;
452439
submat(2:2:end,:) = secondbc;
453-
end
454440

455441
% kernels for the supported plate integral equation that have to be
456442
% discretized using log quadrature
457-
if strcmpi(type, 'supported_plate_log')
443+
case {'supported_plate_log'}
458444
srcnorm = srcinfo.n;
459445
srctang = srcinfo.d;
460446
srcd2 = srcinfo.d2;
@@ -568,11 +554,9 @@
568554
submat(2:2:end,1:2:end) = K21;
569555
submat(2:2:end,2:2:end) = K22;
570556

571-
end
572-
573557
% the kernel for the supported plate integral equation that has to be
574558
% discretized using smooth quadrature to avoid close evaluations
575-
if strcmpi(type, 'supported_plate_smooth')
559+
case {'supported_plate_smooth'}
576560
srcnorm = srcinfo.n;
577561
srctang = srcinfo.d;
578562
srcd2 = srcinfo.d2;
@@ -673,10 +657,8 @@
673657

674658
submat(r2 == 0) = (nu - 1)*(12*kappa(r2 == 0).^3*(nu^2 - nu + 4) + kpp(r2 == 0)*(-5*nu^2 + 4*nu + 33))/(48*pi*(nu - 3)) ; % diagonal replacement
675659

676-
end
677-
678660
% supported plate kernels for plotting
679-
if strcmpi(type, 'supported_plate_eval')
661+
case {'supported_plate_eval'}
680662
srcnorm = srcinfo.n;
681663
srctang = srcinfo.d;
682664
srcd2 = srcinfo.d2;

0 commit comments

Comments
 (0)