Mercurial > repos > public > sbplib
annotate +sbp/D1Gauss.m @ 1031:2ef20d00b386 feature/advectionRV
For easier comparison, return both the first order and residual viscosity when evaluating the residual. Add the first order and residual viscosity to the state of the RungekuttaRV time steppers
author | Vidar Stiernström <vidar.stiernstrom@it.uu.se> |
---|---|
date | Thu, 17 Jan 2019 10:25:06 +0100 |
parents | e1d11b6a68d8 |
children |
rev | line source |
---|---|
405
4d9d8064e58b
Implementation of D1 based on Gauss quadrature formula with 4 nodes.
Martin Almquist <martin.almquist@it.uu.se>
parents:
diff
changeset
|
1 classdef D1Gauss < sbp.OpSet |
4d9d8064e58b
Implementation of D1 based on Gauss quadrature formula with 4 nodes.
Martin Almquist <martin.almquist@it.uu.se>
parents:
diff
changeset
|
2 % Diagonal-norm SBP operators based on the Gauss quadrature formula |
4d9d8064e58b
Implementation of D1 based on Gauss quadrature formula with 4 nodes.
Martin Almquist <martin.almquist@it.uu.se>
parents:
diff
changeset
|
3 % with m nodes, which is of degree 2m-1. Hence, The operator D1 is |
4d9d8064e58b
Implementation of D1 based on Gauss quadrature formula with 4 nodes.
Martin Almquist <martin.almquist@it.uu.se>
parents:
diff
changeset
|
4 % accurate of order m. |
4d9d8064e58b
Implementation of D1 based on Gauss quadrature formula with 4 nodes.
Martin Almquist <martin.almquist@it.uu.se>
parents:
diff
changeset
|
5 properties |
4d9d8064e58b
Implementation of D1 based on Gauss quadrature formula with 4 nodes.
Martin Almquist <martin.almquist@it.uu.se>
parents:
diff
changeset
|
6 D1 % SBP operator approximating first derivative |
4d9d8064e58b
Implementation of D1 based on Gauss quadrature formula with 4 nodes.
Martin Almquist <martin.almquist@it.uu.se>
parents:
diff
changeset
|
7 H % Norm matrix |
4d9d8064e58b
Implementation of D1 based on Gauss quadrature formula with 4 nodes.
Martin Almquist <martin.almquist@it.uu.se>
parents:
diff
changeset
|
8 HI % H^-1 |
4d9d8064e58b
Implementation of D1 based on Gauss quadrature formula with 4 nodes.
Martin Almquist <martin.almquist@it.uu.se>
parents:
diff
changeset
|
9 Q % Skew-symmetric matrix |
4d9d8064e58b
Implementation of D1 based on Gauss quadrature formula with 4 nodes.
Martin Almquist <martin.almquist@it.uu.se>
parents:
diff
changeset
|
10 e_l % Left boundary operator |
4d9d8064e58b
Implementation of D1 based on Gauss quadrature formula with 4 nodes.
Martin Almquist <martin.almquist@it.uu.se>
parents:
diff
changeset
|
11 e_r % Right boundary operator |
4d9d8064e58b
Implementation of D1 based on Gauss quadrature formula with 4 nodes.
Martin Almquist <martin.almquist@it.uu.se>
parents:
diff
changeset
|
12 m % Number of grid points. |
4d9d8064e58b
Implementation of D1 based on Gauss quadrature formula with 4 nodes.
Martin Almquist <martin.almquist@it.uu.se>
parents:
diff
changeset
|
13 h % Step size |
4d9d8064e58b
Implementation of D1 based on Gauss quadrature formula with 4 nodes.
Martin Almquist <martin.almquist@it.uu.se>
parents:
diff
changeset
|
14 x % grid |
4d9d8064e58b
Implementation of D1 based on Gauss quadrature formula with 4 nodes.
Martin Almquist <martin.almquist@it.uu.se>
parents:
diff
changeset
|
15 borrowing % Struct with borrowing limits for different norm matrices |
4d9d8064e58b
Implementation of D1 based on Gauss quadrature formula with 4 nodes.
Martin Almquist <martin.almquist@it.uu.se>
parents:
diff
changeset
|
16 end |
4d9d8064e58b
Implementation of D1 based on Gauss quadrature formula with 4 nodes.
Martin Almquist <martin.almquist@it.uu.se>
parents:
diff
changeset
|
17 |
4d9d8064e58b
Implementation of D1 based on Gauss quadrature formula with 4 nodes.
Martin Almquist <martin.almquist@it.uu.se>
parents:
diff
changeset
|
18 methods |
4d9d8064e58b
Implementation of D1 based on Gauss quadrature formula with 4 nodes.
Martin Almquist <martin.almquist@it.uu.se>
parents:
diff
changeset
|
19 function obj = D1Gauss(m,lim) |
4d9d8064e58b
Implementation of D1 based on Gauss quadrature formula with 4 nodes.
Martin Almquist <martin.almquist@it.uu.se>
parents:
diff
changeset
|
20 |
4d9d8064e58b
Implementation of D1 based on Gauss quadrature formula with 4 nodes.
Martin Almquist <martin.almquist@it.uu.se>
parents:
diff
changeset
|
21 x_l = lim{1}; |
4d9d8064e58b
Implementation of D1 based on Gauss quadrature formula with 4 nodes.
Martin Almquist <martin.almquist@it.uu.se>
parents:
diff
changeset
|
22 x_r = lim{2}; |
4d9d8064e58b
Implementation of D1 based on Gauss quadrature formula with 4 nodes.
Martin Almquist <martin.almquist@it.uu.se>
parents:
diff
changeset
|
23 L = x_r-x_l; |
4d9d8064e58b
Implementation of D1 based on Gauss quadrature formula with 4 nodes.
Martin Almquist <martin.almquist@it.uu.se>
parents:
diff
changeset
|
24 |
4d9d8064e58b
Implementation of D1 based on Gauss quadrature formula with 4 nodes.
Martin Almquist <martin.almquist@it.uu.se>
parents:
diff
changeset
|
25 switch m |
4d9d8064e58b
Implementation of D1 based on Gauss quadrature formula with 4 nodes.
Martin Almquist <martin.almquist@it.uu.se>
parents:
diff
changeset
|
26 case 4 |
4d9d8064e58b
Implementation of D1 based on Gauss quadrature formula with 4 nodes.
Martin Almquist <martin.almquist@it.uu.se>
parents:
diff
changeset
|
27 [obj.D1,obj.H,obj.x,obj.h,obj.e_l,obj.e_r] = ... |
409
42c4f0b545d6
Remove m as input to implementation function. Fix error message for invalid m to D1Gauss
Jonatan Werpers <jonatan@werpers.com>
parents:
405
diff
changeset
|
28 sbp.implementations.d1_gauss_4(L); |
405
4d9d8064e58b
Implementation of D1 based on Gauss quadrature formula with 4 nodes.
Martin Almquist <martin.almquist@it.uu.se>
parents:
diff
changeset
|
29 otherwise |
409
42c4f0b545d6
Remove m as input to implementation function. Fix error message for invalid m to D1Gauss
Jonatan Werpers <jonatan@werpers.com>
parents:
405
diff
changeset
|
30 error('Invalid number of points: %d.', m); |
405
4d9d8064e58b
Implementation of D1 based on Gauss quadrature formula with 4 nodes.
Martin Almquist <martin.almquist@it.uu.se>
parents:
diff
changeset
|
31 end |
4d9d8064e58b
Implementation of D1 based on Gauss quadrature formula with 4 nodes.
Martin Almquist <martin.almquist@it.uu.se>
parents:
diff
changeset
|
32 |
4d9d8064e58b
Implementation of D1 based on Gauss quadrature formula with 4 nodes.
Martin Almquist <martin.almquist@it.uu.se>
parents:
diff
changeset
|
33 |
4d9d8064e58b
Implementation of D1 based on Gauss quadrature formula with 4 nodes.
Martin Almquist <martin.almquist@it.uu.se>
parents:
diff
changeset
|
34 obj.x = obj.x + x_l; |
4d9d8064e58b
Implementation of D1 based on Gauss quadrature formula with 4 nodes.
Martin Almquist <martin.almquist@it.uu.se>
parents:
diff
changeset
|
35 obj.HI = inv(obj.H); |
4d9d8064e58b
Implementation of D1 based on Gauss quadrature formula with 4 nodes.
Martin Almquist <martin.almquist@it.uu.se>
parents:
diff
changeset
|
36 obj.Q = obj.H*obj.D1 - obj.e_r*obj.e_r' + obj.e_l*obj.e_l'; |
4d9d8064e58b
Implementation of D1 based on Gauss quadrature formula with 4 nodes.
Martin Almquist <martin.almquist@it.uu.se>
parents:
diff
changeset
|
37 |
4d9d8064e58b
Implementation of D1 based on Gauss quadrature formula with 4 nodes.
Martin Almquist <martin.almquist@it.uu.se>
parents:
diff
changeset
|
38 obj.borrowing = []; |
4d9d8064e58b
Implementation of D1 based on Gauss quadrature formula with 4 nodes.
Martin Almquist <martin.almquist@it.uu.se>
parents:
diff
changeset
|
39 end |
441
e1d11b6a68d8
Add string methods to OpSets that are missing them
Jonatan Werpers <jonatan@werpers.com>
parents:
409
diff
changeset
|
40 |
e1d11b6a68d8
Add string methods to OpSets that are missing them
Jonatan Werpers <jonatan@werpers.com>
parents:
409
diff
changeset
|
41 function str = string(obj) |
e1d11b6a68d8
Add string methods to OpSets that are missing them
Jonatan Werpers <jonatan@werpers.com>
parents:
409
diff
changeset
|
42 str = [class(obj) '_' num2str(obj.order)]; |
e1d11b6a68d8
Add string methods to OpSets that are missing them
Jonatan Werpers <jonatan@werpers.com>
parents:
409
diff
changeset
|
43 end |
405
4d9d8064e58b
Implementation of D1 based on Gauss quadrature formula with 4 nodes.
Martin Almquist <martin.almquist@it.uu.se>
parents:
diff
changeset
|
44 end |
4d9d8064e58b
Implementation of D1 based on Gauss quadrature formula with 4 nodes.
Martin Almquist <martin.almquist@it.uu.se>
parents:
diff
changeset
|
45 end |