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