Mercurial > repos > public > sbplib
annotate +rv/constructDiffOps.m @ 1156:8c0e2b50f018 feature/rv
Attempt to fix oscilations when not using bdfs by adding lower-order 2nd derivative correction term to the Residual
author | Vidar Stiernström <vidar.stiernstrom@it.uu.se> |
---|---|
date | Tue, 25 Jun 2019 13:06:42 +0200 |
parents | 3108963cc42c |
children |
rev | line source |
---|---|
1156
8c0e2b50f018
Attempt to fix oscilations when not using bdfs by adding lower-order 2nd derivative correction term to the Residual
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents:
1154
diff
changeset
|
1 function [D_rv, D_flux, DvDt, solutionPenalties, residualPenalties] = constructDiffOps(scheme, g, schemeOrder, residualOrder, schemeParams, opSet, BCs) |
1020
5359a61cb4d9
Add utility for constructing the operators used by a discretization emplying RV-stabilization
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents:
diff
changeset
|
2 %% DiffOps for solution vector |
1156
8c0e2b50f018
Attempt to fix oscilations when not using bdfs by adding lower-order 2nd derivative correction term to the Residual
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents:
1154
diff
changeset
|
3 [D, solutionPenalties] = constructFluxDiffOp(scheme, g, schemeOrder, schemeParams, opSet, BCs); |
8c0e2b50f018
Attempt to fix oscilations when not using bdfs by adding lower-order 2nd derivative correction term to the Residual
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents:
1154
diff
changeset
|
4 D2 = constructSymmetricD2Operator(g, schemeOrder, opSet); |
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:
1146
diff
changeset
|
5 D_rv = @(v,Viscosity)(D(v) + D2(Viscosity)*v); |
1020
5359a61cb4d9
Add utility for constructing the operators used by a discretization emplying RV-stabilization
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents:
diff
changeset
|
6 |
5359a61cb4d9
Add utility for constructing the operators used by a discretization emplying RV-stabilization
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents:
diff
changeset
|
7 %% DiffOps for residual viscosity |
1156
8c0e2b50f018
Attempt to fix oscilations when not using bdfs by adding lower-order 2nd derivative correction term to the Residual
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents:
1154
diff
changeset
|
8 [D_flux, residualPenalties] = constructFluxDiffOp(scheme, g, residualOrder, schemeParams, opSet, BCs); |
8c0e2b50f018
Attempt to fix oscilations when not using bdfs by adding lower-order 2nd derivative correction term to the Residual
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents:
1154
diff
changeset
|
9 % TODO: Construct D_flux without closures when using bdfs. |
8c0e2b50f018
Attempt to fix oscilations when not using bdfs by adding lower-order 2nd derivative correction term to the Residual
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents:
1154
diff
changeset
|
10 % diffOp = scheme(g, residualOrder, schemeParams{:}, opSet); |
8c0e2b50f018
Attempt to fix oscilations when not using bdfs by adding lower-order 2nd derivative correction term to the Residual
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents:
1154
diff
changeset
|
11 % if ~isa(diffOp.D, 'function_handle') |
8c0e2b50f018
Attempt to fix oscilations when not using bdfs by adding lower-order 2nd derivative correction term to the Residual
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents:
1154
diff
changeset
|
12 % D_flux = @(v) diffOp.D*v; |
8c0e2b50f018
Attempt to fix oscilations when not using bdfs by adding lower-order 2nd derivative correction term to the Residual
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents:
1154
diff
changeset
|
13 % else |
8c0e2b50f018
Attempt to fix oscilations when not using bdfs by adding lower-order 2nd derivative correction term to the Residual
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents:
1154
diff
changeset
|
14 % D_flux = diffOp.D; |
8c0e2b50f018
Attempt to fix oscilations when not using bdfs by adding lower-order 2nd derivative correction term to the Residual
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents:
1154
diff
changeset
|
15 % end |
8c0e2b50f018
Attempt to fix oscilations when not using bdfs by adding lower-order 2nd derivative correction term to the Residual
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents:
1154
diff
changeset
|
16 |
8c0e2b50f018
Attempt to fix oscilations when not using bdfs by adding lower-order 2nd derivative correction term to the Residual
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents:
1154
diff
changeset
|
17 % DiffOp for flux in residual viscosity. Due to sign conventions of the implemented schemes, we need to |
1020
5359a61cb4d9
Add utility for constructing the operators used by a discretization emplying RV-stabilization
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents:
diff
changeset
|
18 % change the sign. |
1037
2d7ba44340d0
Pass scheme specific parameters as cell array. This will enabale constructDiffOps to be more general. In addition, allow for schemes returning function handles as diffOps, which is currently how non-linear schemes such as Burgers1d are implemented.
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents:
1026
diff
changeset
|
19 D_flux = @(v) -D_flux(v); |
1156
8c0e2b50f018
Attempt to fix oscilations when not using bdfs by adding lower-order 2nd derivative correction term to the Residual
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents:
1154
diff
changeset
|
20 lim = {g.x{1}(1), g.x{1}(end)}; |
8c0e2b50f018
Attempt to fix oscilations when not using bdfs by adding lower-order 2nd derivative correction term to the Residual
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents:
1154
diff
changeset
|
21 o = 2; |
8c0e2b50f018
Attempt to fix oscilations when not using bdfs by adding lower-order 2nd derivative correction term to the Residual
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents:
1154
diff
changeset
|
22 h = g.scaling(); |
8c0e2b50f018
Attempt to fix oscilations when not using bdfs by adding lower-order 2nd derivative correction term to the Residual
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents:
1154
diff
changeset
|
23 gam = 1; |
8c0e2b50f018
Attempt to fix oscilations when not using bdfs by adding lower-order 2nd derivative correction term to the Residual
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents:
1154
diff
changeset
|
24 if isequal(opSet,@sbp.D1Upwind) |
8c0e2b50f018
Attempt to fix oscilations when not using bdfs by adding lower-order 2nd derivative correction term to the Residual
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents:
1154
diff
changeset
|
25 ops = sbp.D1Upwind(g.m(), lim, o); |
8c0e2b50f018
Attempt to fix oscilations when not using bdfs by adding lower-order 2nd derivative correction term to the Residual
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents:
1154
diff
changeset
|
26 Hi = ops.HI; |
8c0e2b50f018
Attempt to fix oscilations when not using bdfs by adding lower-order 2nd derivative correction term to the Residual
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents:
1154
diff
changeset
|
27 e_r = ops.e_r; |
8c0e2b50f018
Attempt to fix oscilations when not using bdfs by adding lower-order 2nd derivative correction term to the Residual
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents:
1154
diff
changeset
|
28 e_l = ops.e_l; |
8c0e2b50f018
Attempt to fix oscilations when not using bdfs by adding lower-order 2nd derivative correction term to the Residual
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents:
1154
diff
changeset
|
29 B = e_r*e_r' - e_l*e_l'; |
8c0e2b50f018
Attempt to fix oscilations when not using bdfs by adding lower-order 2nd derivative correction term to the Residual
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents:
1154
diff
changeset
|
30 M = ops.Dm - Hi*B; |
8c0e2b50f018
Attempt to fix oscilations when not using bdfs by adding lower-order 2nd derivative correction term to the Residual
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents:
1154
diff
changeset
|
31 D2 = M*ops.Dp; |
8c0e2b50f018
Attempt to fix oscilations when not using bdfs by adding lower-order 2nd derivative correction term to the Residual
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents:
1154
diff
changeset
|
32 else |
8c0e2b50f018
Attempt to fix oscilations when not using bdfs by adding lower-order 2nd derivative correction term to the Residual
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents:
1154
diff
changeset
|
33 ops = sbp.D2Standard(g.m(), lim, o); |
8c0e2b50f018
Attempt to fix oscilations when not using bdfs by adding lower-order 2nd derivative correction term to the Residual
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents:
1154
diff
changeset
|
34 D2 = ops.D2; |
8c0e2b50f018
Attempt to fix oscilations when not using bdfs by adding lower-order 2nd derivative correction term to the Residual
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents:
1154
diff
changeset
|
35 end |
8c0e2b50f018
Attempt to fix oscilations when not using bdfs by adding lower-order 2nd derivative correction term to the Residual
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents:
1154
diff
changeset
|
36 D2_low = gam*h^(residualOrder)*D2; |
8c0e2b50f018
Attempt to fix oscilations when not using bdfs by adding lower-order 2nd derivative correction term to the Residual
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents:
1154
diff
changeset
|
37 D2_low = @(v) D2_low*v; |
1020
5359a61cb4d9
Add utility for constructing the operators used by a discretization emplying RV-stabilization
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents:
diff
changeset
|
38 % DiffOp for time derivative in residual viscosity |
1156
8c0e2b50f018
Attempt to fix oscilations when not using bdfs by adding lower-order 2nd derivative correction term to the Residual
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents:
1154
diff
changeset
|
39 DvDt = @(v) D(v)+D2_low(v); |
8c0e2b50f018
Attempt to fix oscilations when not using bdfs by adding lower-order 2nd derivative correction term to the Residual
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents:
1154
diff
changeset
|
40 %DvDt = @(v) D(v); |
1020
5359a61cb4d9
Add utility for constructing the operators used by a discretization emplying RV-stabilization
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents:
diff
changeset
|
41 end |
5359a61cb4d9
Add utility for constructing the operators used by a discretization emplying RV-stabilization
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents:
diff
changeset
|
42 |
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:
1146
diff
changeset
|
43 function [D, penalties] = constructFluxDiffOp(scheme, g, order, schemeParams, opSet, BCs) |
1037
2d7ba44340d0
Pass scheme specific parameters as cell array. This will enabale constructDiffOps to be more general. In addition, allow for schemes returning function handles as diffOps, which is currently how non-linear schemes such as Burgers1d are implemented.
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents:
1026
diff
changeset
|
44 diffOp = scheme(g, order, schemeParams{:}, opSet); |
1020
5359a61cb4d9
Add utility for constructing the operators used by a discretization emplying RV-stabilization
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents:
diff
changeset
|
45 [D, penalties] = addClosuresToDiffOp(diffOp, BCs); |
5359a61cb4d9
Add utility for constructing the operators used by a discretization emplying RV-stabilization
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents:
diff
changeset
|
46 end |
5359a61cb4d9
Add utility for constructing the operators used by a discretization emplying RV-stabilization
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents:
diff
changeset
|
47 |
5359a61cb4d9
Add utility for constructing the operators used by a discretization emplying RV-stabilization
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents:
diff
changeset
|
48 function [D, penalties] = addClosuresToDiffOp(diffOp, BCs) |
1037
2d7ba44340d0
Pass scheme specific parameters as cell array. This will enabale constructDiffOps to be more general. In addition, allow for schemes returning function handles as diffOps, which is currently how non-linear schemes such as Burgers1d are implemented.
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents:
1026
diff
changeset
|
49 if ~isa(diffOp.D, 'function_handle') |
1146
52f59d27b40f
Add missing semicolon
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents:
1037
diff
changeset
|
50 D = @(v) diffOp.D*v; |
1037
2d7ba44340d0
Pass scheme specific parameters as cell array. This will enabale constructDiffOps to be more general. In addition, allow for schemes returning function handles as diffOps, which is currently how non-linear schemes such as Burgers1d are implemented.
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents:
1026
diff
changeset
|
51 else |
2d7ba44340d0
Pass scheme specific parameters as cell array. This will enabale constructDiffOps to be more general. In addition, allow for schemes returning function handles as diffOps, which is currently how non-linear schemes such as Burgers1d are implemented.
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents:
1026
diff
changeset
|
52 D = diffOp.D; |
2d7ba44340d0
Pass scheme specific parameters as cell array. This will enabale constructDiffOps to be more general. In addition, allow for schemes returning function handles as diffOps, which is currently how non-linear schemes such as Burgers1d are implemented.
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents:
1026
diff
changeset
|
53 end |
1020
5359a61cb4d9
Add utility for constructing the operators used by a discretization emplying RV-stabilization
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents:
diff
changeset
|
54 penalties = cell(size(BCs)); |
5359a61cb4d9
Add utility for constructing the operators used by a discretization emplying RV-stabilization
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents:
diff
changeset
|
55 for i = 1:size(BCs,1) |
5359a61cb4d9
Add utility for constructing the operators used by a discretization emplying RV-stabilization
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents:
diff
changeset
|
56 for j = 1:size(BCs,2) |
5359a61cb4d9
Add utility for constructing the operators used by a discretization emplying RV-stabilization
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents:
diff
changeset
|
57 [closure, penalties{i,j}] = diffOp.boundary_condition(BCs{i,j}.boundary, BCs{i,j}.type); |
1037
2d7ba44340d0
Pass scheme specific parameters as cell array. This will enabale constructDiffOps to be more general. In addition, allow for schemes returning function handles as diffOps, which is currently how non-linear schemes such as Burgers1d are implemented.
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents:
1026
diff
changeset
|
58 if ~isa(closure, 'function_handle') |
2d7ba44340d0
Pass scheme specific parameters as cell array. This will enabale constructDiffOps to be more general. In addition, allow for schemes returning function handles as diffOps, which is currently how non-linear schemes such as Burgers1d are implemented.
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents:
1026
diff
changeset
|
59 closure = @(v) closure*v; |
2d7ba44340d0
Pass scheme specific parameters as cell array. This will enabale constructDiffOps to be more general. In addition, allow for schemes returning function handles as diffOps, which is currently how non-linear schemes such as Burgers1d are implemented.
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents:
1026
diff
changeset
|
60 end |
2d7ba44340d0
Pass scheme specific parameters as cell array. This will enabale constructDiffOps to be more general. In addition, allow for schemes returning function handles as diffOps, which is currently how non-linear schemes such as Burgers1d are implemented.
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents:
1026
diff
changeset
|
61 D = @(v) D(v) + closure(v); |
1020
5359a61cb4d9
Add utility for constructing the operators used by a discretization emplying RV-stabilization
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents:
diff
changeset
|
62 end |
5359a61cb4d9
Add utility for constructing the operators used by a discretization emplying RV-stabilization
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents:
diff
changeset
|
63 end |
5359a61cb4d9
Add utility for constructing the operators used by a discretization emplying RV-stabilization
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents:
diff
changeset
|
64 end |
5359a61cb4d9
Add utility for constructing the operators used by a discretization emplying RV-stabilization
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents:
diff
changeset
|
65 |
1037
2d7ba44340d0
Pass scheme specific parameters as cell array. This will enabale constructDiffOps to be more general. In addition, allow for schemes returning function handles as diffOps, which is currently how non-linear schemes such as Burgers1d are implemented.
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents:
1026
diff
changeset
|
66 function D2 = constructSymmetricD2Operator(g, order, opSet) |
2d7ba44340d0
Pass scheme specific parameters as cell array. This will enabale constructDiffOps to be more general. In addition, allow for schemes returning function handles as diffOps, which is currently how non-linear schemes such as Burgers1d are implemented.
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents:
1026
diff
changeset
|
67 m = g.size(); |
2d7ba44340d0
Pass scheme specific parameters as cell array. This will enabale constructDiffOps to be more general. In addition, allow for schemes returning function handles as diffOps, which is currently how non-linear schemes such as Burgers1d are implemented.
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents:
1026
diff
changeset
|
68 ops = cell(g.D(),1); |
2d7ba44340d0
Pass scheme specific parameters as cell array. This will enabale constructDiffOps to be more general. In addition, allow for schemes returning function handles as diffOps, which is currently how non-linear schemes such as Burgers1d are implemented.
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents:
1026
diff
changeset
|
69 I = cell(g.D(),1); |
2d7ba44340d0
Pass scheme specific parameters as cell array. This will enabale constructDiffOps to be more general. In addition, allow for schemes returning function handles as diffOps, which is currently how non-linear schemes such as Burgers1d are implemented.
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents:
1026
diff
changeset
|
70 for i = 1:g.D() |
2d7ba44340d0
Pass scheme specific parameters as cell array. This will enabale constructDiffOps to be more general. In addition, allow for schemes returning function handles as diffOps, which is currently how non-linear schemes such as Burgers1d are implemented.
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents:
1026
diff
changeset
|
71 lim = {g.x{i}(1), g.x{i}(end)}; |
1020
5359a61cb4d9
Add utility for constructing the operators used by a discretization emplying RV-stabilization
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents:
diff
changeset
|
72 ops{i} = opSet(m(i), lim, order); |
5359a61cb4d9
Add utility for constructing the operators used by a discretization emplying RV-stabilization
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents:
diff
changeset
|
73 I{i} = speye(m(i)); |
5359a61cb4d9
Add utility for constructing the operators used by a discretization emplying RV-stabilization
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents:
diff
changeset
|
74 end |
5359a61cb4d9
Add utility for constructing the operators used by a discretization emplying RV-stabilization
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents:
diff
changeset
|
75 |
1037
2d7ba44340d0
Pass scheme specific parameters as cell array. This will enabale constructDiffOps to be more general. In addition, allow for schemes returning function handles as diffOps, which is currently how non-linear schemes such as Burgers1d are implemented.
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents:
1026
diff
changeset
|
76 switch g.D() |
1020
5359a61cb4d9
Add utility for constructing the operators used by a discretization emplying RV-stabilization
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents:
diff
changeset
|
77 case 1 |
5359a61cb4d9
Add utility for constructing the operators used by a discretization emplying RV-stabilization
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents:
diff
changeset
|
78 e_r = ops{1}.e_r; |
5359a61cb4d9
Add utility for constructing the operators used by a discretization emplying RV-stabilization
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents:
diff
changeset
|
79 e_l = ops{1}.e_l; |
5359a61cb4d9
Add utility for constructing the operators used by a discretization emplying RV-stabilization
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents:
diff
changeset
|
80 Hi = ops{1}.HI; |
5359a61cb4d9
Add utility for constructing the operators used by a discretization emplying RV-stabilization
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents:
diff
changeset
|
81 B = e_r*e_r' - e_l*e_l'; |
1037
2d7ba44340d0
Pass scheme specific parameters as cell array. This will enabale constructDiffOps to be more general. In addition, allow for schemes returning function handles as diffOps, which is currently how non-linear schemes such as Burgers1d are implemented.
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents:
1026
diff
changeset
|
82 if isequal(opSet,@sbp.D1Upwind) |
2d7ba44340d0
Pass scheme specific parameters as cell array. This will enabale constructDiffOps to be more general. In addition, allow for schemes returning function handles as diffOps, which is currently how non-linear schemes such as Burgers1d are implemented.
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents:
1026
diff
changeset
|
83 Dm = ops{1}.Dm; |
2d7ba44340d0
Pass scheme specific parameters as cell array. This will enabale constructDiffOps to be more general. In addition, allow for schemes returning function handles as diffOps, which is currently how non-linear schemes such as Burgers1d are implemented.
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents:
1026
diff
changeset
|
84 Dp = ops{1}.Dp; |
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:
1146
diff
changeset
|
85 M = Dm - Hi*B; |
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:
1146
diff
changeset
|
86 D2 = @(Viscosity) M*Viscosity*Dp; |
1037
2d7ba44340d0
Pass scheme specific parameters as cell array. This will enabale constructDiffOps to be more general. In addition, allow for schemes returning function handles as diffOps, which is currently how non-linear schemes such as Burgers1d are implemented.
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents:
1026
diff
changeset
|
87 else |
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:
1146
diff
changeset
|
88 % TODO: Fix closure for D2Variable |
1156
8c0e2b50f018
Attempt to fix oscilations when not using bdfs by adding lower-order 2nd derivative correction term to the Residual
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents:
1154
diff
changeset
|
89 % TODO: Fix Viscosity not being vector |
8c0e2b50f018
Attempt to fix oscilations when not using bdfs by adding lower-order 2nd derivative correction term to the Residual
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents:
1154
diff
changeset
|
90 D2 = @(Viscosity)ops{1}.D2(diag(Viscosity)); |
1037
2d7ba44340d0
Pass scheme specific parameters as cell array. This will enabale constructDiffOps to be more general. In addition, allow for schemes returning function handles as diffOps, which is currently how non-linear schemes such as Burgers1d are implemented.
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents:
1026
diff
changeset
|
91 end |
1020
5359a61cb4d9
Add utility for constructing the operators used by a discretization emplying RV-stabilization
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents:
diff
changeset
|
92 case 2 |
1037
2d7ba44340d0
Pass scheme specific parameters as cell array. This will enabale constructDiffOps to be more general. In addition, allow for schemes returning function handles as diffOps, which is currently how non-linear schemes such as Burgers1d are implemented.
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents:
1026
diff
changeset
|
93 % TODO: |
2d7ba44340d0
Pass scheme specific parameters as cell array. This will enabale constructDiffOps to be more general. In addition, allow for schemes returning function handles as diffOps, which is currently how non-linear schemes such as Burgers1d are implemented.
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents:
1026
diff
changeset
|
94 % Currently only implemented for upwind operators. |
2d7ba44340d0
Pass scheme specific parameters as cell array. This will enabale constructDiffOps to be more general. In addition, allow for schemes returning function handles as diffOps, which is currently how non-linear schemes such as Burgers1d are implemented.
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents:
1026
diff
changeset
|
95 % Remove this part once the time-dependent D2 operator is implemented for other opSets |
2d7ba44340d0
Pass scheme specific parameters as cell array. This will enabale constructDiffOps to be more general. In addition, allow for schemes returning function handles as diffOps, which is currently how non-linear schemes such as Burgers1d are implemented.
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents:
1026
diff
changeset
|
96 % or if it is decided that it should only be supported for upwind operators. |
2d7ba44340d0
Pass scheme specific parameters as cell array. This will enabale constructDiffOps to be more general. In addition, allow for schemes returning function handles as diffOps, which is currently how non-linear schemes such as Burgers1d are implemented.
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents:
1026
diff
changeset
|
97 assert(isequal(opSet,@sbp.D1Upwind)) |
1020
5359a61cb4d9
Add utility for constructing the operators used by a discretization emplying RV-stabilization
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents:
diff
changeset
|
98 e_e = kron(ops{1}.e_r,I{2}); |
5359a61cb4d9
Add utility for constructing the operators used by a discretization emplying RV-stabilization
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents:
diff
changeset
|
99 e_w = kron(ops{1}.e_l,I{2}); |
5359a61cb4d9
Add utility for constructing the operators used by a discretization emplying RV-stabilization
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents:
diff
changeset
|
100 Dm_x = kron(ops{1}.Dm,I{2}); |
5359a61cb4d9
Add utility for constructing the operators used by a discretization emplying RV-stabilization
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents:
diff
changeset
|
101 Dp_x = kron(ops{1}.Dp,I{2}); |
5359a61cb4d9
Add utility for constructing the operators used by a discretization emplying RV-stabilization
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents:
diff
changeset
|
102 H_x = kron(ops{1}.HI,I{2}); |
5359a61cb4d9
Add utility for constructing the operators used by a discretization emplying RV-stabilization
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents:
diff
changeset
|
103 B_x = e_e*e_e' - e_w*e_w'; |
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:
1146
diff
changeset
|
104 M_x = Dm_x-H_x*B_x; |
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:
1146
diff
changeset
|
105 D2_x = @(Viscosity) M_x*Viscosity*Dp_x; |
1020
5359a61cb4d9
Add utility for constructing the operators used by a discretization emplying RV-stabilization
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents:
diff
changeset
|
106 |
5359a61cb4d9
Add utility for constructing the operators used by a discretization emplying RV-stabilization
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents:
diff
changeset
|
107 e_n = kron(I{1},ops{2}.e_r); |
5359a61cb4d9
Add utility for constructing the operators used by a discretization emplying RV-stabilization
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents:
diff
changeset
|
108 e_s = kron(I{1},ops{2}.e_l); |
5359a61cb4d9
Add utility for constructing the operators used by a discretization emplying RV-stabilization
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents:
diff
changeset
|
109 Dm_y = kron(I{1},ops{2}.Dm); |
5359a61cb4d9
Add utility for constructing the operators used by a discretization emplying RV-stabilization
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents:
diff
changeset
|
110 Dp_y = kron(I{1},ops{2}.Dp); |
5359a61cb4d9
Add utility for constructing the operators used by a discretization emplying RV-stabilization
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents:
diff
changeset
|
111 H_y = kron(I{1},ops{2}.HI); |
5359a61cb4d9
Add utility for constructing the operators used by a discretization emplying RV-stabilization
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents:
diff
changeset
|
112 B_y = e_n*e_n' - e_s*e_s'; |
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:
1146
diff
changeset
|
113 M_y = Dm_y-H_y*B_y; |
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:
1146
diff
changeset
|
114 D2_y = @(Viscosity) M_y*Viscosity*Dp_y; |
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:
1146
diff
changeset
|
115 D2 = @(Viscosity) D2_x(Viscosity) + D2_y(Viscosity); |
1020
5359a61cb4d9
Add utility for constructing the operators used by a discretization emplying RV-stabilization
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents:
diff
changeset
|
116 otherwise |
5359a61cb4d9
Add utility for constructing the operators used by a discretization emplying RV-stabilization
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents:
diff
changeset
|
117 error('3D not yet implemented') |
5359a61cb4d9
Add utility for constructing the operators used by a discretization emplying RV-stabilization
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents:
diff
changeset
|
118 end |
5359a61cb4d9
Add utility for constructing the operators used by a discretization emplying RV-stabilization
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents:
diff
changeset
|
119 end |