Mercurial > repos > public > sbplib
annotate +scheme/Burgers2d.m @ 1197:433c89bf19e0 feature/rv
Merge with default
author | Vidar Stiernström <vidar.stiernstrom@it.uu.se> |
---|---|
date | Wed, 07 Aug 2019 15:23:42 +0200 |
parents | 6cb03209f0a7 |
children |
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'); |
1197
433c89bf19e0
Merge with default
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents:
1189
diff
changeset
|
104 s = obj.getBoundarySign(boundary); |
433c89bf19e0
Merge with default
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents:
1189
diff
changeset
|
105 e = obj.getBoundaryOperator('e', boundary); |
433c89bf19e0
Merge with default
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents:
1189
diff
changeset
|
106 indices = obj.getBoundaryIndices(boundary); |
433c89bf19e0
Merge with default
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents:
1189
diff
changeset
|
107 H_1d = obj.getOneDirectionalNorm(boundary); |
1008
a6f34de60044
First attempt at implementing Burgers in 2D with RV-stabilization
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents:
diff
changeset
|
108 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
|
109 case {'D', 'd', 'dirichlet', 'Dirichlet'} |
1197
433c89bf19e0
Merge with default
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents:
1189
diff
changeset
|
110 penalty_parameter = 1/3; |
433c89bf19e0
Merge with default
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents:
1189
diff
changeset
|
111 Tau = s*penalty_parameter*obj.Hi*e*H_1d/2; |
433c89bf19e0
Merge with default
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents:
1189
diff
changeset
|
112 m = obj.grid.m; |
433c89bf19e0
Merge with default
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents:
1189
diff
changeset
|
113 tau = @(v) Tau*spdiags((v(indices)-s*abs(v(indices))),0,m(1),m(2)); |
433c89bf19e0
Merge with default
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents:
1189
diff
changeset
|
114 closure = @(v) Tau*((v(indices)-s*abs(v(indices))).*v(indices)); |
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 |
1197
433c89bf19e0
Merge with default
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents:
1189
diff
changeset
|
123 % 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:
1189
diff
changeset
|
124 % boundary -- string |
433c89bf19e0
Merge with default
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents:
1189
diff
changeset
|
125 function s = getBoundarySign(obj, boundary) |
433c89bf19e0
Merge with default
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents:
1189
diff
changeset
|
126 assertIsMember(boundary, {'w', 'e', 's', 'n'}) |
1008
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 |
1197
433c89bf19e0
Merge with default
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents:
1189
diff
changeset
|
128 case {'e','n'} |
433c89bf19e0
Merge with default
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents:
1189
diff
changeset
|
129 s = 1; |
433c89bf19e0
Merge with default
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents:
1189
diff
changeset
|
130 case {'w','s'} |
1008
a6f34de60044
First attempt at implementing Burgers in 2D with RV-stabilization
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents:
diff
changeset
|
131 s = -1; |
1197
433c89bf19e0
Merge with default
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents:
1189
diff
changeset
|
132 end |
433c89bf19e0
Merge with default
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents:
1189
diff
changeset
|
133 end |
433c89bf19e0
Merge with default
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents:
1189
diff
changeset
|
134 |
433c89bf19e0
Merge with default
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents:
1189
diff
changeset
|
135 % Returns the boundary operator op for the boundary specified by the string boundary. |
433c89bf19e0
Merge with default
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents:
1189
diff
changeset
|
136 % op -- string |
433c89bf19e0
Merge with default
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents:
1189
diff
changeset
|
137 % boundary -- string |
433c89bf19e0
Merge with default
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents:
1189
diff
changeset
|
138 function o = getBoundaryOperator(obj, op, boundary) |
433c89bf19e0
Merge with default
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents:
1189
diff
changeset
|
139 assertIsMember(op, {'e'}) |
433c89bf19e0
Merge with default
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents:
1189
diff
changeset
|
140 assertIsMember(boundary, {'w', 'e', 's', 'n'}) |
433c89bf19e0
Merge with default
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents:
1189
diff
changeset
|
141 |
433c89bf19e0
Merge with default
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents:
1189
diff
changeset
|
142 o = obj.([op, '_', boundary]); |
433c89bf19e0
Merge with default
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents:
1189
diff
changeset
|
143 end |
433c89bf19e0
Merge with default
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents:
1189
diff
changeset
|
144 |
433c89bf19e0
Merge with default
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents:
1189
diff
changeset
|
145 % Returns square boundary quadrature matrix, of dimension |
433c89bf19e0
Merge with default
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents:
1189
diff
changeset
|
146 % corresponding to the number of boundary points |
433c89bf19e0
Merge with default
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents:
1189
diff
changeset
|
147 % |
433c89bf19e0
Merge with default
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents:
1189
diff
changeset
|
148 % boundary -- string |
433c89bf19e0
Merge with default
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents:
1189
diff
changeset
|
149 function H_b = getBoundaryQuadrature(obj, boundary) |
433c89bf19e0
Merge with default
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents:
1189
diff
changeset
|
150 assertIsMember(boundary, {'w', 'e', 's', 'n'}) |
433c89bf19e0
Merge with default
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents:
1189
diff
changeset
|
151 H_b = obj.(['H_', boundary]); |
433c89bf19e0
Merge with default
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents:
1189
diff
changeset
|
152 end |
433c89bf19e0
Merge with default
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents:
1189
diff
changeset
|
153 |
433c89bf19e0
Merge with default
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents:
1189
diff
changeset
|
154 % Returns square boundary quadrature matrix, of dimension |
433c89bf19e0
Merge with default
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents:
1189
diff
changeset
|
155 % corresponding to the number of boundary points |
433c89bf19e0
Merge with default
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents:
1189
diff
changeset
|
156 % |
433c89bf19e0
Merge with default
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents:
1189
diff
changeset
|
157 % boundary -- string |
433c89bf19e0
Merge with default
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents:
1189
diff
changeset
|
158 function H_1d = getOneDirectionalNorm(obj, boundary) |
433c89bf19e0
Merge with default
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents:
1189
diff
changeset
|
159 assertIsMember(boundary, {'w', 'e', 's', 'n'}) |
433c89bf19e0
Merge with default
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents:
1189
diff
changeset
|
160 switch boundary |
433c89bf19e0
Merge with default
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents:
1189
diff
changeset
|
161 case {'w','e'} |
433c89bf19e0
Merge with default
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents:
1189
diff
changeset
|
162 H_1d = obj.H_y; |
433c89bf19e0
Merge with default
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents:
1189
diff
changeset
|
163 case {'s','n'} |
433c89bf19e0
Merge with default
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents:
1189
diff
changeset
|
164 H_1d = obj.H_x; |
433c89bf19e0
Merge with default
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents:
1189
diff
changeset
|
165 end |
433c89bf19e0
Merge with default
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents:
1189
diff
changeset
|
166 end |
433c89bf19e0
Merge with default
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents:
1189
diff
changeset
|
167 |
433c89bf19e0
Merge with default
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents:
1189
diff
changeset
|
168 % Returns the indices of the boundary points in the grid matrix |
433c89bf19e0
Merge with default
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents:
1189
diff
changeset
|
169 % boundary -- string |
433c89bf19e0
Merge with default
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents:
1189
diff
changeset
|
170 function I = getBoundaryIndices(obj, boundary) |
433c89bf19e0
Merge with default
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents:
1189
diff
changeset
|
171 assertIsMember(boundary, {'w', 'e', 's', 'n'}) |
433c89bf19e0
Merge with default
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents:
1189
diff
changeset
|
172 |
433c89bf19e0
Merge with default
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents:
1189
diff
changeset
|
173 ind = grid.funcToMatrix(obj.grid, 1:prod(obj.grid.m)); |
433c89bf19e0
Merge with default
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents:
1189
diff
changeset
|
174 switch boundary |
433c89bf19e0
Merge with default
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents:
1189
diff
changeset
|
175 case 'w' |
433c89bf19e0
Merge with default
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents:
1189
diff
changeset
|
176 I = ind(1,:); |
433c89bf19e0
Merge with default
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents:
1189
diff
changeset
|
177 case 'e' |
433c89bf19e0
Merge with default
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents:
1189
diff
changeset
|
178 I = ind(end,:); |
433c89bf19e0
Merge with default
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents:
1189
diff
changeset
|
179 case 's' |
433c89bf19e0
Merge with default
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents:
1189
diff
changeset
|
180 I = ind(:,1)'; |
433c89bf19e0
Merge with default
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents:
1189
diff
changeset
|
181 case 'n' |
433c89bf19e0
Merge with default
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents:
1189
diff
changeset
|
182 I = 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
|
183 end |
a6f34de60044
First attempt at implementing Burgers in 2D with RV-stabilization
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents:
diff
changeset
|
184 end |
a6f34de60044
First attempt at implementing Burgers in 2D with RV-stabilization
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents:
diff
changeset
|
185 |
a6f34de60044
First attempt at implementing Burgers in 2D with RV-stabilization
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents:
diff
changeset
|
186 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
|
187 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
|
188 end |
a6f34de60044
First attempt at implementing Burgers in 2D with RV-stabilization
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents:
diff
changeset
|
189 |
a6f34de60044
First attempt at implementing Burgers in 2D with RV-stabilization
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents:
diff
changeset
|
190 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
|
191 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
|
192 end |
a6f34de60044
First attempt at implementing Burgers in 2D with RV-stabilization
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents:
diff
changeset
|
193 end |
a6f34de60044
First attempt at implementing Burgers in 2D with RV-stabilization
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents:
diff
changeset
|
194 end |