annotate +scheme/Utux2d.m @ 1225:68ee061639a1 feature/rv

Make sure matrices are sparse.
author Vidar Stiernström <vidar.stiernstrom@it.uu.se>
date Wed, 06 Nov 2019 14:52:07 +0100
parents 433c89bf19e0
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
950
cab047de7f5d Rename *2D schemes to *2d
Jonatan Werpers <jonatan@werpers.com>
parents: 948
diff changeset
1 classdef Utux2d < scheme.Scheme
591
39554f2de783 Add Utux2D scheme
Martin Almquist <martin.almquist@it.uu.se>
parents:
diff changeset
2 properties
39554f2de783 Add Utux2D scheme
Martin Almquist <martin.almquist@it.uu.se>
parents:
diff changeset
3 m % Number of points in each direction, possibly a vector
39554f2de783 Add Utux2D scheme
Martin Almquist <martin.almquist@it.uu.se>
parents:
diff changeset
4 h % Grid spacing
39554f2de783 Add Utux2D scheme
Martin Almquist <martin.almquist@it.uu.se>
parents:
diff changeset
5 grid % Grid
39554f2de783 Add Utux2D scheme
Martin Almquist <martin.almquist@it.uu.se>
parents:
diff changeset
6 order % Order accuracy for the approximation
905
459eeb99130f Include type as (optional) input parameter in the interface method of all schemes.
Martin Almquist <malmquist@stanford.edu>
parents: 743
diff changeset
7
591
39554f2de783 Add Utux2D scheme
Martin Almquist <martin.almquist@it.uu.se>
parents:
diff changeset
8 a % Wave speed a = [a1, a2];
743
f4595f14d696 Change schemes to work for special coefficients.
Martin Almquist <malmquist@stanford.edu>
parents: 666
diff changeset
9 % Can either be a constant vector or a cell array of function handles.
591
39554f2de783 Add Utux2D scheme
Martin Almquist <martin.almquist@it.uu.se>
parents:
diff changeset
10
39554f2de783 Add Utux2D scheme
Martin Almquist <martin.almquist@it.uu.se>
parents:
diff changeset
11 H % Discrete norm
595
2a2f34778ded Make Utux2D work
Martin Almquist <malmquist@stanford.edu>
parents: 591
diff changeset
12 H_x, H_y % Norms in the x and y directions
2a2f34778ded Make Utux2D work
Martin Almquist <malmquist@stanford.edu>
parents: 591
diff changeset
13 Hi, Hx, Hy, Hxi, Hyi % Kroneckered norms
1048
adbb80e60b10 Clean up Elastic2dVariable (partially), Utux, and Utux2d.
Martin Almquist <malmquist@stanford.edu>
parents: 1044
diff changeset
14 H_w, H_e, H_s, H_n % Boundary quadratures
591
39554f2de783 Add Utux2D scheme
Martin Almquist <martin.almquist@it.uu.se>
parents:
diff changeset
15
39554f2de783 Add Utux2D scheme
Martin Almquist <martin.almquist@it.uu.se>
parents:
diff changeset
16 % Derivatives
39554f2de783 Add Utux2D scheme
Martin Almquist <martin.almquist@it.uu.se>
parents:
diff changeset
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
39554f2de783 Add Utux2D scheme
Martin Almquist <martin.almquist@it.uu.se>
parents:
diff changeset
19 % Boundary operators
39554f2de783 Add Utux2D scheme
Martin Almquist <martin.almquist@it.uu.se>
parents:
diff changeset
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
39554f2de783 Add Utux2D scheme
Martin Almquist <martin.almquist@it.uu.se>
parents:
diff changeset
22 D % Total discrete operator
39554f2de783 Add Utux2D scheme
Martin Almquist <martin.almquist@it.uu.se>
parents:
diff changeset
23 end
39554f2de783 Add Utux2D scheme
Martin Almquist <martin.almquist@it.uu.se>
parents:
diff changeset
24
39554f2de783 Add Utux2D scheme
Martin Almquist <martin.almquist@it.uu.se>
parents:
diff changeset
25
905
459eeb99130f Include type as (optional) input parameter in the interface method of all schemes.
Martin Almquist <malmquist@stanford.edu>
parents: 743
diff changeset
26 methods
1036
8a9393084b30 Change argument order to the "correct" order, i.e providing diffOp specific parameters before the opSet.
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents: 1025
diff changeset
27 function obj = Utux2d(g ,order, a, fluxSplitting, opSet)
905
459eeb99130f Include type as (optional) input parameter in the interface method of all schemes.
Martin Almquist <malmquist@stanford.edu>
parents: 743
diff changeset
28
459eeb99130f Include type as (optional) input parameter in the interface method of all schemes.
Martin Almquist <malmquist@stanford.edu>
parents: 743
diff changeset
29 default_arg('a',1/sqrt(2)*[1, 1]);
591
39554f2de783 Add Utux2D scheme
Martin Almquist <martin.almquist@it.uu.se>
parents:
diff changeset
30 default_arg('opSet',@sbp.D2Standard);
1021
cc61dde120cd Add upwind dissipation to the operator inside Utux2d
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents: 1019
diff changeset
31 default_arg('fluxSplitting',[]);
743
f4595f14d696 Change schemes to work for special coefficients.
Martin Almquist <malmquist@stanford.edu>
parents: 666
diff changeset
32
948
3dd7f87c9a1b Use assertType(...) instead of assert(isa(...))
Jonatan Werpers <jonatan@werpers.com>
parents: 942
diff changeset
33 assertType(g, 'grid.Cartesian');
743
f4595f14d696 Change schemes to work for special coefficients.
Martin Almquist <malmquist@stanford.edu>
parents: 666
diff changeset
34 if iscell(a)
f4595f14d696 Change schemes to work for special coefficients.
Martin Almquist <malmquist@stanford.edu>
parents: 666
diff changeset
35 a1 = grid.evalOn(g, a{1});
f4595f14d696 Change schemes to work for special coefficients.
Martin Almquist <malmquist@stanford.edu>
parents: 666
diff changeset
36 a2 = grid.evalOn(g, a{2});
f4595f14d696 Change schemes to work for special coefficients.
Martin Almquist <malmquist@stanford.edu>
parents: 666
diff changeset
37 a = {spdiag(a1), spdiag(a2)};
f4595f14d696 Change schemes to work for special coefficients.
Martin Almquist <malmquist@stanford.edu>
parents: 666
diff changeset
38 else
f4595f14d696 Change schemes to work for special coefficients.
Martin Almquist <malmquist@stanford.edu>
parents: 666
diff changeset
39 a = {a(1), a(2)};
f4595f14d696 Change schemes to work for special coefficients.
Martin Almquist <malmquist@stanford.edu>
parents: 666
diff changeset
40 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
41
591
39554f2de783 Add Utux2D scheme
Martin Almquist <martin.almquist@it.uu.se>
parents:
diff changeset
42 m = g.size();
39554f2de783 Add Utux2D scheme
Martin Almquist <martin.almquist@it.uu.se>
parents:
diff changeset
43 m_x = m(1);
39554f2de783 Add Utux2D scheme
Martin Almquist <martin.almquist@it.uu.se>
parents:
diff changeset
44 m_y = m(2);
39554f2de783 Add Utux2D scheme
Martin Almquist <martin.almquist@it.uu.se>
parents:
diff changeset
45 m_tot = g.N();
39554f2de783 Add Utux2D scheme
Martin Almquist <martin.almquist@it.uu.se>
parents:
diff changeset
46
595
2a2f34778ded Make Utux2D work
Martin Almquist <malmquist@stanford.edu>
parents: 591
diff changeset
47 xlim = {g.x{1}(1), g.x{1}(end)};
2a2f34778ded Make Utux2D work
Martin Almquist <malmquist@stanford.edu>
parents: 591
diff changeset
48 ylim = {g.x{2}(1), g.x{2}(end)};
591
39554f2de783 Add Utux2D scheme
Martin Almquist <martin.almquist@it.uu.se>
parents:
diff changeset
49 obj.grid = g;
39554f2de783 Add Utux2D scheme
Martin Almquist <martin.almquist@it.uu.se>
parents:
diff changeset
50
39554f2de783 Add Utux2D scheme
Martin Almquist <martin.almquist@it.uu.se>
parents:
diff changeset
51 % Operator sets
39554f2de783 Add Utux2D scheme
Martin Almquist <martin.almquist@it.uu.se>
parents:
diff changeset
52 ops_x = opSet(m_x, xlim, order);
39554f2de783 Add Utux2D scheme
Martin Almquist <martin.almquist@it.uu.se>
parents:
diff changeset
53 ops_y = opSet(m_y, ylim, order);
39554f2de783 Add Utux2D scheme
Martin Almquist <martin.almquist@it.uu.se>
parents:
diff changeset
54 Ix = speye(m_x);
39554f2de783 Add Utux2D scheme
Martin Almquist <martin.almquist@it.uu.se>
parents:
diff changeset
55 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
56
591
39554f2de783 Add Utux2D scheme
Martin Almquist <martin.almquist@it.uu.se>
parents:
diff changeset
57 % Norms
39554f2de783 Add Utux2D scheme
Martin Almquist <martin.almquist@it.uu.se>
parents:
diff changeset
58 Hx = ops_x.H;
39554f2de783 Add Utux2D scheme
Martin Almquist <martin.almquist@it.uu.se>
parents:
diff changeset
59 Hy = ops_y.H;
39554f2de783 Add Utux2D scheme
Martin Almquist <martin.almquist@it.uu.se>
parents:
diff changeset
60 Hxi = ops_x.HI;
39554f2de783 Add Utux2D scheme
Martin Almquist <martin.almquist@it.uu.se>
parents:
diff changeset
61 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
62
1048
adbb80e60b10 Clean up Elastic2dVariable (partially), Utux, and Utux2d.
Martin Almquist <malmquist@stanford.edu>
parents: 1044
diff changeset
63 obj.H_w = Hy;
adbb80e60b10 Clean up Elastic2dVariable (partially), Utux, and Utux2d.
Martin Almquist <malmquist@stanford.edu>
parents: 1044
diff changeset
64 obj.H_e = Hy;
adbb80e60b10 Clean up Elastic2dVariable (partially), Utux, and Utux2d.
Martin Almquist <malmquist@stanford.edu>
parents: 1044
diff changeset
65 obj.H_s = Hx;
adbb80e60b10 Clean up Elastic2dVariable (partially), Utux, and Utux2d.
Martin Almquist <malmquist@stanford.edu>
parents: 1044
diff changeset
66 obj.H_n = Hx;
595
2a2f34778ded Make Utux2D work
Martin Almquist <malmquist@stanford.edu>
parents: 591
diff changeset
67 obj.H_x = Hx;
2a2f34778ded Make Utux2D work
Martin Almquist <malmquist@stanford.edu>
parents: 591
diff changeset
68 obj.H_y = Hy;
591
39554f2de783 Add Utux2D scheme
Martin Almquist <martin.almquist@it.uu.se>
parents:
diff changeset
69 obj.H = kron(Hx,Hy);
39554f2de783 Add Utux2D scheme
Martin Almquist <martin.almquist@it.uu.se>
parents:
diff changeset
70 obj.Hi = kron(Hxi,Hyi);
39554f2de783 Add Utux2D scheme
Martin Almquist <martin.almquist@it.uu.se>
parents:
diff changeset
71 obj.Hx = kron(Hx,Iy);
39554f2de783 Add Utux2D scheme
Martin Almquist <martin.almquist@it.uu.se>
parents:
diff changeset
72 obj.Hy = kron(Ix,Hy);
39554f2de783 Add Utux2D scheme
Martin Almquist <martin.almquist@it.uu.se>
parents:
diff changeset
73 obj.Hxi = kron(Hxi,Iy);
39554f2de783 Add Utux2D scheme
Martin Almquist <martin.almquist@it.uu.se>
parents:
diff changeset
74 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
75
591
39554f2de783 Add Utux2D scheme
Martin Almquist <martin.almquist@it.uu.se>
parents:
diff changeset
76 % Derivatives
1019
f029b97dbc72 Support upwind opSet in Utux2d
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents: 950
diff changeset
77 if (isequal(opSet,@sbp.D1Upwind))
f029b97dbc72 Support upwind opSet in Utux2d
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents: 950
diff changeset
78 Dx = (ops_x.Dp + ops_x.Dm)/2;
f029b97dbc72 Support upwind opSet in Utux2d
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents: 950
diff changeset
79 Dy = (ops_y.Dp + ops_y.Dm)/2;
1025
ac80bedc8df7 Clean up of Utux2d
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents: 1022
diff changeset
80 obj.Dx = kron(Dx,Iy);
ac80bedc8df7 Clean up of Utux2d
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents: 1022
diff changeset
81 obj.Dy = kron(Ix,Dy);
1019
f029b97dbc72 Support upwind opSet in Utux2d
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents: 950
diff changeset
82 DissOpx = (ops_x.Dm - ops_x.Dp)/2;
f029b97dbc72 Support upwind opSet in Utux2d
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents: 950
diff changeset
83 DissOpy = (ops_y.Dm - ops_y.Dp)/2;
1025
ac80bedc8df7 Clean up of Utux2d
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents: 1022
diff changeset
84 DissOpx = kron(DissOpx,Iy);
ac80bedc8df7 Clean up of Utux2d
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents: 1022
diff changeset
85 DissOpy = kron(Ix,DissOpy);
ac80bedc8df7 Clean up of Utux2d
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents: 1022
diff changeset
86
ac80bedc8df7 Clean up of Utux2d
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents: 1022
diff changeset
87 obj.D = -(a{1}*obj.Dx + a{2}*obj.Dy + fluxSplitting{1}*DissOpx + fluxSplitting{2}*DissOpy);
1019
f029b97dbc72 Support upwind opSet in Utux2d
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents: 950
diff changeset
88 else
f029b97dbc72 Support upwind opSet in Utux2d
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents: 950
diff changeset
89 Dx = ops_x.D1;
f029b97dbc72 Support upwind opSet in Utux2d
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents: 950
diff changeset
90 Dy = ops_y.D1;
f029b97dbc72 Support upwind opSet in Utux2d
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents: 950
diff changeset
91 obj.Dx = kron(Dx,Iy);
f029b97dbc72 Support upwind opSet in Utux2d
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents: 950
diff changeset
92 obj.Dy = kron(Ix,Dy);
1025
ac80bedc8df7 Clean up of Utux2d
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents: 1022
diff changeset
93
ac80bedc8df7 Clean up of Utux2d
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents: 1022
diff changeset
94 obj.D = -(a{1}*obj.Dx + a{2}*obj.Dy);
1019
f029b97dbc72 Support upwind opSet in Utux2d
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents: 950
diff changeset
95 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
96
591
39554f2de783 Add Utux2D scheme
Martin Almquist <martin.almquist@it.uu.se>
parents:
diff changeset
97 % Boundary operators
39554f2de783 Add Utux2D scheme
Martin Almquist <martin.almquist@it.uu.se>
parents:
diff changeset
98 obj.e_w = kr(ops_x.e_l, Iy);
39554f2de783 Add Utux2D scheme
Martin Almquist <martin.almquist@it.uu.se>
parents:
diff changeset
99 obj.e_e = kr(ops_x.e_r, Iy);
39554f2de783 Add Utux2D scheme
Martin Almquist <martin.almquist@it.uu.se>
parents:
diff changeset
100 obj.e_s = kr(Ix, ops_y.e_l);
39554f2de783 Add Utux2D scheme
Martin Almquist <martin.almquist@it.uu.se>
parents:
diff changeset
101 obj.e_n = kr(Ix, ops_y.e_r);
39554f2de783 Add Utux2D scheme
Martin Almquist <martin.almquist@it.uu.se>
parents:
diff changeset
102
39554f2de783 Add Utux2D scheme
Martin Almquist <martin.almquist@it.uu.se>
parents:
diff changeset
103 obj.m = m;
39554f2de783 Add Utux2D scheme
Martin Almquist <martin.almquist@it.uu.se>
parents:
diff changeset
104 obj.h = [ops_x.h ops_y.h];
39554f2de783 Add Utux2D scheme
Martin Almquist <martin.almquist@it.uu.se>
parents:
diff changeset
105 obj.order = order;
595
2a2f34778ded Make Utux2D work
Martin Almquist <malmquist@stanford.edu>
parents: 591
diff changeset
106 obj.a = a;
591
39554f2de783 Add Utux2D scheme
Martin Almquist <martin.almquist@it.uu.se>
parents:
diff changeset
107 end
39554f2de783 Add Utux2D scheme
Martin Almquist <martin.almquist@it.uu.se>
parents:
diff changeset
108 % Closure functions return the opertors applied to the own domain to close the boundary
39554f2de783 Add Utux2D scheme
Martin Almquist <martin.almquist@it.uu.se>
parents:
diff changeset
109 % Penalty functions return the opertors to force the solution. In the case of an interface it returns the operator applied to the other doamin.
39554f2de783 Add Utux2D scheme
Martin Almquist <martin.almquist@it.uu.se>
parents:
diff changeset
110 % boundary is a string specifying the boundary e.g. 'l','r' or 'e','w','n','s'.
1022
234c1c02ea39 Add dirichlet bc for north and south boundary and handle cases where the wave speed changes in sign.
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents: 1021
diff changeset
111 % type is a string specifying the type of boundary condition if there are several. %TBD Remove type here? Only dirichlet applicable?
591
39554f2de783 Add Utux2D scheme
Martin Almquist <martin.almquist@it.uu.se>
parents:
diff changeset
112 % data is a function returning the data that should be applied at the boundary.
39554f2de783 Add Utux2D scheme
Martin Almquist <martin.almquist@it.uu.se>
parents:
diff changeset
113 % neighbour_scheme is an instance of Scheme that should be interfaced to.
39554f2de783 Add Utux2D scheme
Martin Almquist <martin.almquist@it.uu.se>
parents:
diff changeset
114 % neighbour_boundary is a string specifying which boundary to interface to.
39554f2de783 Add Utux2D scheme
Martin Almquist <martin.almquist@it.uu.se>
parents:
diff changeset
115 function [closure, penalty] = boundary_condition(obj,boundary,type)
39554f2de783 Add Utux2D scheme
Martin Almquist <martin.almquist@it.uu.se>
parents:
diff changeset
116 default_arg('type','dirichlet');
1197
433c89bf19e0 Merge with default
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents: 1036 1051
diff changeset
117 s = obj.getBoundarySign(boundary);
433c89bf19e0 Merge with default
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents: 1036 1051
diff changeset
118 e = obj.getBoundaryOperator('e', boundary);
433c89bf19e0 Merge with default
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents: 1036 1051
diff changeset
119 H_1d = obj.getOneDirectionalNorm(boundary);
591
39554f2de783 Add Utux2D scheme
Martin Almquist <martin.almquist@it.uu.se>
parents:
diff changeset
120 switch boundary
1025
ac80bedc8df7 Clean up of Utux2d
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents: 1022
diff changeset
121 % Can only specify boundary condition where there is inflow
ac80bedc8df7 Clean up of Utux2d
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents: 1022
diff changeset
122 % Extract the postivie resp. negative part of a, for the left
ac80bedc8df7 Clean up of Utux2d
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents: 1022
diff changeset
123 % resp. right boundaries, and set other values of a to zero.
ac80bedc8df7 Clean up of Utux2d
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents: 1022
diff changeset
124 % Then the closure will effectively only contribute to inflow boundaries
591
39554f2de783 Add Utux2D scheme
Martin Almquist <martin.almquist@it.uu.se>
parents:
diff changeset
125 case {'w','W','west','West'}
1025
ac80bedc8df7 Clean up of Utux2d
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents: 1022
diff changeset
126 a_inflow = obj.a{1};
ac80bedc8df7 Clean up of Utux2d
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents: 1022
diff changeset
127 a_inflow(a_inflow < 0) = 0;
ac80bedc8df7 Clean up of Utux2d
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents: 1022
diff changeset
128 case {'e','E','east','East'}
ac80bedc8df7 Clean up of Utux2d
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents: 1022
diff changeset
129 a_inflow = obj.a{1};
ac80bedc8df7 Clean up of Utux2d
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents: 1022
diff changeset
130 a_inflow(a_inflow > 0) = 0;
591
39554f2de783 Add Utux2D scheme
Martin Almquist <martin.almquist@it.uu.se>
parents:
diff changeset
131 case {'s','S','south','South'}
1025
ac80bedc8df7 Clean up of Utux2d
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents: 1022
diff changeset
132 a_inflow = obj.a{2};
ac80bedc8df7 Clean up of Utux2d
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents: 1022
diff changeset
133 a_inflow(a_inflow < 0) = 0;
1022
234c1c02ea39 Add dirichlet bc for north and south boundary and handle cases where the wave speed changes in sign.
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents: 1021
diff changeset
134 case {'n','N','north','North'}
1025
ac80bedc8df7 Clean up of Utux2d
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents: 1022
diff changeset
135 a_inflow = obj.a{2};
ac80bedc8df7 Clean up of Utux2d
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents: 1022
diff changeset
136 a_inflow(a_inflow > 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
137 end
1197
433c89bf19e0 Merge with default
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents: 1036 1051
diff changeset
138 tau = s*a_inflow*e*H_1d;
433c89bf19e0 Merge with default
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents: 1036 1051
diff changeset
139 closure = obj.Hi*tau*e';
591
39554f2de783 Add Utux2D scheme
Martin Almquist <martin.almquist@it.uu.se>
parents:
diff changeset
140 penalty = -obj.Hi*tau;
914
50cafc4b9e40 Make default_field overwrite if field exists but is empty. Refactor interface method in Utux2d.
Martin Almquist <malmquist@stanford.edu>
parents: 910
diff changeset
141 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
142
942
35701c85e356 Make Utux2D work with new interface type etc.
Martin Almquist <malmquist@stanford.edu>
parents: 914
diff changeset
143 % type Struct that specifies the interface coupling.
914
50cafc4b9e40 Make default_field overwrite if field exists but is empty. Refactor interface method in Utux2d.
Martin Almquist <malmquist@stanford.edu>
parents: 910
diff changeset
144 % Fields:
50cafc4b9e40 Make default_field overwrite if field exists but is empty. Refactor interface method in Utux2d.
Martin Almquist <malmquist@stanford.edu>
parents: 910
diff changeset
145 % -- couplingType String, type of interface coupling
50cafc4b9e40 Make default_field overwrite if field exists but is empty. Refactor interface method in Utux2d.
Martin Almquist <malmquist@stanford.edu>
parents: 910
diff changeset
146 % % Default: 'upwind'. Other: 'centered'
942
35701c85e356 Make Utux2D work with new interface type etc.
Martin Almquist <malmquist@stanford.edu>
parents: 914
diff changeset
147 % -- interpolation: type of interpolation, default 'none'
35701c85e356 Make Utux2D work with new interface type etc.
Martin Almquist <malmquist@stanford.edu>
parents: 914
diff changeset
148 % -- interpolationDamping: damping on upstream and downstream sides, when using interpolation.
35701c85e356 Make Utux2D work with new interface type etc.
Martin Almquist <malmquist@stanford.edu>
parents: 914
diff changeset
149 % Default {0,0} gives zero damping.
35701c85e356 Make Utux2D work with new interface type etc.
Martin Almquist <malmquist@stanford.edu>
parents: 914
diff changeset
150 function [closure, penalty] = interface(obj,boundary,neighbour_scheme,neighbour_boundary,type)
35701c85e356 Make Utux2D work with new interface type etc.
Martin Almquist <malmquist@stanford.edu>
parents: 914
diff changeset
151
35701c85e356 Make Utux2D work with new interface type etc.
Martin Almquist <malmquist@stanford.edu>
parents: 914
diff changeset
152 defaultType.couplingType = 'upwind';
35701c85e356 Make Utux2D work with new interface type etc.
Martin Almquist <malmquist@stanford.edu>
parents: 914
diff changeset
153 defaultType.interpolation = 'none';
35701c85e356 Make Utux2D work with new interface type etc.
Martin Almquist <malmquist@stanford.edu>
parents: 914
diff changeset
154 defaultType.interpolationDamping = {0,0};
35701c85e356 Make Utux2D work with new interface type etc.
Martin Almquist <malmquist@stanford.edu>
parents: 914
diff changeset
155 default_struct('type', defaultType);
35701c85e356 Make Utux2D work with new interface type etc.
Martin Almquist <malmquist@stanford.edu>
parents: 914
diff changeset
156
35701c85e356 Make Utux2D work with new interface type etc.
Martin Almquist <malmquist@stanford.edu>
parents: 914
diff changeset
157 switch type.interpolation
35701c85e356 Make Utux2D work with new interface type etc.
Martin Almquist <malmquist@stanford.edu>
parents: 914
diff changeset
158 case {'none', ''}
35701c85e356 Make Utux2D work with new interface type etc.
Martin Almquist <malmquist@stanford.edu>
parents: 914
diff changeset
159 [closure, penalty] = interfaceStandard(obj,boundary,neighbour_scheme,neighbour_boundary,type);
35701c85e356 Make Utux2D work with new interface type etc.
Martin Almquist <malmquist@stanford.edu>
parents: 914
diff changeset
160 case {'op','OP'}
35701c85e356 Make Utux2D work with new interface type etc.
Martin Almquist <malmquist@stanford.edu>
parents: 914
diff changeset
161 [closure, penalty] = interfaceNonConforming(obj,boundary,neighbour_scheme,neighbour_boundary,type);
35701c85e356 Make Utux2D work with new interface type etc.
Martin Almquist <malmquist@stanford.edu>
parents: 914
diff changeset
162 otherwise
35701c85e356 Make Utux2D work with new interface type etc.
Martin Almquist <malmquist@stanford.edu>
parents: 914
diff changeset
163 error('Unknown type of interpolation: %s ', type.interpolation);
914
50cafc4b9e40 Make default_field overwrite if field exists but is empty. Refactor interface method in Utux2d.
Martin Almquist <malmquist@stanford.edu>
parents: 910
diff changeset
164 end
50cafc4b9e40 Make default_field overwrite if field exists but is empty. Refactor interface method in Utux2d.
Martin Almquist <malmquist@stanford.edu>
parents: 910
diff changeset
165 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
166
942
35701c85e356 Make Utux2D work with new interface type etc.
Martin Almquist <malmquist@stanford.edu>
parents: 914
diff changeset
167 function [closure, penalty] = interfaceStandard(obj,boundary,neighbour_scheme,neighbour_boundary,type)
35701c85e356 Make Utux2D work with new interface type etc.
Martin Almquist <malmquist@stanford.edu>
parents: 914
diff changeset
168 couplingType = type.couplingType;
905
459eeb99130f Include type as (optional) input parameter in the interface method of all schemes.
Martin Almquist <malmquist@stanford.edu>
parents: 743
diff changeset
169
914
50cafc4b9e40 Make default_field overwrite if field exists but is empty. Refactor interface method in Utux2d.
Martin Almquist <malmquist@stanford.edu>
parents: 910
diff changeset
170 % Get neighbour boundary operator
997
78db023a7fe3 Add getBoundaryOperator method to all 2d schemes, except obsolete Wave2dCurve and ElastiCurve, which needs a big makeover.
Martin Almquist <malmquist@stanford.edu>
parents: 950
diff changeset
171 e_neighbour = neighbour_scheme.getBoundaryOperator('e', neighbour_boundary);
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
914
50cafc4b9e40 Make default_field overwrite if field exists but is empty. Refactor interface method in Utux2d.
Martin Almquist <malmquist@stanford.edu>
parents: 910
diff changeset
173 switch couplingType
50cafc4b9e40 Make default_field overwrite if field exists but is empty. Refactor interface method in Utux2d.
Martin Almquist <malmquist@stanford.edu>
parents: 910
diff changeset
174
50cafc4b9e40 Make default_field overwrite if field exists but is empty. Refactor interface method in Utux2d.
Martin Almquist <malmquist@stanford.edu>
parents: 910
diff changeset
175 % Upwind coupling (energy dissipation)
50cafc4b9e40 Make default_field overwrite if field exists but is empty. Refactor interface method in Utux2d.
Martin Almquist <malmquist@stanford.edu>
parents: 910
diff changeset
176 case 'upwind'
605
0f9d20dbb7ce Add centered interface coupling in addition to upwind
Martin Almquist <malmquist@stanford.edu>
parents: 595
diff changeset
177 sigma_ds = -1; %"Downstream" penalty
0f9d20dbb7ce Add centered interface coupling in addition to upwind
Martin Almquist <malmquist@stanford.edu>
parents: 595
diff changeset
178 sigma_us = 0; %"Upstream" penalty
0f9d20dbb7ce Add centered interface coupling in addition to upwind
Martin Almquist <malmquist@stanford.edu>
parents: 595
diff changeset
179
914
50cafc4b9e40 Make default_field overwrite if field exists but is empty. Refactor interface method in Utux2d.
Martin Almquist <malmquist@stanford.edu>
parents: 910
diff changeset
180 % Energy-preserving coupling (no energy dissipation)
50cafc4b9e40 Make default_field overwrite if field exists but is empty. Refactor interface method in Utux2d.
Martin Almquist <malmquist@stanford.edu>
parents: 910
diff changeset
181 case 'centered'
605
0f9d20dbb7ce Add centered interface coupling in addition to upwind
Martin Almquist <malmquist@stanford.edu>
parents: 595
diff changeset
182 sigma_ds = -1/2; %"Downstream" penalty
0f9d20dbb7ce Add centered interface coupling in addition to upwind
Martin Almquist <malmquist@stanford.edu>
parents: 595
diff changeset
183 sigma_us = 1/2; %"Upstream" penalty
0f9d20dbb7ce Add centered interface coupling in addition to upwind
Martin Almquist <malmquist@stanford.edu>
parents: 595
diff changeset
184
914
50cafc4b9e40 Make default_field overwrite if field exists but is empty. Refactor interface method in Utux2d.
Martin Almquist <malmquist@stanford.edu>
parents: 910
diff changeset
185 otherwise
942
35701c85e356 Make Utux2D work with new interface type etc.
Martin Almquist <malmquist@stanford.edu>
parents: 914
diff changeset
186 error(['Interface coupling type ' couplingType ' is not available.'])
914
50cafc4b9e40 Make default_field overwrite if field exists but is empty. Refactor interface method in Utux2d.
Martin Almquist <malmquist@stanford.edu>
parents: 910
diff changeset
187 end
50cafc4b9e40 Make default_field overwrite if field exists but is empty. Refactor interface method in Utux2d.
Martin Almquist <malmquist@stanford.edu>
parents: 910
diff changeset
188
50cafc4b9e40 Make default_field overwrite if field exists but is empty. Refactor interface method in Utux2d.
Martin Almquist <malmquist@stanford.edu>
parents: 910
diff changeset
189 switch boundary
50cafc4b9e40 Make default_field overwrite if field exists but is empty. Refactor interface method in Utux2d.
Martin Almquist <malmquist@stanford.edu>
parents: 910
diff changeset
190 case {'w','W','west','West'}
50cafc4b9e40 Make default_field overwrite if field exists but is empty. Refactor interface method in Utux2d.
Martin Almquist <malmquist@stanford.edu>
parents: 910
diff changeset
191 tau = sigma_ds*obj.a{1}*obj.e_w*obj.H_y;
50cafc4b9e40 Make default_field overwrite if field exists but is empty. Refactor interface method in Utux2d.
Martin Almquist <malmquist@stanford.edu>
parents: 910
diff changeset
192 closure = obj.Hi*tau*obj.e_w';
50cafc4b9e40 Make default_field overwrite if field exists but is empty. Refactor interface method in Utux2d.
Martin Almquist <malmquist@stanford.edu>
parents: 910
diff changeset
193 penalty = -obj.Hi*tau*e_neighbour';
50cafc4b9e40 Make default_field overwrite if field exists but is empty. Refactor interface method in Utux2d.
Martin Almquist <malmquist@stanford.edu>
parents: 910
diff changeset
194 case {'e','E','east','East'}
50cafc4b9e40 Make default_field overwrite if field exists but is empty. Refactor interface method in Utux2d.
Martin Almquist <malmquist@stanford.edu>
parents: 910
diff changeset
195 tau = sigma_us*obj.a{1}*obj.e_e*obj.H_y;
50cafc4b9e40 Make default_field overwrite if field exists but is empty. Refactor interface method in Utux2d.
Martin Almquist <malmquist@stanford.edu>
parents: 910
diff changeset
196 closure = obj.Hi*tau*obj.e_e';
50cafc4b9e40 Make default_field overwrite if field exists but is empty. Refactor interface method in Utux2d.
Martin Almquist <malmquist@stanford.edu>
parents: 910
diff changeset
197 penalty = -obj.Hi*tau*e_neighbour';
50cafc4b9e40 Make default_field overwrite if field exists but is empty. Refactor interface method in Utux2d.
Martin Almquist <malmquist@stanford.edu>
parents: 910
diff changeset
198 case {'s','S','south','South'}
50cafc4b9e40 Make default_field overwrite if field exists but is empty. Refactor interface method in Utux2d.
Martin Almquist <malmquist@stanford.edu>
parents: 910
diff changeset
199 tau = sigma_ds*obj.a{2}*obj.e_s*obj.H_x;
50cafc4b9e40 Make default_field overwrite if field exists but is empty. Refactor interface method in Utux2d.
Martin Almquist <malmquist@stanford.edu>
parents: 910
diff changeset
200 closure = obj.Hi*tau*obj.e_s';
50cafc4b9e40 Make default_field overwrite if field exists but is empty. Refactor interface method in Utux2d.
Martin Almquist <malmquist@stanford.edu>
parents: 910
diff changeset
201 penalty = -obj.Hi*tau*e_neighbour';
50cafc4b9e40 Make default_field overwrite if field exists but is empty. Refactor interface method in Utux2d.
Martin Almquist <malmquist@stanford.edu>
parents: 910
diff changeset
202 case {'n','N','north','North'}
50cafc4b9e40 Make default_field overwrite if field exists but is empty. Refactor interface method in Utux2d.
Martin Almquist <malmquist@stanford.edu>
parents: 910
diff changeset
203 tau = sigma_us*obj.a{2}*obj.e_n*obj.H_x;
50cafc4b9e40 Make default_field overwrite if field exists but is empty. Refactor interface method in Utux2d.
Martin Almquist <malmquist@stanford.edu>
parents: 910
diff changeset
204 closure = obj.Hi*tau*obj.e_n';
50cafc4b9e40 Make default_field overwrite if field exists but is empty. Refactor interface method in Utux2d.
Martin Almquist <malmquist@stanford.edu>
parents: 910
diff changeset
205 penalty = -obj.Hi*tau*e_neighbour';
605
0f9d20dbb7ce Add centered interface coupling in addition to upwind
Martin Almquist <malmquist@stanford.edu>
parents: 595
diff changeset
206 end
610
b7b3c11fab4d Add interpolation to scheme
Martin Almquist <malmquist@stanford.edu>
parents: 605
diff changeset
207
914
50cafc4b9e40 Make default_field overwrite if field exists but is empty. Refactor interface method in Utux2d.
Martin Almquist <malmquist@stanford.edu>
parents: 910
diff changeset
208 end
610
b7b3c11fab4d Add interpolation to scheme
Martin Almquist <malmquist@stanford.edu>
parents: 605
diff changeset
209
942
35701c85e356 Make Utux2D work with new interface type etc.
Martin Almquist <malmquist@stanford.edu>
parents: 914
diff changeset
210 function [closure, penalty] = interfaceNonConforming(obj,boundary,neighbour_scheme,neighbour_boundary,type)
35701c85e356 Make Utux2D work with new interface type etc.
Martin Almquist <malmquist@stanford.edu>
parents: 914
diff changeset
211
35701c85e356 Make Utux2D work with new interface type etc.
Martin Almquist <malmquist@stanford.edu>
parents: 914
diff changeset
212 % User can request special interpolation operators by specifying type.interpOpSet
35701c85e356 Make Utux2D work with new interface type etc.
Martin Almquist <malmquist@stanford.edu>
parents: 914
diff changeset
213 default_field(type, 'interpOpSet', @sbp.InterpOpsOP);
35701c85e356 Make Utux2D work with new interface type etc.
Martin Almquist <malmquist@stanford.edu>
parents: 914
diff changeset
214
35701c85e356 Make Utux2D work with new interface type etc.
Martin Almquist <malmquist@stanford.edu>
parents: 914
diff changeset
215 interpOpSet = type.interpOpSet;
35701c85e356 Make Utux2D work with new interface type etc.
Martin Almquist <malmquist@stanford.edu>
parents: 914
diff changeset
216 couplingType = type.couplingType;
35701c85e356 Make Utux2D work with new interface type etc.
Martin Almquist <malmquist@stanford.edu>
parents: 914
diff changeset
217 interpolationDamping = type.interpolationDamping;
610
b7b3c11fab4d Add interpolation to scheme
Martin Almquist <malmquist@stanford.edu>
parents: 605
diff changeset
218
914
50cafc4b9e40 Make default_field overwrite if field exists but is empty. Refactor interface method in Utux2d.
Martin Almquist <malmquist@stanford.edu>
parents: 910
diff changeset
219 % Get neighbour boundary operator
997
78db023a7fe3 Add getBoundaryOperator method to all 2d schemes, except obsolete Wave2dCurve and ElastiCurve, which needs a big makeover.
Martin Almquist <malmquist@stanford.edu>
parents: 950
diff changeset
220 e_neighbour = neighbour_scheme.getBoundaryOperator('e', neighbour_boundary);
905
459eeb99130f Include type as (optional) input parameter in the interface method of all schemes.
Martin Almquist <malmquist@stanford.edu>
parents: 743
diff changeset
221
914
50cafc4b9e40 Make default_field overwrite if field exists but is empty. Refactor interface method in Utux2d.
Martin Almquist <malmquist@stanford.edu>
parents: 910
diff changeset
222 switch couplingType
50cafc4b9e40 Make default_field overwrite if field exists but is empty. Refactor interface method in Utux2d.
Martin Almquist <malmquist@stanford.edu>
parents: 910
diff changeset
223
50cafc4b9e40 Make default_field overwrite if field exists but is empty. Refactor interface method in Utux2d.
Martin Almquist <malmquist@stanford.edu>
parents: 910
diff changeset
224 % Upwind coupling (energy dissipation)
50cafc4b9e40 Make default_field overwrite if field exists but is empty. Refactor interface method in Utux2d.
Martin Almquist <malmquist@stanford.edu>
parents: 910
diff changeset
225 case 'upwind'
50cafc4b9e40 Make default_field overwrite if field exists but is empty. Refactor interface method in Utux2d.
Martin Almquist <malmquist@stanford.edu>
parents: 910
diff changeset
226 sigma_ds = -1; %"Downstream" penalty
50cafc4b9e40 Make default_field overwrite if field exists but is empty. Refactor interface method in Utux2d.
Martin Almquist <malmquist@stanford.edu>
parents: 910
diff changeset
227 sigma_us = 0; %"Upstream" penalty
50cafc4b9e40 Make default_field overwrite if field exists but is empty. Refactor interface method in Utux2d.
Martin Almquist <malmquist@stanford.edu>
parents: 910
diff changeset
228
50cafc4b9e40 Make default_field overwrite if field exists but is empty. Refactor interface method in Utux2d.
Martin Almquist <malmquist@stanford.edu>
parents: 910
diff changeset
229 % Energy-preserving coupling (no energy dissipation)
50cafc4b9e40 Make default_field overwrite if field exists but is empty. Refactor interface method in Utux2d.
Martin Almquist <malmquist@stanford.edu>
parents: 910
diff changeset
230 case 'centered'
50cafc4b9e40 Make default_field overwrite if field exists but is empty. Refactor interface method in Utux2d.
Martin Almquist <malmquist@stanford.edu>
parents: 910
diff changeset
231 sigma_ds = -1/2; %"Downstream" penalty
50cafc4b9e40 Make default_field overwrite if field exists but is empty. Refactor interface method in Utux2d.
Martin Almquist <malmquist@stanford.edu>
parents: 910
diff changeset
232 sigma_us = 1/2; %"Upstream" penalty
666
2d85f17a8aec Add possibility for damping terms at interpolation interface.
Martin Almquist <malmquist@stanford.edu>
parents: 610
diff changeset
233
914
50cafc4b9e40 Make default_field overwrite if field exists but is empty. Refactor interface method in Utux2d.
Martin Almquist <malmquist@stanford.edu>
parents: 910
diff changeset
234 otherwise
50cafc4b9e40 Make default_field overwrite if field exists but is empty. Refactor interface method in Utux2d.
Martin Almquist <malmquist@stanford.edu>
parents: 910
diff changeset
235 error(['Interface coupling type ' couplingType ' is not available.'])
50cafc4b9e40 Make default_field overwrite if field exists but is empty. Refactor interface method in Utux2d.
Martin Almquist <malmquist@stanford.edu>
parents: 910
diff changeset
236 end
50cafc4b9e40 Make default_field overwrite if field exists but is empty. Refactor interface method in Utux2d.
Martin Almquist <malmquist@stanford.edu>
parents: 910
diff changeset
237
50cafc4b9e40 Make default_field overwrite if field exists but is empty. Refactor interface method in Utux2d.
Martin Almquist <malmquist@stanford.edu>
parents: 910
diff changeset
238 int_damp_us = interpolationDamping{1};
50cafc4b9e40 Make default_field overwrite if field exists but is empty. Refactor interface method in Utux2d.
Martin Almquist <malmquist@stanford.edu>
parents: 910
diff changeset
239 int_damp_ds = interpolationDamping{2};
50cafc4b9e40 Make default_field overwrite if field exists but is empty. Refactor interface method in Utux2d.
Martin Almquist <malmquist@stanford.edu>
parents: 910
diff changeset
240
50cafc4b9e40 Make default_field overwrite if field exists but is empty. Refactor interface method in Utux2d.
Martin Almquist <malmquist@stanford.edu>
parents: 910
diff changeset
241 % u denotes the solution in the own domain
50cafc4b9e40 Make default_field overwrite if field exists but is empty. Refactor interface method in Utux2d.
Martin Almquist <malmquist@stanford.edu>
parents: 910
diff changeset
242 % v denotes the solution in the neighbour domain
942
35701c85e356 Make Utux2D work with new interface type etc.
Martin Almquist <malmquist@stanford.edu>
parents: 914
diff changeset
243 % Find the number of grid points along the interface
35701c85e356 Make Utux2D work with new interface type etc.
Martin Almquist <malmquist@stanford.edu>
parents: 914
diff changeset
244 switch boundary
35701c85e356 Make Utux2D work with new interface type etc.
Martin Almquist <malmquist@stanford.edu>
parents: 914
diff changeset
245 case {'w','e'}
35701c85e356 Make Utux2D work with new interface type etc.
Martin Almquist <malmquist@stanford.edu>
parents: 914
diff changeset
246 m_u = obj.m(2);
35701c85e356 Make Utux2D work with new interface type etc.
Martin Almquist <malmquist@stanford.edu>
parents: 914
diff changeset
247 case {'s','n'}
35701c85e356 Make Utux2D work with new interface type etc.
Martin Almquist <malmquist@stanford.edu>
parents: 914
diff changeset
248 m_u = obj.m(1);
35701c85e356 Make Utux2D work with new interface type etc.
Martin Almquist <malmquist@stanford.edu>
parents: 914
diff changeset
249 end
35701c85e356 Make Utux2D work with new interface type etc.
Martin Almquist <malmquist@stanford.edu>
parents: 914
diff changeset
250 m_v = size(e_neighbour, 2);
35701c85e356 Make Utux2D work with new interface type etc.
Martin Almquist <malmquist@stanford.edu>
parents: 914
diff changeset
251
35701c85e356 Make Utux2D work with new interface type etc.
Martin Almquist <malmquist@stanford.edu>
parents: 914
diff changeset
252 % Build interpolation operators
35701c85e356 Make Utux2D work with new interface type etc.
Martin Almquist <malmquist@stanford.edu>
parents: 914
diff changeset
253 intOps = interpOpSet(m_u, m_v, obj.order, neighbour_scheme.order);
35701c85e356 Make Utux2D work with new interface type etc.
Martin Almquist <malmquist@stanford.edu>
parents: 914
diff changeset
254 Iu2v = intOps.Iu2v;
35701c85e356 Make Utux2D work with new interface type etc.
Martin Almquist <malmquist@stanford.edu>
parents: 914
diff changeset
255 Iv2u = intOps.Iv2u;
35701c85e356 Make Utux2D work with new interface type etc.
Martin Almquist <malmquist@stanford.edu>
parents: 914
diff changeset
256
35701c85e356 Make Utux2D work with new interface type etc.
Martin Almquist <malmquist@stanford.edu>
parents: 914
diff changeset
257 I_local2neighbour_ds = intOps.Iu2v.bad;
35701c85e356 Make Utux2D work with new interface type etc.
Martin Almquist <malmquist@stanford.edu>
parents: 914
diff changeset
258 I_local2neighbour_us = intOps.Iu2v.good;
35701c85e356 Make Utux2D work with new interface type etc.
Martin Almquist <malmquist@stanford.edu>
parents: 914
diff changeset
259 I_neighbour2local_ds = intOps.Iv2u.good;
35701c85e356 Make Utux2D work with new interface type etc.
Martin Almquist <malmquist@stanford.edu>
parents: 914
diff changeset
260 I_neighbour2local_us = intOps.Iv2u.bad;
914
50cafc4b9e40 Make default_field overwrite if field exists but is empty. Refactor interface method in Utux2d.
Martin Almquist <malmquist@stanford.edu>
parents: 910
diff changeset
261
50cafc4b9e40 Make default_field overwrite if field exists but is empty. Refactor interface method in Utux2d.
Martin Almquist <malmquist@stanford.edu>
parents: 910
diff changeset
262 I_back_forth_us = I_neighbour2local_us*I_local2neighbour_us;
50cafc4b9e40 Make default_field overwrite if field exists but is empty. Refactor interface method in Utux2d.
Martin Almquist <malmquist@stanford.edu>
parents: 910
diff changeset
263 I_back_forth_ds = I_neighbour2local_ds*I_local2neighbour_ds;
666
2d85f17a8aec Add possibility for damping terms at interpolation interface.
Martin Almquist <malmquist@stanford.edu>
parents: 610
diff changeset
264
2d85f17a8aec Add possibility for damping terms at interpolation interface.
Martin Almquist <malmquist@stanford.edu>
parents: 610
diff changeset
265
942
35701c85e356 Make Utux2D work with new interface type etc.
Martin Almquist <malmquist@stanford.edu>
parents: 914
diff changeset
266 switch boundary
35701c85e356 Make Utux2D work with new interface type etc.
Martin Almquist <malmquist@stanford.edu>
parents: 914
diff changeset
267 case {'w','W','west','West'}
35701c85e356 Make Utux2D work with new interface type etc.
Martin Almquist <malmquist@stanford.edu>
parents: 914
diff changeset
268 tau = sigma_ds*obj.a{1}*obj.e_w*obj.H_y;
35701c85e356 Make Utux2D work with new interface type etc.
Martin Almquist <malmquist@stanford.edu>
parents: 914
diff changeset
269 closure = obj.Hi*tau*obj.e_w';
35701c85e356 Make Utux2D work with new interface type etc.
Martin Almquist <malmquist@stanford.edu>
parents: 914
diff changeset
270 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
271
942
35701c85e356 Make Utux2D work with new interface type etc.
Martin Almquist <malmquist@stanford.edu>
parents: 914
diff changeset
272 beta = int_damp_ds*obj.a{1}...
35701c85e356 Make Utux2D work with new interface type etc.
Martin Almquist <malmquist@stanford.edu>
parents: 914
diff changeset
273 *obj.e_w*obj.H_y;
35701c85e356 Make Utux2D work with new interface type etc.
Martin Almquist <malmquist@stanford.edu>
parents: 914
diff changeset
274 closure = closure + obj.Hi*beta*I_back_forth_ds*obj.e_w' - obj.Hi*beta*obj.e_w';
35701c85e356 Make Utux2D work with new interface type etc.
Martin Almquist <malmquist@stanford.edu>
parents: 914
diff changeset
275 case {'e','E','east','East'}
35701c85e356 Make Utux2D work with new interface type etc.
Martin Almquist <malmquist@stanford.edu>
parents: 914
diff changeset
276 tau = sigma_us*obj.a{1}*obj.e_e*obj.H_y;
35701c85e356 Make Utux2D work with new interface type etc.
Martin Almquist <malmquist@stanford.edu>
parents: 914
diff changeset
277 closure = obj.Hi*tau*obj.e_e';
35701c85e356 Make Utux2D work with new interface type etc.
Martin Almquist <malmquist@stanford.edu>
parents: 914
diff changeset
278 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
279
942
35701c85e356 Make Utux2D work with new interface type etc.
Martin Almquist <malmquist@stanford.edu>
parents: 914
diff changeset
280 beta = int_damp_us*obj.a{1}...
35701c85e356 Make Utux2D work with new interface type etc.
Martin Almquist <malmquist@stanford.edu>
parents: 914
diff changeset
281 *obj.e_e*obj.H_y;
35701c85e356 Make Utux2D work with new interface type etc.
Martin Almquist <malmquist@stanford.edu>
parents: 914
diff changeset
282 closure = closure + obj.Hi*beta*I_back_forth_us*obj.e_e' - obj.Hi*beta*obj.e_e';
35701c85e356 Make Utux2D work with new interface type etc.
Martin Almquist <malmquist@stanford.edu>
parents: 914
diff changeset
283 case {'s','S','south','South'}
35701c85e356 Make Utux2D work with new interface type etc.
Martin Almquist <malmquist@stanford.edu>
parents: 914
diff changeset
284 tau = sigma_ds*obj.a{2}*obj.e_s*obj.H_x;
35701c85e356 Make Utux2D work with new interface type etc.
Martin Almquist <malmquist@stanford.edu>
parents: 914
diff changeset
285 closure = obj.Hi*tau*obj.e_s';
35701c85e356 Make Utux2D work with new interface type etc.
Martin Almquist <malmquist@stanford.edu>
parents: 914
diff changeset
286 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
287
942
35701c85e356 Make Utux2D work with new interface type etc.
Martin Almquist <malmquist@stanford.edu>
parents: 914
diff changeset
288 beta = int_damp_ds*obj.a{2}...
35701c85e356 Make Utux2D work with new interface type etc.
Martin Almquist <malmquist@stanford.edu>
parents: 914
diff changeset
289 *obj.e_s*obj.H_x;
35701c85e356 Make Utux2D work with new interface type etc.
Martin Almquist <malmquist@stanford.edu>
parents: 914
diff changeset
290 closure = closure + obj.Hi*beta*I_back_forth_ds*obj.e_s' - obj.Hi*beta*obj.e_s';
35701c85e356 Make Utux2D work with new interface type etc.
Martin Almquist <malmquist@stanford.edu>
parents: 914
diff changeset
291 case {'n','N','north','North'}
35701c85e356 Make Utux2D work with new interface type etc.
Martin Almquist <malmquist@stanford.edu>
parents: 914
diff changeset
292 tau = sigma_us*obj.a{2}*obj.e_n*obj.H_x;
35701c85e356 Make Utux2D work with new interface type etc.
Martin Almquist <malmquist@stanford.edu>
parents: 914
diff changeset
293 closure = obj.Hi*tau*obj.e_n';
35701c85e356 Make Utux2D work with new interface type etc.
Martin Almquist <malmquist@stanford.edu>
parents: 914
diff changeset
294 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
295
942
35701c85e356 Make Utux2D work with new interface type etc.
Martin Almquist <malmquist@stanford.edu>
parents: 914
diff changeset
296 beta = int_damp_us*obj.a{2}...
35701c85e356 Make Utux2D work with new interface type etc.
Martin Almquist <malmquist@stanford.edu>
parents: 914
diff changeset
297 *obj.e_n*obj.H_x;
35701c85e356 Make Utux2D work with new interface type etc.
Martin Almquist <malmquist@stanford.edu>
parents: 914
diff changeset
298 closure = closure + obj.Hi*beta*I_back_forth_us*obj.e_n' - obj.Hi*beta*obj.e_n';
591
39554f2de783 Add Utux2D scheme
Martin Almquist <martin.almquist@it.uu.se>
parents:
diff changeset
299 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
300
459eeb99130f Include type as (optional) input parameter in the interface method of all schemes.
Martin Almquist <malmquist@stanford.edu>
parents: 743
diff changeset
301
591
39554f2de783 Add Utux2D scheme
Martin Almquist <martin.almquist@it.uu.se>
parents:
diff changeset
302 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
303
1197
433c89bf19e0 Merge with default
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents: 1036 1051
diff changeset
304 % Returns the boundary sign. The right boundary is considered the positive boundary
433c89bf19e0 Merge with default
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents: 1036 1051
diff changeset
305 % boundary -- string
433c89bf19e0 Merge with default
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents: 1036 1051
diff changeset
306 function s = getBoundarySign(obj, boundary)
433c89bf19e0 Merge with default
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents: 1036 1051
diff changeset
307 assertIsMember(boundary, {'w', 'e', 's', 'n'})
433c89bf19e0 Merge with default
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents: 1036 1051
diff changeset
308 switch boundary
433c89bf19e0 Merge with default
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents: 1036 1051
diff changeset
309 case {'e','n'}
433c89bf19e0 Merge with default
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents: 1036 1051
diff changeset
310 s = 1;
433c89bf19e0 Merge with default
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents: 1036 1051
diff changeset
311 case {'w','s'}
433c89bf19e0 Merge with default
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents: 1036 1051
diff changeset
312 s = -1;
433c89bf19e0 Merge with default
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents: 1036 1051
diff changeset
313 end
433c89bf19e0 Merge with default
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents: 1036 1051
diff changeset
314 end
433c89bf19e0 Merge with default
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents: 1036 1051
diff changeset
315
1048
adbb80e60b10 Clean up Elastic2dVariable (partially), Utux, and Utux2d.
Martin Almquist <malmquist@stanford.edu>
parents: 1044
diff changeset
316 % Returns the boundary operator op for the boundary specified by the string boundary.
adbb80e60b10 Clean up Elastic2dVariable (partially), Utux, and Utux2d.
Martin Almquist <malmquist@stanford.edu>
parents: 1044
diff changeset
317 % op -- string
997
78db023a7fe3 Add getBoundaryOperator method to all 2d schemes, except obsolete Wave2dCurve and ElastiCurve, which needs a big makeover.
Martin Almquist <malmquist@stanford.edu>
parents: 950
diff changeset
318 % boundary -- string
1048
adbb80e60b10 Clean up Elastic2dVariable (partially), Utux, and Utux2d.
Martin Almquist <malmquist@stanford.edu>
parents: 1044
diff changeset
319 function o = getBoundaryOperator(obj, op, boundary)
adbb80e60b10 Clean up Elastic2dVariable (partially), Utux, and Utux2d.
Martin Almquist <malmquist@stanford.edu>
parents: 1044
diff changeset
320 assertIsMember(op, {'e'})
1042
8d73fcdb07a5 Add asserts to boundary identifier inputs
Jonatan Werpers <jonatan@werpers.com>
parents: 997
diff changeset
321 assertIsMember(boundary, {'w', 'e', 's', 'n'})
997
78db023a7fe3 Add getBoundaryOperator method to all 2d schemes, except obsolete Wave2dCurve and ElastiCurve, which needs a big makeover.
Martin Almquist <malmquist@stanford.edu>
parents: 950
diff changeset
322
1048
adbb80e60b10 Clean up Elastic2dVariable (partially), Utux, and Utux2d.
Martin Almquist <malmquist@stanford.edu>
parents: 1044
diff changeset
323 o = obj.([op, '_', boundary]);
997
78db023a7fe3 Add getBoundaryOperator method to all 2d schemes, except obsolete Wave2dCurve and ElastiCurve, which needs a big makeover.
Martin Almquist <malmquist@stanford.edu>
parents: 950
diff changeset
324 end
78db023a7fe3 Add getBoundaryOperator method to all 2d schemes, except obsolete Wave2dCurve and ElastiCurve, which needs a big makeover.
Martin Almquist <malmquist@stanford.edu>
parents: 950
diff changeset
325
78db023a7fe3 Add getBoundaryOperator method to all 2d schemes, except obsolete Wave2dCurve and ElastiCurve, which needs a big makeover.
Martin Almquist <malmquist@stanford.edu>
parents: 950
diff changeset
326 % Returns square boundary quadrature matrix, of dimension
78db023a7fe3 Add getBoundaryOperator method to all 2d schemes, except obsolete Wave2dCurve and ElastiCurve, which needs a big makeover.
Martin Almquist <malmquist@stanford.edu>
parents: 950
diff changeset
327 % corresponding to the number of boundary points
78db023a7fe3 Add getBoundaryOperator method to all 2d schemes, except obsolete Wave2dCurve and ElastiCurve, which needs a big makeover.
Martin Almquist <malmquist@stanford.edu>
parents: 950
diff changeset
328 %
78db023a7fe3 Add getBoundaryOperator method to all 2d schemes, except obsolete Wave2dCurve and ElastiCurve, which needs a big makeover.
Martin Almquist <malmquist@stanford.edu>
parents: 950
diff changeset
329 % boundary -- string
78db023a7fe3 Add getBoundaryOperator method to all 2d schemes, except obsolete Wave2dCurve and ElastiCurve, which needs a big makeover.
Martin Almquist <malmquist@stanford.edu>
parents: 950
diff changeset
330 function H_b = getBoundaryQuadrature(obj, boundary)
1042
8d73fcdb07a5 Add asserts to boundary identifier inputs
Jonatan Werpers <jonatan@werpers.com>
parents: 997
diff changeset
331 assertIsMember(boundary, {'w', 'e', 's', 'n'})
997
78db023a7fe3 Add getBoundaryOperator method to all 2d schemes, except obsolete Wave2dCurve and ElastiCurve, which needs a big makeover.
Martin Almquist <malmquist@stanford.edu>
parents: 950
diff changeset
332
1051
84200bbae101 Bugfix: add missing brackets in getBoundaryQuadrature in LaplCurv and Utux2d
Martin Almquist <malmquist@stanford.edu>
parents: 1048
diff changeset
333 H_b = obj.(['H_', boundary]);
997
78db023a7fe3 Add getBoundaryOperator method to all 2d schemes, except obsolete Wave2dCurve and ElastiCurve, which needs a big makeover.
Martin Almquist <malmquist@stanford.edu>
parents: 950
diff changeset
334 end
78db023a7fe3 Add getBoundaryOperator method to all 2d schemes, except obsolete Wave2dCurve and ElastiCurve, which needs a big makeover.
Martin Almquist <malmquist@stanford.edu>
parents: 950
diff changeset
335
1197
433c89bf19e0 Merge with default
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents: 1036 1051
diff changeset
336 % Returns square boundary quadrature matrix, of dimension
433c89bf19e0 Merge with default
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents: 1036 1051
diff changeset
337 % corresponding to the number of boundary points
433c89bf19e0 Merge with default
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents: 1036 1051
diff changeset
338 %
433c89bf19e0 Merge with default
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents: 1036 1051
diff changeset
339 % boundary -- string
433c89bf19e0 Merge with default
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents: 1036 1051
diff changeset
340 function H_1d = getOneDirectionalNorm(obj, boundary)
433c89bf19e0 Merge with default
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents: 1036 1051
diff changeset
341 assertIsMember(boundary, {'w', 'e', 's', 'n'})
433c89bf19e0 Merge with default
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents: 1036 1051
diff changeset
342 switch boundary
433c89bf19e0 Merge with default
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents: 1036 1051
diff changeset
343 case {'w','e'}
433c89bf19e0 Merge with default
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents: 1036 1051
diff changeset
344 H_1d = obj.H_y;
433c89bf19e0 Merge with default
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents: 1036 1051
diff changeset
345 case {'s','n'}
433c89bf19e0 Merge with default
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents: 1036 1051
diff changeset
346 H_1d = obj.H_x;
433c89bf19e0 Merge with default
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents: 1036 1051
diff changeset
347 end
433c89bf19e0 Merge with default
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents: 1036 1051
diff changeset
348 end
433c89bf19e0 Merge with default
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents: 1036 1051
diff changeset
349
591
39554f2de783 Add Utux2D scheme
Martin Almquist <martin.almquist@it.uu.se>
parents:
diff changeset
350 function N = size(obj)
39554f2de783 Add Utux2D scheme
Martin Almquist <martin.almquist@it.uu.se>
parents:
diff changeset
351 N = obj.m;
39554f2de783 Add Utux2D scheme
Martin Almquist <martin.almquist@it.uu.se>
parents:
diff changeset
352 end
39554f2de783 Add Utux2D scheme
Martin Almquist <martin.almquist@it.uu.se>
parents:
diff changeset
353
39554f2de783 Add Utux2D scheme
Martin Almquist <martin.almquist@it.uu.se>
parents:
diff changeset
354 end
1043
c12b84fe9b00 Remove static method `interface_coupling` that shouldn't have existed in the first place
Jonatan Werpers <jonatan@werpers.com>
parents: 950
diff changeset
355 end