0
|
1 classdef SchmBeam2d < noname.Scheme
|
|
2 properties
|
|
3 m % Number of points in each direction, possibly a vector
|
|
4 N % Number of points total
|
|
5 h % Grid spacing
|
|
6 u,v % Grid
|
|
7 x,y % Values of x and y for each grid point
|
|
8 order % Order accuracy for the approximation
|
|
9
|
|
10 D % non-stabalized scheme operator
|
|
11 M % Derivative norm
|
|
12 alpha
|
|
13
|
|
14 H % Discrete norm
|
|
15 Hi
|
|
16 H_x, H_y % Norms in the x and y directions
|
|
17 Hx,Hy % Kroneckerd norms. 1'*Hx*v corresponds to integration in the x dir.
|
|
18 Hi_x, Hi_y
|
|
19 Hix, Hiy
|
|
20 e_w, e_e, e_s, e_n
|
|
21 d1_w, d1_e, d1_s, d1_n
|
|
22 d2_w, d2_e, d2_s, d2_n
|
|
23 d3_w, d3_e, d3_s, d3_n
|
|
24 gamm_x, gamm_y
|
|
25 delt_x, delt_y
|
|
26 end
|
|
27
|
|
28 methods
|
|
29 function obj = SchmBeam2d(m,lim,order,alpha,opsGen)
|
|
30 default_arg('opsGen',@sbp.Higher);
|
|
31 default_arg('a',1);
|
|
32
|
|
33 if length(m) == 1
|
|
34 m = [m m];
|
|
35 end
|
|
36
|
|
37 m_x = m(1);
|
|
38 m_y = m(2);
|
|
39
|
|
40 xlim = lim{1};
|
|
41 ylim = lim{2};
|
|
42
|
|
43 [x, h_x] = util.get_grid(xlim{:},m_x);
|
|
44 [y, h_y] = util.get_grid(ylim{:},m_y);
|
|
45
|
|
46 ops_x = opsGen(m_x,h_x,order);
|
|
47 ops_y = opsGen(m_y,h_y,order);
|
|
48
|
|
49 I_x = speye(m_x);
|
|
50 I_y = speye(m_y);
|
|
51
|
|
52
|
|
53
|
|
54
|
|
55 D4_x = sparse(ops_x.derivatives.D4);
|
|
56 H_x = sparse(ops_x.norms.H);
|
|
57 Hi_x = sparse(ops_x.norms.HI);
|
|
58 e_l_x = sparse(ops_x.boundary.e_1);
|
|
59 e_r_x = sparse(ops_x.boundary.e_m);
|
|
60 d1_l_x = sparse(ops_x.boundary.S_1);
|
|
61 d1_r_x = sparse(ops_x.boundary.S_m);
|
|
62 d2_l_x = sparse(ops_x.boundary.S2_1);
|
|
63 d2_r_x = sparse(ops_x.boundary.S2_m);
|
|
64 d3_l_x = sparse(ops_x.boundary.S3_1);
|
|
65 d3_r_x = sparse(ops_x.boundary.S3_m);
|
|
66
|
|
67 D4_y = sparse(ops_y.derivatives.D4);
|
|
68 H_y = sparse(ops_y.norms.H);
|
|
69 Hi_y = sparse(ops_y.norms.HI);
|
|
70 e_l_y = sparse(ops_y.boundary.e_1);
|
|
71 e_r_y = sparse(ops_y.boundary.e_m);
|
|
72 d1_l_y = sparse(ops_y.boundary.S_1);
|
|
73 d1_r_y = sparse(ops_y.boundary.S_m);
|
|
74 d2_l_y = sparse(ops_y.boundary.S2_1);
|
|
75 d2_r_y = sparse(ops_y.boundary.S2_m);
|
|
76 d3_l_y = sparse(ops_y.boundary.S3_1);
|
|
77 d3_r_y = sparse(ops_y.boundary.S3_m);
|
|
78
|
|
79
|
|
80 D4 = kr(D4_x, I_y) + kr(I_x, D4_y);
|
|
81
|
|
82 % Norms
|
|
83 obj.H = kr(H_x,H_y);
|
|
84 obj.Hx = kr(H_x,I_x);
|
|
85 obj.Hy = kr(I_x,H_y);
|
|
86 obj.Hix = kr(Hi_x,I_y);
|
|
87 obj.Hiy = kr(I_x,Hi_y);
|
|
88 obj.Hi = kr(Hi_x,Hi_y);
|
|
89
|
|
90 % Boundary operators
|
|
91 obj.e_w = kr(e_l_x,I_y);
|
|
92 obj.e_e = kr(e_r_x,I_y);
|
|
93 obj.e_s = kr(I_x,e_l_y);
|
|
94 obj.e_n = kr(I_x,e_r_y);
|
|
95 obj.d1_w = kr(d1_l_x,I_y);
|
|
96 obj.d1_e = kr(d1_r_x,I_y);
|
|
97 obj.d1_s = kr(I_x,d1_l_y);
|
|
98 obj.d1_n = kr(I_x,d1_r_y);
|
|
99 obj.d2_w = kr(d2_l_x,I_y);
|
|
100 obj.d2_e = kr(d2_r_x,I_y);
|
|
101 obj.d2_s = kr(I_x,d2_l_y);
|
|
102 obj.d2_n = kr(I_x,d2_r_y);
|
|
103 obj.d3_w = kr(d3_l_x,I_y);
|
|
104 obj.d3_e = kr(d3_r_x,I_y);
|
|
105 obj.d3_s = kr(I_x,d3_l_y);
|
|
106 obj.d3_n = kr(I_x,d3_r_y);
|
|
107
|
|
108 obj.m = m;
|
|
109 obj.h = [h_x h_y];
|
|
110 obj.order = order;
|
|
111
|
|
112 obj.alpha = alpha;
|
|
113 obj.D = alpha*D4;
|
|
114 obj.u = x;
|
|
115 obj.v = y;
|
|
116 obj.x = kr(x,ones(m_y,1));
|
|
117 obj.y = kr(ones(m_x,1),y);
|
|
118
|
|
119 obj.gamm_x = h_x*ops_x.borrowing.N.S2/2;
|
|
120 obj.delt_x = h_x^3*ops_x.borrowing.N.S3/2;
|
|
121
|
|
122 obj.gamm_y = h_y*ops_y.borrowing.N.S2/2;
|
|
123 obj.delt_y = h_y^3*ops_y.borrowing.N.S3/2;
|
|
124 end
|
|
125
|
|
126
|
|
127 % Closure functions return the opertors applied to the own doamin to close the boundary
|
|
128 % Penalty functions return the opertors to force the solution. In the case of an interface it returns the operator applied to the other doamin.
|
|
129 % boundary is a string specifying the boundary e.g. 'l','r' or 'e','w','n','s'.
|
|
130 % type is a string specifying the type of boundary condition if there are several.
|
|
131 % data is a function returning the data that should be applied at the boundary.
|
|
132 % neighbour_scheme is an instance of Scheme that should be interfaced to.
|
|
133 % neighbour_boundary is a string specifying which boundary to interface to.
|
|
134 function [closure, penalty_e,penalty_d] = boundary_condition(obj,boundary,type,data)
|
|
135 default_arg('type','dn');
|
|
136 default_arg('data',0);
|
|
137
|
|
138 [e,d1,d2,d3,s,gamm,delt,halfnorm_inv] = obj.get_boundary_ops(boundary);
|
|
139
|
|
140 switch type
|
|
141 % Dirichlet-neumann boundary condition
|
|
142 case {'dn'}
|
|
143 alpha = obj.alpha;
|
|
144
|
|
145 % tau1 < -alpha^2/gamma
|
|
146 tuning = 1.1;
|
|
147
|
|
148 tau1 = tuning * alpha/delt;
|
|
149 tau4 = s*alpha;
|
|
150
|
|
151 sig2 = tuning * alpha/gamm;
|
|
152 sig3 = -s*alpha;
|
|
153
|
|
154 tau = tau1*e+tau4*d3;
|
|
155 sig = sig2*d1+sig3*d2;
|
|
156
|
|
157 closure = halfnorm_inv*(tau*e' + sig*d1');
|
|
158
|
|
159 pp_e = halfnorm_inv*tau;
|
|
160 pp_d = halfnorm_inv*sig;
|
|
161 switch class(data)
|
|
162 case 'double'
|
|
163 penalty_e = pp_e*data;
|
|
164 penalty_d = pp_d*data;
|
|
165 case 'function_handle'
|
|
166 penalty_e = @(t)pp_e*data(t);
|
|
167 penalty_d = @(t)pp_d*data(t);
|
|
168 otherwise
|
|
169 error('Wierd data argument!')
|
|
170 end
|
|
171
|
|
172 % Unknown, boundary condition
|
|
173 otherwise
|
|
174 error('No such boundary condition: type = %s',type);
|
|
175 end
|
|
176 end
|
|
177
|
|
178 function [closure, penalty] = interface(obj,boundary,neighbour_scheme,neighbour_boundary)
|
|
179 % u denotes the solution in the own domain
|
|
180 % v denotes the solution in the neighbour domain
|
|
181 [e_u,d1_u,d2_u,d3_u,s_u,gamm_u,delt_u, halfnorm_inv] = obj.get_boundary_ops(boundary);
|
|
182 [e_v,d1_v,d2_v,d3_v,s_v,gamm_v,delt_v] = neighbour_scheme.get_boundary_ops(neighbour_boundary);
|
|
183
|
|
184 tuning = 2;
|
|
185
|
|
186 alpha_u = obj.alpha;
|
|
187 alpha_v = neighbour_scheme.alpha;
|
|
188
|
|
189 tau1 = ((alpha_u/2)/delt_u + (alpha_v/2)/delt_v)/2*tuning;
|
|
190 % tau1 = (alpha_u/2 + alpha_v/2)/(2*delt_u)*tuning;
|
|
191 tau4 = s_u*alpha_u/2;
|
|
192
|
|
193 sig2 = ((alpha_u/2)/gamm_u + (alpha_v/2)/gamm_v)/2*tuning;
|
|
194 sig3 = -s_u*alpha_u/2;
|
|
195
|
|
196 phi2 = s_u*1/2;
|
|
197
|
|
198 psi1 = -s_u*1/2;
|
|
199
|
|
200 tau = tau1*e_u + tau4*d3_u;
|
|
201 sig = sig2*d1_u + sig3*d2_u ;
|
|
202 phi = phi2*d1_u ;
|
|
203 psi = psi1*e_u ;
|
|
204
|
|
205 closure = halfnorm_inv*(tau*e_u' + sig*d1_u' + phi*alpha_u*d2_u' + psi*alpha_u*d3_u');
|
|
206 penalty = -halfnorm_inv*(tau*e_v' + sig*d1_v' + phi*alpha_v*d2_v' + psi*alpha_v*d3_v');
|
|
207 end
|
|
208
|
|
209 % Ruturns the boundary ops and sign for the boundary specified by the string boundary.
|
|
210 % The right boundary is considered the positive boundary
|
|
211 function [e,d1,d2,d3,s,gamm, delt, halfnorm_inv] = get_boundary_ops(obj,boundary)
|
|
212 switch boundary
|
|
213 case 'w'
|
|
214 e = obj.e_w;
|
|
215 d1 = obj.d1_w;
|
|
216 d2 = obj.d2_w;
|
|
217 d3 = obj.d3_w;
|
|
218 s = -1;
|
|
219 gamm = obj.gamm_x;
|
|
220 delt = obj.delt_x;
|
|
221 halfnorm_inv = obj.Hix;
|
|
222 case 'e'
|
|
223 e = obj.e_e;
|
|
224 d1 = obj.d1_e;
|
|
225 d2 = obj.d2_e;
|
|
226 d3 = obj.d3_e;
|
|
227 s = 1;
|
|
228 gamm = obj.gamm_x;
|
|
229 delt = obj.delt_x;
|
|
230 halfnorm_inv = obj.Hix;
|
|
231 case 's'
|
|
232 e = obj.e_s;
|
|
233 d1 = obj.d1_s;
|
|
234 d2 = obj.d2_s;
|
|
235 d3 = obj.d3_s;
|
|
236 s = -1;
|
|
237 gamm = obj.gamm_y;
|
|
238 delt = obj.delt_y;
|
|
239 halfnorm_inv = obj.Hiy;
|
|
240 case 'n'
|
|
241 e = obj.e_n;
|
|
242 d1 = obj.d1_n;
|
|
243 d2 = obj.d2_n;
|
|
244 d3 = obj.d3_n;
|
|
245 s = 1;
|
|
246 gamm = obj.gamm_y;
|
|
247 delt = obj.delt_y;
|
|
248 halfnorm_inv = obj.Hiy;
|
|
249 otherwise
|
|
250 error('No such boundary: boundary = %s',boundary);
|
|
251 end
|
|
252 end
|
|
253
|
|
254 function N = size(obj)
|
|
255 N = prod(obj.m);
|
|
256 end
|
|
257
|
|
258 end
|
|
259 end
|