annotate +scheme/Burgers2d.m @ 1149:1fe48cbd379a feature/rv

Change Burgers2d to inviscid formulation. Rewrite to use opSets and fix the implementation of the Dirichlet conditions.
author Vidar Stiernström <vidar.stiernstrom@it.uu.se>
date Thu, 24 Jan 2019 09:05:44 +0100
parents c322a9454d75
children 3108963cc42c 0c906f7ab8bf
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
1149
1fe48cbd379a Change Burgers2d to inviscid formulation. Rewrite to use opSets and fix the implementation of the Dirichlet conditions.
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents: 1147
diff changeset
1 classdef Burgers2d < scheme.Scheme
1008
a6f34de60044 First attempt at implementing Burgers in 2D with RV-stabilization
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents:
diff changeset
2 properties
a6f34de60044 First attempt at implementing Burgers in 2D with RV-stabilization
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents:
diff changeset
3 grid % Physical grid
a6f34de60044 First attempt at implementing Burgers in 2D with RV-stabilization
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents:
diff changeset
4 order % Order accuracy for the approximation
a6f34de60044 First attempt at implementing Burgers in 2D with RV-stabilization
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents:
diff changeset
5
a6f34de60044 First attempt at implementing Burgers in 2D with RV-stabilization
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents:
diff changeset
6 D % Non-stabilized scheme operator
a6f34de60044 First attempt at implementing Burgers in 2D with RV-stabilization
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents:
diff changeset
7 H % Discrete norm
1149
1fe48cbd379a Change Burgers2d to inviscid formulation. Rewrite to use opSets and fix the implementation of the Dirichlet conditions.
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents: 1147
diff changeset
8 H_x, H_y % Norms in the x and y directions
1fe48cbd379a Change Burgers2d to inviscid formulation. Rewrite to use opSets and fix the implementation of the Dirichlet conditions.
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents: 1147
diff changeset
9 Hi % Kroneckered norm inverse
1fe48cbd379a Change Burgers2d to inviscid formulation. Rewrite to use opSets and fix the implementation of the Dirichlet conditions.
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents: 1147
diff changeset
10 % Boundary operators
1fe48cbd379a Change Burgers2d to inviscid formulation. Rewrite to use opSets and fix the implementation of the Dirichlet conditions.
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents: 1147
diff changeset
11 e_w, e_e, e_s, e_n
1008
a6f34de60044 First attempt at implementing Burgers in 2D with RV-stabilization
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents:
diff changeset
12 end
a6f34de60044 First attempt at implementing Burgers in 2D with RV-stabilization
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents:
diff changeset
13
a6f34de60044 First attempt at implementing Burgers in 2D with RV-stabilization
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents:
diff changeset
14 methods
1149
1fe48cbd379a Change Burgers2d to inviscid formulation. Rewrite to use opSets and fix the implementation of the Dirichlet conditions.
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents: 1147
diff changeset
15 function obj = Burgers2d(g, order, pde_form, fluxSplitting, opSet)
1fe48cbd379a Change Burgers2d to inviscid formulation. Rewrite to use opSets and fix the implementation of the Dirichlet conditions.
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents: 1147
diff changeset
16 default_arg('opSet',@sbp.D2Standard);
1fe48cbd379a Change Burgers2d to inviscid formulation. Rewrite to use opSets and fix the implementation of the Dirichlet conditions.
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents: 1147
diff changeset
17 default_arg('fluxSplitting',{@(v)max(abs(v)),@(v)max(abs(v))});
1fe48cbd379a Change Burgers2d to inviscid formulation. Rewrite to use opSets and fix the implementation of the Dirichlet conditions.
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents: 1147
diff changeset
18 assertType(g, 'grid.Cartesian');
1fe48cbd379a Change Burgers2d to inviscid formulation. Rewrite to use opSets and fix the implementation of the Dirichlet conditions.
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents: 1147
diff changeset
19
1fe48cbd379a Change Burgers2d to inviscid formulation. Rewrite to use opSets and fix the implementation of the Dirichlet conditions.
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents: 1147
diff changeset
20 m = g.size();
1fe48cbd379a Change Burgers2d to inviscid formulation. Rewrite to use opSets and fix the implementation of the Dirichlet conditions.
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents: 1147
diff changeset
21 m_x = m(1);
1fe48cbd379a Change Burgers2d to inviscid formulation. Rewrite to use opSets and fix the implementation of the Dirichlet conditions.
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents: 1147
diff changeset
22 m_y = m(2);
1fe48cbd379a Change Burgers2d to inviscid formulation. Rewrite to use opSets and fix the implementation of the Dirichlet conditions.
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents: 1147
diff changeset
23 m_tot = g.N();
1fe48cbd379a Change Burgers2d to inviscid formulation. Rewrite to use opSets and fix the implementation of the Dirichlet conditions.
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents: 1147
diff changeset
24
1fe48cbd379a Change Burgers2d to inviscid formulation. Rewrite to use opSets and fix the implementation of the Dirichlet conditions.
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents: 1147
diff changeset
25 xlim = {g.x{1}(1), g.x{1}(end)};
1fe48cbd379a Change Burgers2d to inviscid formulation. Rewrite to use opSets and fix the implementation of the Dirichlet conditions.
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents: 1147
diff changeset
26 ylim = {g.x{2}(1), g.x{2}(end)};
1fe48cbd379a Change Burgers2d to inviscid formulation. Rewrite to use opSets and fix the implementation of the Dirichlet conditions.
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents: 1147
diff changeset
27 obj.grid = g;
1fe48cbd379a Change Burgers2d to inviscid formulation. Rewrite to use opSets and fix the implementation of the Dirichlet conditions.
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents: 1147
diff changeset
28
1fe48cbd379a Change Burgers2d to inviscid formulation. Rewrite to use opSets and fix the implementation of the Dirichlet conditions.
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents: 1147
diff changeset
29 % Operator sets
1fe48cbd379a Change Burgers2d to inviscid formulation. Rewrite to use opSets and fix the implementation of the Dirichlet conditions.
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents: 1147
diff changeset
30 ops_x = opSet(m_x, xlim, order);
1fe48cbd379a Change Burgers2d to inviscid formulation. Rewrite to use opSets and fix the implementation of the Dirichlet conditions.
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents: 1147
diff changeset
31 ops_y = opSet(m_y, ylim, order);
1fe48cbd379a Change Burgers2d to inviscid formulation. Rewrite to use opSets and fix the implementation of the Dirichlet conditions.
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents: 1147
diff changeset
32 Ix = speye(m_x);
1fe48cbd379a Change Burgers2d to inviscid formulation. Rewrite to use opSets and fix the implementation of the Dirichlet conditions.
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents: 1147
diff changeset
33 Iy = speye(m_y);
1fe48cbd379a Change Burgers2d to inviscid formulation. Rewrite to use opSets and fix the implementation of the Dirichlet conditions.
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents: 1147
diff changeset
34
1fe48cbd379a Change Burgers2d to inviscid formulation. Rewrite to use opSets and fix the implementation of the Dirichlet conditions.
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents: 1147
diff changeset
35 % Norms
1fe48cbd379a Change Burgers2d to inviscid formulation. Rewrite to use opSets and fix the implementation of the Dirichlet conditions.
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents: 1147
diff changeset
36 Hx = ops_x.H;
1fe48cbd379a Change Burgers2d to inviscid formulation. Rewrite to use opSets and fix the implementation of the Dirichlet conditions.
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents: 1147
diff changeset
37 Hy = ops_y.H;
1fe48cbd379a Change Burgers2d to inviscid formulation. Rewrite to use opSets and fix the implementation of the Dirichlet conditions.
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents: 1147
diff changeset
38 Hxi = ops_x.HI;
1fe48cbd379a Change Burgers2d to inviscid formulation. Rewrite to use opSets and fix the implementation of the Dirichlet conditions.
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents: 1147
diff changeset
39 Hyi = ops_y.HI;
1fe48cbd379a Change Burgers2d to inviscid formulation. Rewrite to use opSets and fix the implementation of the Dirichlet conditions.
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents: 1147
diff changeset
40
1fe48cbd379a Change Burgers2d to inviscid formulation. Rewrite to use opSets and fix the implementation of the Dirichlet conditions.
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents: 1147
diff changeset
41 obj.H_x = Hx;
1fe48cbd379a Change Burgers2d to inviscid formulation. Rewrite to use opSets and fix the implementation of the Dirichlet conditions.
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents: 1147
diff changeset
42 obj.H_y = Hy;
1fe48cbd379a Change Burgers2d to inviscid formulation. Rewrite to use opSets and fix the implementation of the Dirichlet conditions.
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents: 1147
diff changeset
43 obj.H = kron(Hx,Hy);
1fe48cbd379a Change Burgers2d to inviscid formulation. Rewrite to use opSets and fix the implementation of the Dirichlet conditions.
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents: 1147
diff changeset
44 obj.Hi = kron(Hxi,Hyi);
1fe48cbd379a Change Burgers2d to inviscid formulation. Rewrite to use opSets and fix the implementation of the Dirichlet conditions.
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents: 1147
diff changeset
45
1fe48cbd379a Change Burgers2d to inviscid formulation. Rewrite to use opSets and fix the implementation of the Dirichlet conditions.
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents: 1147
diff changeset
46 % Derivatives
1fe48cbd379a Change Burgers2d to inviscid formulation. Rewrite to use opSets and fix the implementation of the Dirichlet conditions.
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents: 1147
diff changeset
47 if (isequal(opSet,@sbp.D1Upwind))
1fe48cbd379a Change Burgers2d to inviscid formulation. Rewrite to use opSets and fix the implementation of the Dirichlet conditions.
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents: 1147
diff changeset
48 Dx = kron((ops_x.Dp + ops_x.Dm)/2,Iy);
1fe48cbd379a Change Burgers2d to inviscid formulation. Rewrite to use opSets and fix the implementation of the Dirichlet conditions.
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents: 1147
diff changeset
49 Dy = kron(Ix,(ops_y.Dp + ops_y.Dm)/2);
1fe48cbd379a Change Burgers2d to inviscid formulation. Rewrite to use opSets and fix the implementation of the Dirichlet conditions.
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents: 1147
diff changeset
50 DissOpx = kron((ops_x.Dm - ops_x.Dp)/2,Iy);
1fe48cbd379a Change Burgers2d to inviscid formulation. Rewrite to use opSets and fix the implementation of the Dirichlet conditions.
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents: 1147
diff changeset
51 DissOpy = kron(Ix,(ops_y.Dm - ops_y.Dp)/2);
1fe48cbd379a Change Burgers2d to inviscid formulation. Rewrite to use opSets and fix the implementation of the Dirichlet conditions.
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents: 1147
diff changeset
52 D1 = Dx + Dy;
1fe48cbd379a Change Burgers2d to inviscid formulation. Rewrite to use opSets and fix the implementation of the Dirichlet conditions.
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents: 1147
diff changeset
53 switch pde_form
1fe48cbd379a Change Burgers2d to inviscid formulation. Rewrite to use opSets and fix the implementation of the Dirichlet conditions.
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents: 1147
diff changeset
54 case 'skew-symmetric'
1fe48cbd379a Change Burgers2d to inviscid formulation. Rewrite to use opSets and fix the implementation of the Dirichlet conditions.
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents: 1147
diff changeset
55 switch length(fluxSplitting)
1fe48cbd379a Change Burgers2d to inviscid formulation. Rewrite to use opSets and fix the implementation of the Dirichlet conditions.
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents: 1147
diff changeset
56 case 1
1fe48cbd379a Change Burgers2d to inviscid formulation. Rewrite to use opSets and fix the implementation of the Dirichlet conditions.
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents: 1147
diff changeset
57 DissOp = DissOpx + DissOpy;
1fe48cbd379a Change Burgers2d to inviscid formulation. Rewrite to use opSets and fix the implementation of the Dirichlet conditions.
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents: 1147
diff changeset
58 obj.D = @(v) -(1/3*D1*v.*v + (1/3*spdiag(v)*D1 + fluxSplitting{1}(v)*DissOp)*v);
1fe48cbd379a Change Burgers2d to inviscid formulation. Rewrite to use opSets and fix the implementation of the Dirichlet conditions.
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents: 1147
diff changeset
59 case 2
1fe48cbd379a Change Burgers2d to inviscid formulation. Rewrite to use opSets and fix the implementation of the Dirichlet conditions.
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents: 1147
diff changeset
60 obj.D = @(v) -(1/3*D1*v.*v + (1/3*spdiag(v)*D1 + fluxSplitting{1}(v)*DissOpx + fluxSplitting{2}(v)*DissOpy)*v);
1fe48cbd379a Change Burgers2d to inviscid formulation. Rewrite to use opSets and fix the implementation of the Dirichlet conditions.
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents: 1147
diff changeset
61 end
1fe48cbd379a Change Burgers2d to inviscid formulation. Rewrite to use opSets and fix the implementation of the Dirichlet conditions.
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents: 1147
diff changeset
62 case 'conservative'
1fe48cbd379a Change Burgers2d to inviscid formulation. Rewrite to use opSets and fix the implementation of the Dirichlet conditions.
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents: 1147
diff changeset
63 switch length(fluxSplitting)
1fe48cbd379a Change Burgers2d to inviscid formulation. Rewrite to use opSets and fix the implementation of the Dirichlet conditions.
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents: 1147
diff changeset
64 case 1
1fe48cbd379a Change Burgers2d to inviscid formulation. Rewrite to use opSets and fix the implementation of the Dirichlet conditions.
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents: 1147
diff changeset
65 DissOp = DissOpx + DissOpy;
1fe48cbd379a Change Burgers2d to inviscid formulation. Rewrite to use opSets and fix the implementation of the Dirichlet conditions.
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents: 1147
diff changeset
66 obj.D = @(v) -(1/2*D1*v.*v + fluxSplitting{1}(v)*DissOp*v);
1fe48cbd379a Change Burgers2d to inviscid formulation. Rewrite to use opSets and fix the implementation of the Dirichlet conditions.
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents: 1147
diff changeset
67 case 2
1fe48cbd379a Change Burgers2d to inviscid formulation. Rewrite to use opSets and fix the implementation of the Dirichlet conditions.
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents: 1147
diff changeset
68 obj.D = @(v) -(1/2*D1*v.*v + (fluxSplitting{1}(v)*DissOpx + fluxSplitting{2}(v)*DissOpy)*v);
1fe48cbd379a Change Burgers2d to inviscid formulation. Rewrite to use opSets and fix the implementation of the Dirichlet conditions.
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents: 1147
diff changeset
69 end
1fe48cbd379a Change Burgers2d to inviscid formulation. Rewrite to use opSets and fix the implementation of the Dirichlet conditions.
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents: 1147
diff changeset
70
1fe48cbd379a Change Burgers2d to inviscid formulation. Rewrite to use opSets and fix the implementation of the Dirichlet conditions.
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents: 1147
diff changeset
71 end
1fe48cbd379a Change Burgers2d to inviscid formulation. Rewrite to use opSets and fix the implementation of the Dirichlet conditions.
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents: 1147
diff changeset
72 else
1fe48cbd379a Change Burgers2d to inviscid formulation. Rewrite to use opSets and fix the implementation of the Dirichlet conditions.
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents: 1147
diff changeset
73 Dx = kron(ops_x.D1,Iy);
1fe48cbd379a Change Burgers2d to inviscid formulation. Rewrite to use opSets and fix the implementation of the Dirichlet conditions.
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents: 1147
diff changeset
74 Dy = kron(Ix,ops_y.D1);
1fe48cbd379a Change Burgers2d to inviscid formulation. Rewrite to use opSets and fix the implementation of the Dirichlet conditions.
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents: 1147
diff changeset
75 D1 = Dx + Dy;
1fe48cbd379a Change Burgers2d to inviscid formulation. Rewrite to use opSets and fix the implementation of the Dirichlet conditions.
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents: 1147
diff changeset
76 switch pde_form
1fe48cbd379a Change Burgers2d to inviscid formulation. Rewrite to use opSets and fix the implementation of the Dirichlet conditions.
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents: 1147
diff changeset
77 case 'skew-symmetric'
1fe48cbd379a Change Burgers2d to inviscid formulation. Rewrite to use opSets and fix the implementation of the Dirichlet conditions.
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents: 1147
diff changeset
78 obj.D = @(v) -(1/3*D1*v.*v + 1/3*spdiag(v)*D1*v);
1fe48cbd379a Change Burgers2d to inviscid formulation. Rewrite to use opSets and fix the implementation of the Dirichlet conditions.
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents: 1147
diff changeset
79 case 'conservative'
1fe48cbd379a Change Burgers2d to inviscid formulation. Rewrite to use opSets and fix the implementation of the Dirichlet conditions.
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents: 1147
diff changeset
80 obj.D = @(v) -1/2*D1*v.*v;
1fe48cbd379a Change Burgers2d to inviscid formulation. Rewrite to use opSets and fix the implementation of the Dirichlet conditions.
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents: 1147
diff changeset
81 end
1008
a6f34de60044 First attempt at implementing Burgers in 2D with RV-stabilization
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents:
diff changeset
82 end
a6f34de60044 First attempt at implementing Burgers in 2D with RV-stabilization
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents:
diff changeset
83
1149
1fe48cbd379a Change Burgers2d to inviscid formulation. Rewrite to use opSets and fix the implementation of the Dirichlet conditions.
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents: 1147
diff changeset
84 % Boundary operators
1fe48cbd379a Change Burgers2d to inviscid formulation. Rewrite to use opSets and fix the implementation of the Dirichlet conditions.
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents: 1147
diff changeset
85 obj.e_w = kr(ops_x.e_l, Iy);
1fe48cbd379a Change Burgers2d to inviscid formulation. Rewrite to use opSets and fix the implementation of the Dirichlet conditions.
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents: 1147
diff changeset
86 obj.e_e = kr(ops_x.e_r, Iy);
1fe48cbd379a Change Burgers2d to inviscid formulation. Rewrite to use opSets and fix the implementation of the Dirichlet conditions.
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents: 1147
diff changeset
87 obj.e_s = kr(Ix, ops_y.e_l);
1fe48cbd379a Change Burgers2d to inviscid formulation. Rewrite to use opSets and fix the implementation of the Dirichlet conditions.
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents: 1147
diff changeset
88 obj.e_n = kr(Ix, ops_y.e_r);
1008
a6f34de60044 First attempt at implementing Burgers in 2D with RV-stabilization
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents:
diff changeset
89
1149
1fe48cbd379a Change Burgers2d to inviscid formulation. Rewrite to use opSets and fix the implementation of the Dirichlet conditions.
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents: 1147
diff changeset
90 obj.order = order;
1008
a6f34de60044 First attempt at implementing Burgers in 2D with RV-stabilization
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents:
diff changeset
91 end
a6f34de60044 First attempt at implementing Burgers in 2D with RV-stabilization
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents:
diff changeset
92
a6f34de60044 First attempt at implementing Burgers in 2D with RV-stabilization
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents:
diff changeset
93 % Closure functions return the operators applied to the own doamin to close the boundary
a6f34de60044 First attempt at implementing Burgers in 2D with RV-stabilization
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents:
diff changeset
94 % Penalty functions return the operators to force the solution. In the case of an interface it returns the operator applied to the other domain.
a6f34de60044 First attempt at implementing Burgers in 2D with RV-stabilization
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents:
diff changeset
95 % boundary is a string specifying the boundary e.g. 'l','r' or 'e','w','n','s'.
a6f34de60044 First attempt at implementing Burgers in 2D with RV-stabilization
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents:
diff changeset
96 % type is a string specifying the type of boundary condition if there are several.
1149
1fe48cbd379a Change Burgers2d to inviscid formulation. Rewrite to use opSets and fix the implementation of the Dirichlet conditions.
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents: 1147
diff changeset
97 function [closure, penalty] = boundary_condition(obj,boundary,type)
1fe48cbd379a Change Burgers2d to inviscid formulation. Rewrite to use opSets and fix the implementation of the Dirichlet conditions.
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents: 1147
diff changeset
98 default_arg('type','dirichlet');
1fe48cbd379a Change Burgers2d to inviscid formulation. Rewrite to use opSets and fix the implementation of the Dirichlet conditions.
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents: 1147
diff changeset
99 [e, H_b, index, s] = obj.get_boundary_ops(boundary);
1008
a6f34de60044 First attempt at implementing Burgers in 2D with RV-stabilization
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents:
diff changeset
100 switch type
1149
1fe48cbd379a Change Burgers2d to inviscid formulation. Rewrite to use opSets and fix the implementation of the Dirichlet conditions.
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents: 1147
diff changeset
101 % Stable dirchlet-like boundary conditions (u+-abs(u))*u/3
1fe48cbd379a Change Burgers2d to inviscid formulation. Rewrite to use opSets and fix the implementation of the Dirichlet conditions.
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents: 1147
diff changeset
102 % with +- at left/right boundaries in each coordinate direction
1fe48cbd379a Change Burgers2d to inviscid formulation. Rewrite to use opSets and fix the implementation of the Dirichlet conditions.
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents: 1147
diff changeset
103 case {'D', 'd', 'dirichlet', 'Dirichlet'}
1fe48cbd379a Change Burgers2d to inviscid formulation. Rewrite to use opSets and fix the implementation of the Dirichlet conditions.
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents: 1147
diff changeset
104
1fe48cbd379a Change Burgers2d to inviscid formulation. Rewrite to use opSets and fix the implementation of the Dirichlet conditions.
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents: 1147
diff changeset
105 magnitude = 2/3;
1fe48cbd379a Change Burgers2d to inviscid formulation. Rewrite to use opSets and fix the implementation of the Dirichlet conditions.
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents: 1147
diff changeset
106 tau = @(v) s*magnitude*obj.Hi*e*H_b*spdiag((v(index)-s*abs(v(index)))/2);
1fe48cbd379a Change Burgers2d to inviscid formulation. Rewrite to use opSets and fix the implementation of the Dirichlet conditions.
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents: 1147
diff changeset
107 closure = @(v) tau(v)*v(index);
1fe48cbd379a Change Burgers2d to inviscid formulation. Rewrite to use opSets and fix the implementation of the Dirichlet conditions.
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents: 1147
diff changeset
108 penalty = @(v) -tau(v);
1fe48cbd379a Change Burgers2d to inviscid formulation. Rewrite to use opSets and fix the implementation of the Dirichlet conditions.
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents: 1147
diff changeset
109
1fe48cbd379a Change Burgers2d to inviscid formulation. Rewrite to use opSets and fix the implementation of the Dirichlet conditions.
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents: 1147
diff changeset
110
1fe48cbd379a Change Burgers2d to inviscid formulation. Rewrite to use opSets and fix the implementation of the Dirichlet conditions.
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents: 1147
diff changeset
111 % tau = s*e*H_b;
1fe48cbd379a Change Burgers2d to inviscid formulation. Rewrite to use opSets and fix the implementation of the Dirichlet conditions.
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents: 1147
diff changeset
112 % closure = @(v) (obj.Hi*tau)*(((v(index)-s*abs(v(index)))/3).*v(index));
1fe48cbd379a Change Burgers2d to inviscid formulation. Rewrite to use opSets and fix the implementation of the Dirichlet conditions.
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents: 1147
diff changeset
113 % penalty = -obj.Hi*tau;
1008
a6f34de60044 First attempt at implementing Burgers in 2D with RV-stabilization
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents:
diff changeset
114 otherwise
a6f34de60044 First attempt at implementing Burgers in 2D with RV-stabilization
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents:
diff changeset
115 error('No such boundary condition: type = %s',type);
a6f34de60044 First attempt at implementing Burgers in 2D with RV-stabilization
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents:
diff changeset
116 end
1149
1fe48cbd379a Change Burgers2d to inviscid formulation. Rewrite to use opSets and fix the implementation of the Dirichlet conditions.
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents: 1147
diff changeset
117
1fe48cbd379a Change Burgers2d to inviscid formulation. Rewrite to use opSets and fix the implementation of the Dirichlet conditions.
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents: 1147
diff changeset
118
1008
a6f34de60044 First attempt at implementing Burgers in 2D with RV-stabilization
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents:
diff changeset
119 end
a6f34de60044 First attempt at implementing Burgers in 2D with RV-stabilization
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents:
diff changeset
120
a6f34de60044 First attempt at implementing Burgers in 2D with RV-stabilization
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents:
diff changeset
121 % Ruturns the boundary ops, half-norm, boundary indices and sign for the boundary specified by the string boundary.
a6f34de60044 First attempt at implementing Burgers in 2D with RV-stabilization
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents:
diff changeset
122 % The right boundary for each coordinate direction is considered the positive boundary
1149
1fe48cbd379a Change Burgers2d to inviscid formulation. Rewrite to use opSets and fix the implementation of the Dirichlet conditions.
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents: 1147
diff changeset
123 function [e, H_b, index, s] = get_boundary_ops(obj, boundary)
1008
a6f34de60044 First attempt at implementing Burgers in 2D with RV-stabilization
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents:
diff changeset
124 ind = grid.funcToMatrix(obj.grid, 1:obj.grid.N());
a6f34de60044 First attempt at implementing Burgers in 2D with RV-stabilization
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents:
diff changeset
125 switch boundary
1149
1fe48cbd379a Change Burgers2d to inviscid formulation. Rewrite to use opSets and fix the implementation of the Dirichlet conditions.
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents: 1147
diff changeset
126 case {'w', 'W', 'west', 'West'}
1fe48cbd379a Change Burgers2d to inviscid formulation. Rewrite to use opSets and fix the implementation of the Dirichlet conditions.
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents: 1147
diff changeset
127 e = obj.e_w;
1fe48cbd379a Change Burgers2d to inviscid formulation. Rewrite to use opSets and fix the implementation of the Dirichlet conditions.
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents: 1147
diff changeset
128 H_b = obj.H_y;
1fe48cbd379a Change Burgers2d to inviscid formulation. Rewrite to use opSets and fix the implementation of the Dirichlet conditions.
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents: 1147
diff changeset
129 index = ind(1,:);
1008
a6f34de60044 First attempt at implementing Burgers in 2D with RV-stabilization
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents:
diff changeset
130 s = -1;
1149
1fe48cbd379a Change Burgers2d to inviscid formulation. Rewrite to use opSets and fix the implementation of the Dirichlet conditions.
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents: 1147
diff changeset
131 case {'e', 'E', 'east', 'East'}
1fe48cbd379a Change Burgers2d to inviscid formulation. Rewrite to use opSets and fix the implementation of the Dirichlet conditions.
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents: 1147
diff changeset
132 e = obj.e_e;
1fe48cbd379a Change Burgers2d to inviscid formulation. Rewrite to use opSets and fix the implementation of the Dirichlet conditions.
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents: 1147
diff changeset
133 H_b = obj.H_y;
1fe48cbd379a Change Burgers2d to inviscid formulation. Rewrite to use opSets and fix the implementation of the Dirichlet conditions.
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents: 1147
diff changeset
134 index = ind(end,:);
1008
a6f34de60044 First attempt at implementing Burgers in 2D with RV-stabilization
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents:
diff changeset
135 s = 1;
1149
1fe48cbd379a Change Burgers2d to inviscid formulation. Rewrite to use opSets and fix the implementation of the Dirichlet conditions.
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents: 1147
diff changeset
136 case {'s', 'S', 'south', 'South'}
1fe48cbd379a Change Burgers2d to inviscid formulation. Rewrite to use opSets and fix the implementation of the Dirichlet conditions.
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents: 1147
diff changeset
137 e = obj.e_s;
1fe48cbd379a Change Burgers2d to inviscid formulation. Rewrite to use opSets and fix the implementation of the Dirichlet conditions.
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents: 1147
diff changeset
138 H_b = obj.H_x;
1fe48cbd379a Change Burgers2d to inviscid formulation. Rewrite to use opSets and fix the implementation of the Dirichlet conditions.
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents: 1147
diff changeset
139 index = ind(:,1);
1008
a6f34de60044 First attempt at implementing Burgers in 2D with RV-stabilization
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents:
diff changeset
140 s = -1;
1149
1fe48cbd379a Change Burgers2d to inviscid formulation. Rewrite to use opSets and fix the implementation of the Dirichlet conditions.
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents: 1147
diff changeset
141 case {'n', 'N', 'north', 'North'}
1fe48cbd379a Change Burgers2d to inviscid formulation. Rewrite to use opSets and fix the implementation of the Dirichlet conditions.
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents: 1147
diff changeset
142 e = obj.e_n;
1fe48cbd379a Change Burgers2d to inviscid formulation. Rewrite to use opSets and fix the implementation of the Dirichlet conditions.
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents: 1147
diff changeset
143 H_b = obj.H_x;
1fe48cbd379a Change Burgers2d to inviscid formulation. Rewrite to use opSets and fix the implementation of the Dirichlet conditions.
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents: 1147
diff changeset
144 index = ind(:,end);
1008
a6f34de60044 First attempt at implementing Burgers in 2D with RV-stabilization
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents:
diff changeset
145 s = 1;
a6f34de60044 First attempt at implementing Burgers in 2D with RV-stabilization
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents:
diff changeset
146 otherwise
a6f34de60044 First attempt at implementing Burgers in 2D with RV-stabilization
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents:
diff changeset
147 error('No such boundary: boundary = %s',boundary);
a6f34de60044 First attempt at implementing Burgers in 2D with RV-stabilization
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents:
diff changeset
148 end
a6f34de60044 First attempt at implementing Burgers in 2D with RV-stabilization
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents:
diff changeset
149 end
a6f34de60044 First attempt at implementing Burgers in 2D with RV-stabilization
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents:
diff changeset
150
a6f34de60044 First attempt at implementing Burgers in 2D with RV-stabilization
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents:
diff changeset
151 function [closure, penalty] = interface(obj,boundary,neighbour_scheme,neighbour_boundary)
a6f34de60044 First attempt at implementing Burgers in 2D with RV-stabilization
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents:
diff changeset
152 error('An interface function does not exist yet');
a6f34de60044 First attempt at implementing Burgers in 2D with RV-stabilization
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents:
diff changeset
153 end
a6f34de60044 First attempt at implementing Burgers in 2D with RV-stabilization
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents:
diff changeset
154
a6f34de60044 First attempt at implementing Burgers in 2D with RV-stabilization
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents:
diff changeset
155 function N = size(obj)
a6f34de60044 First attempt at implementing Burgers in 2D with RV-stabilization
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents:
diff changeset
156 N = obj.grid.m;
a6f34de60044 First attempt at implementing Burgers in 2D with RV-stabilization
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents:
diff changeset
157 end
a6f34de60044 First attempt at implementing Burgers in 2D with RV-stabilization
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents:
diff changeset
158 end
a6f34de60044 First attempt at implementing Burgers in 2D with RV-stabilization
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents:
diff changeset
159 end