Mercurial > repos > public > sbplib
annotate +scheme/Utux2D.m @ 666:2d85f17a8aec feature/utux2D
Add possibility for damping terms at interpolation interface.
author | Martin Almquist <malmquist@stanford.edu> |
---|---|
date | Mon, 16 Oct 2017 21:56:12 -0700 |
parents | b7b3c11fab4d |
children | f4595f14d696 |
rev | line source |
---|---|
591 | 1 classdef Utux2D < scheme.Scheme |
2 properties | |
3 m % Number of points in each direction, possibly a vector | |
4 h % Grid spacing | |
5 grid % Grid | |
6 order % Order accuracy for the approximation | |
7 v0 % Initial data | |
8 | |
9 a % Wave speed a = [a1, a2]; | |
10 | |
11 H % Discrete norm | |
595 | 12 H_x, H_y % Norms in the x and y directions |
13 Hi, Hx, Hy, Hxi, Hyi % Kroneckered norms | |
591 | 14 |
15 % Derivatives | |
16 Dx, Dy | |
17 | |
18 % Boundary operators | |
19 e_w, e_e, e_s, e_n | |
20 | |
21 D % Total discrete operator | |
605
0f9d20dbb7ce
Add centered interface coupling in addition to upwind
Martin Almquist <malmquist@stanford.edu>
parents:
595
diff
changeset
|
22 |
0f9d20dbb7ce
Add centered interface coupling in addition to upwind
Martin Almquist <malmquist@stanford.edu>
parents:
595
diff
changeset
|
23 % String, type of interface coupling |
0f9d20dbb7ce
Add centered interface coupling in addition to upwind
Martin Almquist <malmquist@stanford.edu>
parents:
595
diff
changeset
|
24 % Default: 'upwind' |
0f9d20dbb7ce
Add centered interface coupling in addition to upwind
Martin Almquist <malmquist@stanford.edu>
parents:
595
diff
changeset
|
25 % Other: 'centered' |
0f9d20dbb7ce
Add centered interface coupling in addition to upwind
Martin Almquist <malmquist@stanford.edu>
parents:
595
diff
changeset
|
26 coupling_type |
0f9d20dbb7ce
Add centered interface coupling in addition to upwind
Martin Almquist <malmquist@stanford.edu>
parents:
595
diff
changeset
|
27 |
610
b7b3c11fab4d
Add interpolation to scheme
Martin Almquist <malmquist@stanford.edu>
parents:
605
diff
changeset
|
28 % String, type of interpolation operators |
b7b3c11fab4d
Add interpolation to scheme
Martin Almquist <malmquist@stanford.edu>
parents:
605
diff
changeset
|
29 % Default: 'AWW' (Almquist Wang Werpers) |
b7b3c11fab4d
Add interpolation to scheme
Martin Almquist <malmquist@stanford.edu>
parents:
605
diff
changeset
|
30 % Other: 'MC' (Mattsson Carpenter) |
b7b3c11fab4d
Add interpolation to scheme
Martin Almquist <malmquist@stanford.edu>
parents:
605
diff
changeset
|
31 interpolation_type |
b7b3c11fab4d
Add interpolation to scheme
Martin Almquist <malmquist@stanford.edu>
parents:
605
diff
changeset
|
32 |
591 | 33 |
666
2d85f17a8aec
Add possibility for damping terms at interpolation interface.
Martin Almquist <malmquist@stanford.edu>
parents:
610
diff
changeset
|
34 % Cell array, damping on upwstream and downstream sides. |
2d85f17a8aec
Add possibility for damping terms at interpolation interface.
Martin Almquist <malmquist@stanford.edu>
parents:
610
diff
changeset
|
35 interpolation_damping |
2d85f17a8aec
Add possibility for damping terms at interpolation interface.
Martin Almquist <malmquist@stanford.edu>
parents:
610
diff
changeset
|
36 |
591 | 37 end |
38 | |
39 | |
40 methods | |
666
2d85f17a8aec
Add possibility for damping terms at interpolation interface.
Martin Almquist <malmquist@stanford.edu>
parents:
610
diff
changeset
|
41 function obj = Utux2D(g ,order, opSet, a, coupling_type, interpolation_type, interpolation_damping) |
605
0f9d20dbb7ce
Add centered interface coupling in addition to upwind
Martin Almquist <malmquist@stanford.edu>
parents:
595
diff
changeset
|
42 |
666
2d85f17a8aec
Add possibility for damping terms at interpolation interface.
Martin Almquist <malmquist@stanford.edu>
parents:
610
diff
changeset
|
43 default_arg('interpolation_damping',{0,0}); |
610
b7b3c11fab4d
Add interpolation to scheme
Martin Almquist <malmquist@stanford.edu>
parents:
605
diff
changeset
|
44 default_arg('interpolation_type','AWW'); |
605
0f9d20dbb7ce
Add centered interface coupling in addition to upwind
Martin Almquist <malmquist@stanford.edu>
parents:
595
diff
changeset
|
45 default_arg('coupling_type','upwind'); |
591 | 46 default_arg('a',1/sqrt(2)*[1, 1]); |
47 default_arg('opSet',@sbp.D2Standard); | |
48 assert(isa(g, 'grid.Cartesian')) | |
49 | |
50 m = g.size(); | |
51 m_x = m(1); | |
52 m_y = m(2); | |
53 m_tot = g.N(); | |
54 | |
595 | 55 xlim = {g.x{1}(1), g.x{1}(end)}; |
56 ylim = {g.x{2}(1), g.x{2}(end)}; | |
591 | 57 obj.grid = g; |
58 | |
59 % Operator sets | |
60 ops_x = opSet(m_x, xlim, order); | |
61 ops_y = opSet(m_y, ylim, order); | |
62 Ix = speye(m_x); | |
63 Iy = speye(m_y); | |
64 | |
65 % Norms | |
66 Hx = ops_x.H; | |
67 Hy = ops_y.H; | |
68 Hxi = ops_x.HI; | |
69 Hyi = ops_y.HI; | |
595 | 70 |
71 obj.H_x = Hx; | |
72 obj.H_y = Hy; | |
591 | 73 obj.H = kron(Hx,Hy); |
74 obj.Hi = kron(Hxi,Hyi); | |
75 obj.Hx = kron(Hx,Iy); | |
76 obj.Hy = kron(Ix,Hy); | |
77 obj.Hxi = kron(Hxi,Iy); | |
78 obj.Hyi = kron(Ix,Hyi); | |
79 | |
80 % Derivatives | |
81 Dx = ops_x.D1; | |
82 Dy = ops_y.D1; | |
83 obj.Dx = kron(Dx,Iy); | |
84 obj.Dy = kron(Ix,Dy); | |
85 | |
86 % Boundary operators | |
87 obj.e_w = kr(ops_x.e_l, Iy); | |
88 obj.e_e = kr(ops_x.e_r, Iy); | |
89 obj.e_s = kr(Ix, ops_y.e_l); | |
90 obj.e_n = kr(Ix, ops_y.e_r); | |
91 | |
92 obj.m = m; | |
93 obj.h = [ops_x.h ops_y.h]; | |
94 obj.order = order; | |
595 | 95 obj.a = a; |
605
0f9d20dbb7ce
Add centered interface coupling in addition to upwind
Martin Almquist <malmquist@stanford.edu>
parents:
595
diff
changeset
|
96 obj.coupling_type = coupling_type; |
610
b7b3c11fab4d
Add interpolation to scheme
Martin Almquist <malmquist@stanford.edu>
parents:
605
diff
changeset
|
97 obj.interpolation_type = interpolation_type; |
666
2d85f17a8aec
Add possibility for damping terms at interpolation interface.
Martin Almquist <malmquist@stanford.edu>
parents:
610
diff
changeset
|
98 obj.interpolation_damping = interpolation_damping; |
591 | 99 obj.D = -(a(1)*obj.Dx + a(2)*obj.Dy); |
100 | |
101 end | |
102 % Closure functions return the opertors applied to the own domain to close the boundary | |
103 % Penalty functions return the opertors to force the solution. In the case of an interface it returns the operator applied to the other doamin. | |
104 % boundary is a string specifying the boundary e.g. 'l','r' or 'e','w','n','s'. | |
105 % type is a string specifying the type of boundary condition if there are several. | |
106 % data is a function returning the data that should be applied at the boundary. | |
107 % neighbour_scheme is an instance of Scheme that should be interfaced to. | |
108 % neighbour_boundary is a string specifying which boundary to interface to. | |
109 function [closure, penalty] = boundary_condition(obj,boundary,type) | |
110 default_arg('type','dirichlet'); | |
111 | |
112 sigma = -1; % Scalar penalty parameter | |
113 switch boundary | |
114 case {'w','W','west','West'} | |
595 | 115 tau = sigma*obj.a(1)*obj.e_w*obj.H_y; |
591 | 116 closure = obj.Hi*tau*obj.e_w'; |
117 | |
118 case {'s','S','south','South'} | |
595 | 119 tau = sigma*obj.a(2)*obj.e_s*obj.H_x; |
591 | 120 closure = obj.Hi*tau*obj.e_s'; |
121 end | |
122 penalty = -obj.Hi*tau; | |
123 | |
124 end | |
125 | |
126 function [closure, penalty] = interface(obj,boundary,neighbour_scheme,neighbour_boundary) | |
127 | |
128 % Get neighbour boundary operator | |
129 switch neighbour_boundary | |
130 case {'e','E','east','East'} | |
131 e_neighbour = neighbour_scheme.e_e; | |
610
b7b3c11fab4d
Add interpolation to scheme
Martin Almquist <malmquist@stanford.edu>
parents:
605
diff
changeset
|
132 m_neighbour = neighbour_scheme.m(2); |
591 | 133 case {'w','W','west','West'} |
134 e_neighbour = neighbour_scheme.e_w; | |
610
b7b3c11fab4d
Add interpolation to scheme
Martin Almquist <malmquist@stanford.edu>
parents:
605
diff
changeset
|
135 m_neighbour = neighbour_scheme.m(2); |
591 | 136 case {'n','N','north','North'} |
137 e_neighbour = neighbour_scheme.e_n; | |
610
b7b3c11fab4d
Add interpolation to scheme
Martin Almquist <malmquist@stanford.edu>
parents:
605
diff
changeset
|
138 m_neighbour = neighbour_scheme.m(1); |
591 | 139 case {'s','S','south','South'} |
140 e_neighbour = neighbour_scheme.e_s; | |
610
b7b3c11fab4d
Add interpolation to scheme
Martin Almquist <malmquist@stanford.edu>
parents:
605
diff
changeset
|
141 m_neighbour = neighbour_scheme.m(1); |
591 | 142 end |
143 | |
605
0f9d20dbb7ce
Add centered interface coupling in addition to upwind
Martin Almquist <malmquist@stanford.edu>
parents:
595
diff
changeset
|
144 switch obj.coupling_type |
0f9d20dbb7ce
Add centered interface coupling in addition to upwind
Martin Almquist <malmquist@stanford.edu>
parents:
595
diff
changeset
|
145 |
0f9d20dbb7ce
Add centered interface coupling in addition to upwind
Martin Almquist <malmquist@stanford.edu>
parents:
595
diff
changeset
|
146 % Upwind coupling (energy dissipation) |
0f9d20dbb7ce
Add centered interface coupling in addition to upwind
Martin Almquist <malmquist@stanford.edu>
parents:
595
diff
changeset
|
147 case 'upwind' |
0f9d20dbb7ce
Add centered interface coupling in addition to upwind
Martin Almquist <malmquist@stanford.edu>
parents:
595
diff
changeset
|
148 sigma_ds = -1; %"Downstream" penalty |
0f9d20dbb7ce
Add centered interface coupling in addition to upwind
Martin Almquist <malmquist@stanford.edu>
parents:
595
diff
changeset
|
149 sigma_us = 0; %"Upstream" penalty |
0f9d20dbb7ce
Add centered interface coupling in addition to upwind
Martin Almquist <malmquist@stanford.edu>
parents:
595
diff
changeset
|
150 |
0f9d20dbb7ce
Add centered interface coupling in addition to upwind
Martin Almquist <malmquist@stanford.edu>
parents:
595
diff
changeset
|
151 % Energy-preserving coupling (no energy dissipation) |
0f9d20dbb7ce
Add centered interface coupling in addition to upwind
Martin Almquist <malmquist@stanford.edu>
parents:
595
diff
changeset
|
152 case 'centered' |
0f9d20dbb7ce
Add centered interface coupling in addition to upwind
Martin Almquist <malmquist@stanford.edu>
parents:
595
diff
changeset
|
153 sigma_ds = -1/2; %"Downstream" penalty |
0f9d20dbb7ce
Add centered interface coupling in addition to upwind
Martin Almquist <malmquist@stanford.edu>
parents:
595
diff
changeset
|
154 sigma_us = 1/2; %"Upstream" penalty |
0f9d20dbb7ce
Add centered interface coupling in addition to upwind
Martin Almquist <malmquist@stanford.edu>
parents:
595
diff
changeset
|
155 |
0f9d20dbb7ce
Add centered interface coupling in addition to upwind
Martin Almquist <malmquist@stanford.edu>
parents:
595
diff
changeset
|
156 otherwise |
0f9d20dbb7ce
Add centered interface coupling in addition to upwind
Martin Almquist <malmquist@stanford.edu>
parents:
595
diff
changeset
|
157 error(['Interface coupling type ' coupling_type ' is not available.']) |
0f9d20dbb7ce
Add centered interface coupling in addition to upwind
Martin Almquist <malmquist@stanford.edu>
parents:
595
diff
changeset
|
158 end |
610
b7b3c11fab4d
Add interpolation to scheme
Martin Almquist <malmquist@stanford.edu>
parents:
605
diff
changeset
|
159 |
b7b3c11fab4d
Add interpolation to scheme
Martin Almquist <malmquist@stanford.edu>
parents:
605
diff
changeset
|
160 % Check grid ratio for interpolation |
b7b3c11fab4d
Add interpolation to scheme
Martin Almquist <malmquist@stanford.edu>
parents:
605
diff
changeset
|
161 switch boundary |
b7b3c11fab4d
Add interpolation to scheme
Martin Almquist <malmquist@stanford.edu>
parents:
605
diff
changeset
|
162 case {'w','W','west','West','e','E','east','East'} |
b7b3c11fab4d
Add interpolation to scheme
Martin Almquist <malmquist@stanford.edu>
parents:
605
diff
changeset
|
163 m = obj.m(2); |
b7b3c11fab4d
Add interpolation to scheme
Martin Almquist <malmquist@stanford.edu>
parents:
605
diff
changeset
|
164 case {'s','S','south','South','n','N','north','North'} |
b7b3c11fab4d
Add interpolation to scheme
Martin Almquist <malmquist@stanford.edu>
parents:
605
diff
changeset
|
165 m = obj.m(1); |
b7b3c11fab4d
Add interpolation to scheme
Martin Almquist <malmquist@stanford.edu>
parents:
605
diff
changeset
|
166 end |
b7b3c11fab4d
Add interpolation to scheme
Martin Almquist <malmquist@stanford.edu>
parents:
605
diff
changeset
|
167 grid_ratio = m/m_neighbour; |
b7b3c11fab4d
Add interpolation to scheme
Martin Almquist <malmquist@stanford.edu>
parents:
605
diff
changeset
|
168 if grid_ratio ~= 1 |
b7b3c11fab4d
Add interpolation to scheme
Martin Almquist <malmquist@stanford.edu>
parents:
605
diff
changeset
|
169 |
b7b3c11fab4d
Add interpolation to scheme
Martin Almquist <malmquist@stanford.edu>
parents:
605
diff
changeset
|
170 [ms, index] = sort([m, m_neighbour]); |
b7b3c11fab4d
Add interpolation to scheme
Martin Almquist <malmquist@stanford.edu>
parents:
605
diff
changeset
|
171 orders = [obj.order, neighbour_scheme.order]; |
b7b3c11fab4d
Add interpolation to scheme
Martin Almquist <malmquist@stanford.edu>
parents:
605
diff
changeset
|
172 orders = orders(index); |
b7b3c11fab4d
Add interpolation to scheme
Martin Almquist <malmquist@stanford.edu>
parents:
605
diff
changeset
|
173 |
b7b3c11fab4d
Add interpolation to scheme
Martin Almquist <malmquist@stanford.edu>
parents:
605
diff
changeset
|
174 switch obj.interpolation_type |
b7b3c11fab4d
Add interpolation to scheme
Martin Almquist <malmquist@stanford.edu>
parents:
605
diff
changeset
|
175 case 'MC' |
b7b3c11fab4d
Add interpolation to scheme
Martin Almquist <malmquist@stanford.edu>
parents:
605
diff
changeset
|
176 interpOpSet = sbp.InterpMC(ms(1),ms(2),orders(1),orders(2)); |
b7b3c11fab4d
Add interpolation to scheme
Martin Almquist <malmquist@stanford.edu>
parents:
605
diff
changeset
|
177 if grid_ratio < 1 |
b7b3c11fab4d
Add interpolation to scheme
Martin Almquist <malmquist@stanford.edu>
parents:
605
diff
changeset
|
178 I_neighbour2local_us = interpOpSet.IF2C; |
b7b3c11fab4d
Add interpolation to scheme
Martin Almquist <malmquist@stanford.edu>
parents:
605
diff
changeset
|
179 I_neighbour2local_ds = interpOpSet.IF2C; |
666
2d85f17a8aec
Add possibility for damping terms at interpolation interface.
Martin Almquist <malmquist@stanford.edu>
parents:
610
diff
changeset
|
180 I_local2neighbour_us = interpOpSet.IC2F; |
2d85f17a8aec
Add possibility for damping terms at interpolation interface.
Martin Almquist <malmquist@stanford.edu>
parents:
610
diff
changeset
|
181 I_local2neighbour_ds = interpOpSet.IC2F; |
610
b7b3c11fab4d
Add interpolation to scheme
Martin Almquist <malmquist@stanford.edu>
parents:
605
diff
changeset
|
182 elseif grid_ratio > 1 |
b7b3c11fab4d
Add interpolation to scheme
Martin Almquist <malmquist@stanford.edu>
parents:
605
diff
changeset
|
183 I_neighbour2local_us = interpOpSet.IC2F; |
b7b3c11fab4d
Add interpolation to scheme
Martin Almquist <malmquist@stanford.edu>
parents:
605
diff
changeset
|
184 I_neighbour2local_ds = interpOpSet.IC2F; |
666
2d85f17a8aec
Add possibility for damping terms at interpolation interface.
Martin Almquist <malmquist@stanford.edu>
parents:
610
diff
changeset
|
185 I_local2neighbour_us = interpOpSet.IF2C; |
2d85f17a8aec
Add possibility for damping terms at interpolation interface.
Martin Almquist <malmquist@stanford.edu>
parents:
610
diff
changeset
|
186 I_local2neighbour_ds = interpOpSet.IF2C; |
610
b7b3c11fab4d
Add interpolation to scheme
Martin Almquist <malmquist@stanford.edu>
parents:
605
diff
changeset
|
187 end |
b7b3c11fab4d
Add interpolation to scheme
Martin Almquist <malmquist@stanford.edu>
parents:
605
diff
changeset
|
188 case 'AWW' |
b7b3c11fab4d
Add interpolation to scheme
Martin Almquist <malmquist@stanford.edu>
parents:
605
diff
changeset
|
189 %String 'C2F' indicates that ICF2 is more accurate. |
b7b3c11fab4d
Add interpolation to scheme
Martin Almquist <malmquist@stanford.edu>
parents:
605
diff
changeset
|
190 interpOpSetF2C = sbp.InterpAWW(ms(1),ms(2),orders(1),orders(2),'F2C'); |
b7b3c11fab4d
Add interpolation to scheme
Martin Almquist <malmquist@stanford.edu>
parents:
605
diff
changeset
|
191 interpOpSetC2F = sbp.InterpAWW(ms(1),ms(2),orders(1),orders(2),'C2F'); |
b7b3c11fab4d
Add interpolation to scheme
Martin Almquist <malmquist@stanford.edu>
parents:
605
diff
changeset
|
192 if grid_ratio < 1 |
b7b3c11fab4d
Add interpolation to scheme
Martin Almquist <malmquist@stanford.edu>
parents:
605
diff
changeset
|
193 % Local is coarser than neighbour |
b7b3c11fab4d
Add interpolation to scheme
Martin Almquist <malmquist@stanford.edu>
parents:
605
diff
changeset
|
194 I_neighbour2local_us = interpOpSetC2F.IF2C; |
b7b3c11fab4d
Add interpolation to scheme
Martin Almquist <malmquist@stanford.edu>
parents:
605
diff
changeset
|
195 I_neighbour2local_ds = interpOpSetF2C.IF2C; |
666
2d85f17a8aec
Add possibility for damping terms at interpolation interface.
Martin Almquist <malmquist@stanford.edu>
parents:
610
diff
changeset
|
196 I_local2neighbour_us = interpOpSetC2F.IC2F; |
2d85f17a8aec
Add possibility for damping terms at interpolation interface.
Martin Almquist <malmquist@stanford.edu>
parents:
610
diff
changeset
|
197 I_local2neighbour_ds = interpOpSetF2C.IC2F; |
610
b7b3c11fab4d
Add interpolation to scheme
Martin Almquist <malmquist@stanford.edu>
parents:
605
diff
changeset
|
198 elseif grid_ratio > 1 |
b7b3c11fab4d
Add interpolation to scheme
Martin Almquist <malmquist@stanford.edu>
parents:
605
diff
changeset
|
199 % Local is finer than neighbour |
b7b3c11fab4d
Add interpolation to scheme
Martin Almquist <malmquist@stanford.edu>
parents:
605
diff
changeset
|
200 I_neighbour2local_us = interpOpSetF2C.IC2F; |
b7b3c11fab4d
Add interpolation to scheme
Martin Almquist <malmquist@stanford.edu>
parents:
605
diff
changeset
|
201 I_neighbour2local_ds = interpOpSetC2F.IC2F; |
666
2d85f17a8aec
Add possibility for damping terms at interpolation interface.
Martin Almquist <malmquist@stanford.edu>
parents:
610
diff
changeset
|
202 I_local2neighbour_us = interpOpSetF2C.IF2C; |
2d85f17a8aec
Add possibility for damping terms at interpolation interface.
Martin Almquist <malmquist@stanford.edu>
parents:
610
diff
changeset
|
203 I_local2neighbour_ds = interpOpSetC2F.IF2C; |
610
b7b3c11fab4d
Add interpolation to scheme
Martin Almquist <malmquist@stanford.edu>
parents:
605
diff
changeset
|
204 end |
b7b3c11fab4d
Add interpolation to scheme
Martin Almquist <malmquist@stanford.edu>
parents:
605
diff
changeset
|
205 otherwise |
b7b3c11fab4d
Add interpolation to scheme
Martin Almquist <malmquist@stanford.edu>
parents:
605
diff
changeset
|
206 error(['Interpolation type ' obj.interpolation_type ... |
b7b3c11fab4d
Add interpolation to scheme
Martin Almquist <malmquist@stanford.edu>
parents:
605
diff
changeset
|
207 ' is not available.' ]); |
b7b3c11fab4d
Add interpolation to scheme
Martin Almquist <malmquist@stanford.edu>
parents:
605
diff
changeset
|
208 end |
b7b3c11fab4d
Add interpolation to scheme
Martin Almquist <malmquist@stanford.edu>
parents:
605
diff
changeset
|
209 |
b7b3c11fab4d
Add interpolation to scheme
Martin Almquist <malmquist@stanford.edu>
parents:
605
diff
changeset
|
210 else |
b7b3c11fab4d
Add interpolation to scheme
Martin Almquist <malmquist@stanford.edu>
parents:
605
diff
changeset
|
211 % No interpolation required |
b7b3c11fab4d
Add interpolation to scheme
Martin Almquist <malmquist@stanford.edu>
parents:
605
diff
changeset
|
212 I_neighbour2local_us = speye(m,m); |
b7b3c11fab4d
Add interpolation to scheme
Martin Almquist <malmquist@stanford.edu>
parents:
605
diff
changeset
|
213 I_neighbour2local_ds = speye(m,m); |
b7b3c11fab4d
Add interpolation to scheme
Martin Almquist <malmquist@stanford.edu>
parents:
605
diff
changeset
|
214 end |
591 | 215 |
666
2d85f17a8aec
Add possibility for damping terms at interpolation interface.
Martin Almquist <malmquist@stanford.edu>
parents:
610
diff
changeset
|
216 int_damp_us = obj.interpolation_damping{1}; |
2d85f17a8aec
Add possibility for damping terms at interpolation interface.
Martin Almquist <malmquist@stanford.edu>
parents:
610
diff
changeset
|
217 int_damp_ds = obj.interpolation_damping{2}; |
2d85f17a8aec
Add possibility for damping terms at interpolation interface.
Martin Almquist <malmquist@stanford.edu>
parents:
610
diff
changeset
|
218 |
2d85f17a8aec
Add possibility for damping terms at interpolation interface.
Martin Almquist <malmquist@stanford.edu>
parents:
610
diff
changeset
|
219 I = speye(m,m); |
2d85f17a8aec
Add possibility for damping terms at interpolation interface.
Martin Almquist <malmquist@stanford.edu>
parents:
610
diff
changeset
|
220 I_back_forth_us = I_neighbour2local_us*I_local2neighbour_us; |
2d85f17a8aec
Add possibility for damping terms at interpolation interface.
Martin Almquist <malmquist@stanford.edu>
parents:
610
diff
changeset
|
221 I_back_forth_ds = I_neighbour2local_ds*I_local2neighbour_ds; |
2d85f17a8aec
Add possibility for damping terms at interpolation interface.
Martin Almquist <malmquist@stanford.edu>
parents:
610
diff
changeset
|
222 |
2d85f17a8aec
Add possibility for damping terms at interpolation interface.
Martin Almquist <malmquist@stanford.edu>
parents:
610
diff
changeset
|
223 |
591 | 224 switch boundary |
225 case {'w','W','west','West'} | |
595 | 226 tau = sigma_ds*obj.a(1)*obj.e_w*obj.H_y; |
610
b7b3c11fab4d
Add interpolation to scheme
Martin Almquist <malmquist@stanford.edu>
parents:
605
diff
changeset
|
227 closure = obj.Hi*tau*obj.e_w'; |
666
2d85f17a8aec
Add possibility for damping terms at interpolation interface.
Martin Almquist <malmquist@stanford.edu>
parents:
610
diff
changeset
|
228 penalty = -obj.Hi*tau*I_neighbour2local_ds*e_neighbour'; |
2d85f17a8aec
Add possibility for damping terms at interpolation interface.
Martin Almquist <malmquist@stanford.edu>
parents:
610
diff
changeset
|
229 |
2d85f17a8aec
Add possibility for damping terms at interpolation interface.
Martin Almquist <malmquist@stanford.edu>
parents:
610
diff
changeset
|
230 beta = int_damp_ds*obj.a(1)... |
2d85f17a8aec
Add possibility for damping terms at interpolation interface.
Martin Almquist <malmquist@stanford.edu>
parents:
610
diff
changeset
|
231 *obj.e_w*obj.H_y; |
2d85f17a8aec
Add possibility for damping terms at interpolation interface.
Martin Almquist <malmquist@stanford.edu>
parents:
610
diff
changeset
|
232 closure = closure + obj.Hi*beta*(I_back_forth_ds - I)*obj.e_w'; |
591 | 233 case {'e','E','east','East'} |
595 | 234 tau = sigma_us*obj.a(1)*obj.e_e*obj.H_y; |
591 | 235 closure = obj.Hi*tau*obj.e_e'; |
610
b7b3c11fab4d
Add interpolation to scheme
Martin Almquist <malmquist@stanford.edu>
parents:
605
diff
changeset
|
236 penalty = -obj.Hi*tau*I_neighbour2local_us*e_neighbour'; |
666
2d85f17a8aec
Add possibility for damping terms at interpolation interface.
Martin Almquist <malmquist@stanford.edu>
parents:
610
diff
changeset
|
237 |
2d85f17a8aec
Add possibility for damping terms at interpolation interface.
Martin Almquist <malmquist@stanford.edu>
parents:
610
diff
changeset
|
238 beta = int_damp_us*obj.a(1)... |
2d85f17a8aec
Add possibility for damping terms at interpolation interface.
Martin Almquist <malmquist@stanford.edu>
parents:
610
diff
changeset
|
239 *obj.e_e*obj.H_y; |
2d85f17a8aec
Add possibility for damping terms at interpolation interface.
Martin Almquist <malmquist@stanford.edu>
parents:
610
diff
changeset
|
240 closure = closure + obj.Hi*beta*(I_back_forth_us - I)*obj.e_e'; |
591 | 241 case {'s','S','south','South'} |
595 | 242 tau = sigma_ds*obj.a(2)*obj.e_s*obj.H_x; |
591 | 243 closure = obj.Hi*tau*obj.e_s'; |
610
b7b3c11fab4d
Add interpolation to scheme
Martin Almquist <malmquist@stanford.edu>
parents:
605
diff
changeset
|
244 penalty = -obj.Hi*tau*I_neighbour2local_ds*e_neighbour'; |
666
2d85f17a8aec
Add possibility for damping terms at interpolation interface.
Martin Almquist <malmquist@stanford.edu>
parents:
610
diff
changeset
|
245 |
2d85f17a8aec
Add possibility for damping terms at interpolation interface.
Martin Almquist <malmquist@stanford.edu>
parents:
610
diff
changeset
|
246 beta = int_damp_ds*obj.a(2)... |
2d85f17a8aec
Add possibility for damping terms at interpolation interface.
Martin Almquist <malmquist@stanford.edu>
parents:
610
diff
changeset
|
247 *obj.e_s*obj.H_x; |
2d85f17a8aec
Add possibility for damping terms at interpolation interface.
Martin Almquist <malmquist@stanford.edu>
parents:
610
diff
changeset
|
248 closure = closure + obj.Hi*beta*(I_back_forth_ds - I)*obj.e_s'; |
591 | 249 case {'n','N','north','North'} |
595 | 250 tau = sigma_us*obj.a(2)*obj.e_n*obj.H_x; |
591 | 251 closure = obj.Hi*tau*obj.e_n'; |
610
b7b3c11fab4d
Add interpolation to scheme
Martin Almquist <malmquist@stanford.edu>
parents:
605
diff
changeset
|
252 penalty = -obj.Hi*tau*I_neighbour2local_us*e_neighbour'; |
666
2d85f17a8aec
Add possibility for damping terms at interpolation interface.
Martin Almquist <malmquist@stanford.edu>
parents:
610
diff
changeset
|
253 |
2d85f17a8aec
Add possibility for damping terms at interpolation interface.
Martin Almquist <malmquist@stanford.edu>
parents:
610
diff
changeset
|
254 beta = int_damp_us*obj.a(2)... |
2d85f17a8aec
Add possibility for damping terms at interpolation interface.
Martin Almquist <malmquist@stanford.edu>
parents:
610
diff
changeset
|
255 *obj.e_n*obj.H_x; |
2d85f17a8aec
Add possibility for damping terms at interpolation interface.
Martin Almquist <malmquist@stanford.edu>
parents:
610
diff
changeset
|
256 closure = closure + obj.Hi*beta*(I_back_forth_us - I)*obj.e_n'; |
591 | 257 end |
610
b7b3c11fab4d
Add interpolation to scheme
Martin Almquist <malmquist@stanford.edu>
parents:
605
diff
changeset
|
258 |
591 | 259 |
260 end | |
261 | |
262 function N = size(obj) | |
263 N = obj.m; | |
264 end | |
265 | |
266 end | |
267 | |
268 methods(Static) | |
269 % Calculates the matrices needed for the inteface coupling between boundary bound_u of scheme schm_u | |
270 % and bound_v of scheme schm_v. | |
271 % [uu, uv, vv, vu] = inteface_coupling(A,'r',B,'l') | |
272 function [uu, uv, vv, vu] = interface_coupling(schm_u,bound_u,schm_v,bound_v) | |
273 [uu,uv] = schm_u.interface(bound_u,schm_v,bound_v); | |
274 [vv,vu] = schm_v.interface(bound_v,schm_u,bound_u); | |
275 end | |
276 end | |
277 end |