annotate +scheme/Burgers2d.m @ 1192:b3c47a716d57 feature/rv

Fix indentation
author Vidar Stiernström <vidar.stiernstrom@it.uu.se>
date Mon, 29 Jul 2019 16:43:39 +0200
parents 6cb03209f0a7
children 433c89bf19e0
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);
1154
3108963cc42c Improve efficiency of diffOps in Burgers2d, the artificial diffusion operator in rv.constructDiffOps and the RungekuttaExteriorRv time-steppers
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents: 1149
diff changeset
50 DissOpx = kron((ops_x.Dp - ops_x.Dm)/2,Iy);
3108963cc42c Improve efficiency of diffOps in Burgers2d, the artificial diffusion operator in rv.constructDiffOps and the RungekuttaExteriorRv time-steppers
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents: 1149
diff changeset
51 DissOpy = kron(Ix,(ops_y.Dp - ops_y.Dm)/2);
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
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'
1155
336ee37a0617 Change penalty term and add missing semicolon
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents: 1154
diff changeset
55 D = -1/3*D1;
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
56 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
57 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
58 DissOp = DissOpx + DissOpy;
1154
3108963cc42c Improve efficiency of diffOps in Burgers2d, the artificial diffusion operator in rv.constructDiffOps and the RungekuttaExteriorRv time-steppers
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents: 1149
diff changeset
59 obj.D = @(v) D*(v.*v) + (spdiags(v,0,m_tot,m_tot)*D + fluxSplitting{1}(v)*DissOp)*v;
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
60 case 2
1154
3108963cc42c Improve efficiency of diffOps in Burgers2d, the artificial diffusion operator in rv.constructDiffOps and the RungekuttaExteriorRv time-steppers
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents: 1149
diff changeset
61 obj.D = @(v) D*(v.*v) + (spdiags(v,0,m_tot,m_tot)*D + fluxSplitting{1}(v)*DissOpx + fluxSplitting{2}(v)*DissOpy)*v;
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
62 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
63 case 'conservative'
1154
3108963cc42c Improve efficiency of diffOps in Burgers2d, the artificial diffusion operator in rv.constructDiffOps and the RungekuttaExteriorRv time-steppers
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents: 1149
diff changeset
64 D = -1/2*D1;
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
65 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
66 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
67 DissOp = DissOpx + DissOpy;
1154
3108963cc42c Improve efficiency of diffOps in Burgers2d, the artificial diffusion operator in rv.constructDiffOps and the RungekuttaExteriorRv time-steppers
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents: 1149
diff changeset
68 % TODO: Check if we can use fluxSplitting{1} here instead
3108963cc42c Improve efficiency of diffOps in Burgers2d, the artificial diffusion operator in rv.constructDiffOps and the RungekuttaExteriorRv time-steppers
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents: 1149
diff changeset
69 obj.D = @(v) D*(v.*v) + max(abs(v))*DissOp*v;
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
70 case 2
1154
3108963cc42c Improve efficiency of diffOps in Burgers2d, the artificial diffusion operator in rv.constructDiffOps and the RungekuttaExteriorRv time-steppers
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents: 1149
diff changeset
71 obj.D = @(v) D*(v.*v) + (fluxSplitting{1}(v)*DissOpx + fluxSplitting{2}(v)*DissOpy)*v;
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
72 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
73
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 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
75 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
76 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
77 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
78 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
79 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
80 case 'skew-symmetric'
1189
6cb03209f0a7 Add missing semicolon
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents: 1155
diff changeset
81 D = -1/3*D1;
1154
3108963cc42c Improve efficiency of diffOps in Burgers2d, the artificial diffusion operator in rv.constructDiffOps and the RungekuttaExteriorRv time-steppers
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents: 1149
diff changeset
82 obj.D = @(v) D*(v.*v) + spdiags(v,0,m_tot,m_tot)*D*v;
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
83 case 'conservative'
1154
3108963cc42c Improve efficiency of diffOps in Burgers2d, the artificial diffusion operator in rv.constructDiffOps and the RungekuttaExteriorRv time-steppers
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents: 1149
diff changeset
84 D = -1/2*D1;
3108963cc42c Improve efficiency of diffOps in Burgers2d, the artificial diffusion operator in rv.constructDiffOps and the RungekuttaExteriorRv time-steppers
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents: 1149
diff changeset
85 obj.D = @(v) D*(v.*v);
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
86 end
1008
a6f34de60044 First attempt at implementing Burgers in 2D with RV-stabilization
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents:
diff changeset
87 end
a6f34de60044 First attempt at implementing Burgers in 2D with RV-stabilization
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents:
diff changeset
88
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
89 % 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
90 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
91 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
92 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
93 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
94
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
95 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
96 end
a6f34de60044 First attempt at implementing Burgers in 2D with RV-stabilization
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents:
diff changeset
97
a6f34de60044 First attempt at implementing Burgers in 2D with RV-stabilization
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents:
diff changeset
98 % 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
99 % 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
100 % 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
101 % 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
102 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
103 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
104 [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
105 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
106 % 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
107 % 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
108 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
109
1155
336ee37a0617 Change penalty term and add missing semicolon
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents: 1154
diff changeset
110 magnitude = 1/3;
1154
3108963cc42c Improve efficiency of diffOps in Burgers2d, the artificial diffusion operator in rv.constructDiffOps and the RungekuttaExteriorRv time-steppers
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents: 1149
diff changeset
111 Tau = s*magnitude*obj.Hi*e*H_b/2;
3108963cc42c Improve efficiency of diffOps in Burgers2d, the artificial diffusion operator in rv.constructDiffOps and the RungekuttaExteriorRv time-steppers
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents: 1149
diff changeset
112 m = length(index);
3108963cc42c Improve efficiency of diffOps in Burgers2d, the artificial diffusion operator in rv.constructDiffOps and the RungekuttaExteriorRv time-steppers
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents: 1149
diff changeset
113 tau = @(v) Tau*spdiags((v(index)-s*abs(v(index))),0,m,m);
3108963cc42c Improve efficiency of diffOps in Burgers2d, the artificial diffusion operator in rv.constructDiffOps and the RungekuttaExteriorRv time-steppers
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents: 1149
diff changeset
114 closure = @(v) Tau*((v(index)-s*abs(v(index))).*v(index));
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
115 penalty = @(v) -tau(v);
1008
a6f34de60044 First attempt at implementing Burgers in 2D with RV-stabilization
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents:
diff changeset
116 otherwise
a6f34de60044 First attempt at implementing Burgers in 2D with RV-stabilization
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents:
diff changeset
117 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
118 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
119
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
120
1008
a6f34de60044 First attempt at implementing Burgers in 2D with RV-stabilization
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents:
diff changeset
121 end
a6f34de60044 First attempt at implementing Burgers in 2D with RV-stabilization
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents:
diff changeset
122
a6f34de60044 First attempt at implementing Burgers in 2D with RV-stabilization
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents:
diff changeset
123 % 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
124 % 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
125 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
126 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
127 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
128 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
129 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
130 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
131 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
132 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
133 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
134 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
135 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
136 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
137 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
138 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
139 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
140 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
141 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
142 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
143 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
144 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
145 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
146 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
147 s = 1;
a6f34de60044 First attempt at implementing Burgers in 2D with RV-stabilization
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents:
diff changeset
148 otherwise
a6f34de60044 First attempt at implementing Burgers in 2D with RV-stabilization
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents:
diff changeset
149 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
150 end
a6f34de60044 First attempt at implementing Burgers in 2D with RV-stabilization
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents:
diff changeset
151 end
a6f34de60044 First attempt at implementing Burgers in 2D with RV-stabilization
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents:
diff changeset
152
a6f34de60044 First attempt at implementing Burgers in 2D with RV-stabilization
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents:
diff changeset
153 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
154 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
155 end
a6f34de60044 First attempt at implementing Burgers in 2D with RV-stabilization
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents:
diff changeset
156
a6f34de60044 First attempt at implementing Burgers in 2D with RV-stabilization
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents:
diff changeset
157 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
158 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
159 end
a6f34de60044 First attempt at implementing Burgers in 2D with RV-stabilization
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents:
diff changeset
160 end
a6f34de60044 First attempt at implementing Burgers in 2D with RV-stabilization
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents:
diff changeset
161 end