-
Notifications
You must be signed in to change notification settings - Fork 0
/
neumann_relation.m
108 lines (79 loc) · 3.38 KB
/
neumann_relation.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
% Neumann relation class
%
% obj = neumann_relation(weights,bases,sheet,fun) represents a Neumann
% boundary condition applied to bases on a surface represented by an object
% of class sheet. In particular,
%
% weights(1) * D bases(1) + ... + weights(end) * D bases(end) + fun = 0
%
% where D denotes the normal derivative to surface.
%
% See relation for more details and an example.
%
% Here weights is a vector, bases is a vector of class basis, and surface
% is of class sheet_with_points.
%
% See also: relation, dirichlet_relation, basis, sheet_with_points.
%
% Stuart C. Hawkins - 21 April 2021
% Copyright 2019-2022 Stuart C. Hawkins
%
% This file is part of TMATROM3
%
% TMATROM3 is free software: you can redistribute it and/or modify
% it under the terms of the GNU General Public License as published by
% the Free Software Foundation, either version 3 of the License, or
% (at your option) any later version.
%
% TMATROM3 is distributed in the hope that it will be useful,
% but WITHOUT ANY WARRANTY; without even the implied warranty of
% MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
% GNU General Public License for more details.
%
% You should have received a copy of the GNU General Public License
% along with TMATROM3. If not, see <http://www.gnu.org/licenses/>.
classdef neumann_relation < relation
properties
end
methods
%-----------------------------------------
% constructor
%-----------------------------------------
function self = neumann_relation(weights,bases,sheet,fun)
% call parent constructor
self = self@relation(weights,bases,sheet,fun);
end
%-----------------------------------------
% compute scattering matrix
%-----------------------------------------
function matrix = inner_matrix(self)
% matrix involves evaluating the normal trace of self.bases on
% self.curve
matrix = self.bases.normaltrace(self.sheet,self.weights);
end
%-----------------------------------------
% compute right hand side vector
%-----------------------------------------
function rhs = inner_rhs(self)
% what we do depends on the type of self.fun....
if isa(self.fun,'function_handle')
% then evaluate the function
rhs = self.fun(self.sheet.points);
elseif isa(self.fun,'incident')
% then evaluate the gradient and take its dot product with
% the normal
% get the normal
n = self.sheet.sheet.normal(self.sheet.pointsu,self.sheet.pointsv);
% get the gradient of the incident wave
[dx,dy,dz] = self.fun.evaluateGradient(self.sheet.points);
% compute the dot product
rhs = n(1,:).*dx + n(2,:).*dy + n(3,:).*dz;
else
% report an error
error('fun is not of a supported type')
end
% make sure the right hand side is a column vector
rhs = rhs(:);
end
end
end