From b7e0433169474656f3027a3c114517d9839baa63 Mon Sep 17 00:00:00 2001 From: Hai Zhu Date: Fri, 18 Oct 2024 22:18:13 -0700 Subject: [PATCH] clean up stokes slp kernel split --- chunkie/@kernel/stok2d.m | 20 ++++++++++++-------- devtools/test/chunkermat_stok2dTest.m | 2 +- 2 files changed, 13 insertions(+), 9 deletions(-) diff --git a/chunkie/@kernel/stok2d.m b/chunkie/@kernel/stok2d.m index 91ae858..b5bb102 100644 --- a/chunkie/@kernel/stok2d.m +++ b/chunkie/@kernel/stok2d.m @@ -195,20 +195,24 @@ function f = stok2d_s_split(mu,s,t) dist = (s.r(1,:)+1i*s.r(2,:))-(t.r(1,:)'+1i*t.r(2,:)'); +distr = real(dist); +disti = imag(dist); f = cell(3, 1); ntarg = numel(t.r(1,:)); nsrc = numel(s.r(1,:)); +sn1mat = repmat(s.n(1,:),[ntarg 1]); +sn2mat = repmat(s.n(2,:),[ntarg 1]); f{1} = zeros(2*ntarg,2*nsrc); f{2} = zeros(2*ntarg,2*nsrc); f{3} = zeros(2*ntarg,2*nsrc); f{1}(1:2:end,1:2:end) = 1/(2*mu); f{1}(2:2:end,2:2:end) = 1/(2*mu); -f{2}(1:2:end,1:2:end) = (-(repmat(s.n(1,:),[ntarg 1]))).*real(dist)/(2*mu); -f{2}(1:2:end,2:2:end) = -((repmat(s.n(2,:),[ntarg 1]))).*real(dist)/(2*mu); -f{2}(2:2:end,1:2:end) = (-(repmat(s.n(1,:),[ntarg 1]))).*imag(dist)/(2*mu); -f{2}(2:2:end,2:2:end) = -((repmat(s.n(2,:),[ntarg 1]))).*imag(dist)/(2*mu); -f{3}(1:2:end,1:2:end) = - (repmat(s.n(2,:),[ntarg 1])).*real(dist)/(2*mu); -f{3}(1:2:end,2:2:end) = (repmat(s.n(1,:),[ntarg 1])).*real(dist)/(2*mu); -f{3}(2:2:end,1:2:end) = - (repmat(s.n(2,:),[ntarg 1])).*imag(dist)/(2*mu); -f{3}(2:2:end,2:2:end) = (repmat(s.n(1,:),[ntarg 1])).*imag(dist)/(2*mu); +f{2}(1:2:end,1:2:end) = -sn1mat.*distr/(2*mu); +f{2}(1:2:end,2:2:end) = -sn2mat.*distr/(2*mu); +f{2}(2:2:end,1:2:end) = -sn1mat.*disti/(2*mu); +f{2}(2:2:end,2:2:end) = -sn2mat.*disti/(2*mu); +f{3}(1:2:end,1:2:end) = -sn2mat.*distr/(2*mu); +f{3}(1:2:end,2:2:end) = sn1mat.*distr/(2*mu); +f{3}(2:2:end,1:2:end) = -sn2mat.*disti/(2*mu); +f{3}(2:2:end,2:2:end) = sn1mat.*disti/(2*mu); end diff --git a/devtools/test/chunkermat_stok2dTest.m b/devtools/test/chunkermat_stok2dTest.m index 6e22f47..0d1b2ed 100644 --- a/devtools/test/chunkermat_stok2dTest.m +++ b/devtools/test/chunkermat_stok2dTest.m @@ -94,7 +94,7 @@ t1 = toc(start); fprintf('%5.2e s : time to eval at targs (slow, adaptive routine)\n',t1) -% test stokes slp velocity pquad... +% just test stokes slp velocity pquad... % targets = targets.*repmat(rand(1,nt),2,1)*0.99 seems to break below stokes kernel test... fkerns = kernel('stok', 'svel', mu); Ssol = chunkerkerneval(chnkr,fkerns,sol,targets,opts);