|
18 | 18 |
|
19 | 19 | % normal derivative of single layer |
20 | 20 | case {'sp', 'sprime'} |
| 21 | + if ~isfield(targinfo,'n') |
| 22 | + targnorm = chnk.normal2d(targinfo); |
| 23 | + else |
| 24 | + targnorm = targinfo.n; |
| 25 | + end |
21 | 26 | [~,grad] = chnk.lap2d.green(src,targ,true); |
22 | | - nx = repmat((targinfo.n(1,:)).',1,ns); |
23 | | - ny = repmat((targinfo.n(2,:)).',1,ns); |
| 27 | + nx = repmat((targnorm(1,:)).',1,ns); |
| 28 | + ny = repmat((targnorm(2,:)).',1,ns); |
24 | 29 |
|
25 | 30 | submat = (grad(:,:,1).*nx + grad(:,:,2).*ny); |
26 | 31 |
|
27 | 32 | % Tangential derivative of single layer |
28 | 33 | case {'stau'} |
| 34 | + if ~isfield(targinfo,'n') |
| 35 | + targnorm = chnk.normal2d(targinfo); |
| 36 | + else |
| 37 | + targnorm = targinfo.n; |
| 38 | + end |
29 | 39 | [~,grad] = chnk.lap2d.green(src,targ,true); |
30 | | - nx = repmat((targinfo.n(1,:)).',1,ns); |
31 | | - ny = repmat((targinfo.n(2,:)).',1,ns); |
| 40 | + nx = repmat((targnorm(1,:)).',1,ns); |
| 41 | + ny = repmat((targnorm(2,:)).',1,ns); |
32 | 42 |
|
33 | 43 | submat = (-grad(:,:,1).*ny + grad(:,:,2).*nx); |
34 | 44 |
|
35 | 45 | % Hilbert transform (two times the adjoint of stau) |
36 | 46 | case {'hilb'} |
| 47 | + if ~isfield(srcinfo,'n') |
| 48 | + srcnorm = chnk.normal2d(srcinfo); |
| 49 | + else |
| 50 | + srcnorm = srcinfo.n; |
| 51 | + end |
37 | 52 | [~,grad] = chnk.lap2d.green(src,targ,true); |
38 | | - nx = repmat((srcinfo.n(1,:)),nt,1); |
39 | | - ny = repmat((srcinfo.n(2,:)),nt,1); |
| 53 | + nx = repmat((srcnorm(1,:)),nt,1); |
| 54 | + ny = repmat((srcnorm(2,:)),nt,1); |
40 | 55 |
|
41 | 56 | submat = 2*(grad(:,:,1).*ny - grad(:,:,2).*nx); |
42 | 57 |
|
|
47 | 62 |
|
48 | 63 | % gradient of double layer |
49 | 64 | case {'dgrad','dg'} |
| 65 | + if ~isfield(srcinfo,'n') |
| 66 | + srcnorm = chnk.normal2d(srcinfo); |
| 67 | + else |
| 68 | + srcnorm = srcinfo.n; |
| 69 | + end |
50 | 70 | [~,~,hess] = chnk.lap2d.green(src,targ,true); |
51 | | - submat = -(hess(:,:,1:2).*srcinfo.n(1,:)+hess(:,:,2:3).*srcinfo.n(2,:)); |
| 71 | + submat = -(hess(:,:,1:2).*srcnorm(1,:)+hess(:,:,2:3).*srcnorm(2,:)); |
52 | 72 | submat = reshape(permute(submat,[3,1,2]),2*nt,ns); |
53 | 73 |
|
54 | 74 | % normal derivative of double layer |
55 | 75 | case {'dprime','dp'} |
56 | | - targnorm = targinfo.n(:,:); |
57 | | - srcnorm = srcinfo.n(:,:); |
58 | | - [~,~,hess] = chnk.lap2d.green(src,targ); |
59 | | - nxsrc = repmat(srcnorm(1,:),nt,1); |
60 | | - nysrc = repmat(srcnorm(2,:),nt,1); |
61 | | - nxtarg = repmat((targnorm(1,:)).',1,ns); |
62 | | - nytarg = repmat((targnorm(2,:)).',1,ns); |
63 | | - submat = -(hess(:,:,1).*nxsrc.*nxtarg + hess(:,:,2).*(nysrc.*nxtarg+nxsrc.*nytarg)... |
| 76 | + if ~isfield(targinfo,'n') |
| 77 | + targnorm = chnk.normal2d(targinfo); |
| 78 | + else |
| 79 | + targnorm = targinfo.n; |
| 80 | + end |
| 81 | + if ~isfield(srcinfo,'n') |
| 82 | + srcnorm = chnk.normal2d(srcinfo); |
| 83 | + else |
| 84 | + srcnorm = srcinfo.n; |
| 85 | + end |
| 86 | + [~,~,hess] = chnk.lap2d.green(src,targ); |
| 87 | + nxsrc = repmat(srcnorm(1,:),nt,1); |
| 88 | + nysrc = repmat(srcnorm(2,:),nt,1); |
| 89 | + nxtarg = repmat((targnorm(1,:)).',1,ns); |
| 90 | + nytarg = repmat((targnorm(2,:)).',1,ns); |
| 91 | + submat = -(hess(:,:,1).*nxsrc.*nxtarg + hess(:,:,2).*(nysrc.*nxtarg+nxsrc.*nytarg)... |
64 | 92 | + hess(:,:,3).*nysrc.*nytarg); |
65 | 93 |
|
66 | 94 | % single layer |
|
69 | 97 |
|
70 | 98 | % combined field |
71 | 99 | case {'c', 'combined'} |
| 100 | + if ~isfield(srcinfo,'n') |
| 101 | + srcnorm = chnk.normal2d(srcinfo); |
| 102 | + else |
| 103 | + srcnorm = srcinfo.n; |
| 104 | + end |
72 | 105 | coef = ones(2,1); |
73 | 106 | if(nargin == 4); coef = varargin{1}; end |
74 | 107 | [s,grad] = chnk.lap2d.green(src,targ); |
75 | | - nx = repmat(srcinfo.n(1,:),nt,1); |
76 | | - ny = repmat(srcinfo.n(2,:),nt,1); |
| 108 | + nx = repmat(srcnorm(1,:),nt,1); |
| 109 | + ny = repmat(srcnorm(2,:),nt,1); |
77 | 110 | submat = -coef(1)*(grad(:,:,1).*nx + grad(:,:,2).*ny) + coef(2)*s; |
78 | 111 |
|
79 | 112 | % gradient of combined field |
80 | 113 | case {'cgrad', 'cg'} |
| 114 | + if ~isfield(srcinfo,'n') |
| 115 | + srcnorm = chnk.normal2d(srcinfo); |
| 116 | + else |
| 117 | + srcnorm = srcinfo.n; |
| 118 | + end |
81 | 119 | coef = ones(2,1); |
82 | 120 | if(nargin == 4); coef = varargin{1}; end |
83 | 121 | [~,grad,hess] = chnk.lap2d.green(src,targ,true); |
84 | | - submat = -(hess(:,:,1:2).*srcinfo.n(1,:)+hess(:,:,2:3).*srcinfo.n(2,:)); |
| 122 | + submat = -(hess(:,:,1:2).*srcnorm(1,:)+hess(:,:,2:3).*srcnorm(2,:)); |
85 | 123 | submat = coef(1)*reshape(permute(submat,[3,1,2]),2*nt,ns); |
86 | 124 | submat = submat+coef(2)*reshape(permute(grad,[3,1,2]),2*nt,ns); |
87 | 125 |
|
|
0 commit comments