Mercurial > repos > public > sbplib
annotate +sbp/+implementations/d1_gauss_4.m @ 1037:2d7ba44340d0 feature/burgers1d
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.
author | Vidar Stiernström <vidar.stiernstrom@it.uu.se> |
---|---|
date | Fri, 18 Jan 2019 09:02:02 +0100 |
parents | 0bc37a25ed88 |
children |
rev | line source |
---|---|
409
42c4f0b545d6
Remove m as input to implementation function. Fix error message for invalid m to D1Gauss
Jonatan Werpers <jonatan@werpers.com>
parents:
408
diff
changeset
|
1 function [D1,H,x,h,e_l,e_r] = 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
|
2 |
4d9d8064e58b
Implementation of D1 based on Gauss quadrature formula with 4 nodes.
Martin Almquist <martin.almquist@it.uu.se>
parents:
diff
changeset
|
3 % L: Domain length |
434
0bc37a25ed88
Bug fix sbp in time gauss default arg
Martin Almquist <martin.almquist@it.uu.se>
parents:
409
diff
changeset
|
4 default_arg('L',1); |
405
4d9d8064e58b
Implementation of D1 based on Gauss quadrature formula with 4 nodes.
Martin Almquist <martin.almquist@it.uu.se>
parents:
diff
changeset
|
5 |
409
42c4f0b545d6
Remove m as input to implementation function. Fix error message for invalid m to D1Gauss
Jonatan Werpers <jonatan@werpers.com>
parents:
408
diff
changeset
|
6 N = 4; |
405
4d9d8064e58b
Implementation of D1 based on Gauss quadrature formula with 4 nodes.
Martin Almquist <martin.almquist@it.uu.se>
parents:
diff
changeset
|
7 |
4d9d8064e58b
Implementation of D1 based on Gauss quadrature formula with 4 nodes.
Martin Almquist <martin.almquist@it.uu.se>
parents:
diff
changeset
|
8 % Quadrature nodes on interval [-1, 1] |
4d9d8064e58b
Implementation of D1 based on Gauss quadrature formula with 4 nodes.
Martin Almquist <martin.almquist@it.uu.se>
parents:
diff
changeset
|
9 x = [ -0.8611363115940526; -0.3399810435848563; 0.3399810435848563; 0.8611363115940526]; |
4d9d8064e58b
Implementation of D1 based on Gauss quadrature formula with 4 nodes.
Martin Almquist <martin.almquist@it.uu.se>
parents:
diff
changeset
|
10 |
4d9d8064e58b
Implementation of D1 based on Gauss quadrature formula with 4 nodes.
Martin Almquist <martin.almquist@it.uu.se>
parents:
diff
changeset
|
11 % Shift nodes to [0,L] |
4d9d8064e58b
Implementation of D1 based on Gauss quadrature formula with 4 nodes.
Martin Almquist <martin.almquist@it.uu.se>
parents:
diff
changeset
|
12 x = (x+1)/2*L; |
4d9d8064e58b
Implementation of D1 based on Gauss quadrature formula with 4 nodes.
Martin Almquist <martin.almquist@it.uu.se>
parents:
diff
changeset
|
13 |
4d9d8064e58b
Implementation of D1 based on Gauss quadrature formula with 4 nodes.
Martin Almquist <martin.almquist@it.uu.se>
parents:
diff
changeset
|
14 % Boundary extrapolation operators |
4d9d8064e58b
Implementation of D1 based on Gauss quadrature formula with 4 nodes.
Martin Almquist <martin.almquist@it.uu.se>
parents:
diff
changeset
|
15 e_l = [1.5267881254572668; -0.8136324494869273; 0.4007615203116504; -0.1139171962819899]; |
4d9d8064e58b
Implementation of D1 based on Gauss quadrature formula with 4 nodes.
Martin Almquist <martin.almquist@it.uu.se>
parents:
diff
changeset
|
16 e_r = flipud(e_l); |
4d9d8064e58b
Implementation of D1 based on Gauss quadrature formula with 4 nodes.
Martin Almquist <martin.almquist@it.uu.se>
parents:
diff
changeset
|
17 e_l = sparse(e_l); |
4d9d8064e58b
Implementation of D1 based on Gauss quadrature formula with 4 nodes.
Martin Almquist <martin.almquist@it.uu.se>
parents:
diff
changeset
|
18 e_r = sparse(e_r); |
4d9d8064e58b
Implementation of D1 based on Gauss quadrature formula with 4 nodes.
Martin Almquist <martin.almquist@it.uu.se>
parents:
diff
changeset
|
19 |
4d9d8064e58b
Implementation of D1 based on Gauss quadrature formula with 4 nodes.
Martin Almquist <martin.almquist@it.uu.se>
parents:
diff
changeset
|
20 %%%% Compute approximate h %%%%%%%%%% |
4d9d8064e58b
Implementation of D1 based on Gauss quadrature formula with 4 nodes.
Martin Almquist <martin.almquist@it.uu.se>
parents:
diff
changeset
|
21 h = L/(N-1); |
4d9d8064e58b
Implementation of D1 based on Gauss quadrature formula with 4 nodes.
Martin Almquist <martin.almquist@it.uu.se>
parents:
diff
changeset
|
22 %%%%%%%%%%%%%%%%%%%%%%%%% |
4d9d8064e58b
Implementation of D1 based on Gauss quadrature formula with 4 nodes.
Martin Almquist <martin.almquist@it.uu.se>
parents:
diff
changeset
|
23 |
4d9d8064e58b
Implementation of D1 based on Gauss quadrature formula with 4 nodes.
Martin Almquist <martin.almquist@it.uu.se>
parents:
diff
changeset
|
24 %%%% Norm matrix on [-1,1] %%%%%%%% |
4d9d8064e58b
Implementation of D1 based on Gauss quadrature formula with 4 nodes.
Martin Almquist <martin.almquist@it.uu.se>
parents:
diff
changeset
|
25 P = sparse(N,N); |
4d9d8064e58b
Implementation of D1 based on Gauss quadrature formula with 4 nodes.
Martin Almquist <martin.almquist@it.uu.se>
parents:
diff
changeset
|
26 P(1,1) = 0.3478548451374539; |
4d9d8064e58b
Implementation of D1 based on Gauss quadrature formula with 4 nodes.
Martin Almquist <martin.almquist@it.uu.se>
parents:
diff
changeset
|
27 P(2,2) = 0.6521451548625461; |
4d9d8064e58b
Implementation of D1 based on Gauss quadrature formula with 4 nodes.
Martin Almquist <martin.almquist@it.uu.se>
parents:
diff
changeset
|
28 P(3,3) = 0.6521451548625461; |
4d9d8064e58b
Implementation of D1 based on Gauss quadrature formula with 4 nodes.
Martin Almquist <martin.almquist@it.uu.se>
parents:
diff
changeset
|
29 P(4,4) = 0.3478548451374539; |
4d9d8064e58b
Implementation of D1 based on Gauss quadrature formula with 4 nodes.
Martin Almquist <martin.almquist@it.uu.se>
parents:
diff
changeset
|
30 %%%%%%%%%%%%%%%%%%%%%%%%% |
4d9d8064e58b
Implementation of D1 based on Gauss quadrature formula with 4 nodes.
Martin Almquist <martin.almquist@it.uu.se>
parents:
diff
changeset
|
31 |
4d9d8064e58b
Implementation of D1 based on Gauss quadrature formula with 4 nodes.
Martin Almquist <martin.almquist@it.uu.se>
parents:
diff
changeset
|
32 %%%% Norm matrix on [0,L] %%%%%%%% |
4d9d8064e58b
Implementation of D1 based on Gauss quadrature formula with 4 nodes.
Martin Almquist <martin.almquist@it.uu.se>
parents:
diff
changeset
|
33 H = P*L/2; |
4d9d8064e58b
Implementation of D1 based on Gauss quadrature formula with 4 nodes.
Martin Almquist <martin.almquist@it.uu.se>
parents:
diff
changeset
|
34 %%%%%%%%%%%%%%%%%%%%%%%%% |
4d9d8064e58b
Implementation of D1 based on Gauss quadrature formula with 4 nodes.
Martin Almquist <martin.almquist@it.uu.se>
parents:
diff
changeset
|
35 |
4d9d8064e58b
Implementation of D1 based on Gauss quadrature formula with 4 nodes.
Martin Almquist <martin.almquist@it.uu.se>
parents:
diff
changeset
|
36 %%%% D1 on [-1,1] %%%%%%%% |
4d9d8064e58b
Implementation of D1 based on Gauss quadrature formula with 4 nodes.
Martin Almquist <martin.almquist@it.uu.se>
parents:
diff
changeset
|
37 D1 = sparse(N,N); |
4d9d8064e58b
Implementation of D1 based on Gauss quadrature formula with 4 nodes.
Martin Almquist <martin.almquist@it.uu.se>
parents:
diff
changeset
|
38 D1(1,1) = -3.3320002363522817; |
4d9d8064e58b
Implementation of D1 based on Gauss quadrature formula with 4 nodes.
Martin Almquist <martin.almquist@it.uu.se>
parents:
diff
changeset
|
39 D1(1,2) = 4.8601544156851962; |
408
ba73c9c8d1a6
Remove extra whitespace.
Jonatan Werpers <jonatan@werpers.com>
parents:
405
diff
changeset
|
40 D1(1,3) = -2.1087823484951789; |
405
4d9d8064e58b
Implementation of D1 based on Gauss quadrature formula with 4 nodes.
Martin Almquist <martin.almquist@it.uu.se>
parents:
diff
changeset
|
41 D1(1,4) = 0.5806281691622644; |
4d9d8064e58b
Implementation of D1 based on Gauss quadrature formula with 4 nodes.
Martin Almquist <martin.almquist@it.uu.se>
parents:
diff
changeset
|
42 |
4d9d8064e58b
Implementation of D1 based on Gauss quadrature formula with 4 nodes.
Martin Almquist <martin.almquist@it.uu.se>
parents:
diff
changeset
|
43 D1(2,1) = -0.7575576147992339; |
4d9d8064e58b
Implementation of D1 based on Gauss quadrature formula with 4 nodes.
Martin Almquist <martin.almquist@it.uu.se>
parents:
diff
changeset
|
44 D1(2,2) = -0.3844143922232086; |
4d9d8064e58b
Implementation of D1 based on Gauss quadrature formula with 4 nodes.
Martin Almquist <martin.almquist@it.uu.se>
parents:
diff
changeset
|
45 D1(2,3) = 1.4706702312807167; |
4d9d8064e58b
Implementation of D1 based on Gauss quadrature formula with 4 nodes.
Martin Almquist <martin.almquist@it.uu.se>
parents:
diff
changeset
|
46 D1(2,4) = -0.3286982242582743; |
4d9d8064e58b
Implementation of D1 based on Gauss quadrature formula with 4 nodes.
Martin Almquist <martin.almquist@it.uu.se>
parents:
diff
changeset
|
47 |
4d9d8064e58b
Implementation of D1 based on Gauss quadrature formula with 4 nodes.
Martin Almquist <martin.almquist@it.uu.se>
parents:
diff
changeset
|
48 D1(3,1) = 0.3286982242582743; |
4d9d8064e58b
Implementation of D1 based on Gauss quadrature formula with 4 nodes.
Martin Almquist <martin.almquist@it.uu.se>
parents:
diff
changeset
|
49 D1(3,2) = -1.4706702312807167; |
4d9d8064e58b
Implementation of D1 based on Gauss quadrature formula with 4 nodes.
Martin Almquist <martin.almquist@it.uu.se>
parents:
diff
changeset
|
50 D1(3,3) = 0.3844143922232086; |
408
ba73c9c8d1a6
Remove extra whitespace.
Jonatan Werpers <jonatan@werpers.com>
parents:
405
diff
changeset
|
51 D1(3,4) = 0.7575576147992339; |
405
4d9d8064e58b
Implementation of D1 based on Gauss quadrature formula with 4 nodes.
Martin Almquist <martin.almquist@it.uu.se>
parents:
diff
changeset
|
52 |
4d9d8064e58b
Implementation of D1 based on Gauss quadrature formula with 4 nodes.
Martin Almquist <martin.almquist@it.uu.se>
parents:
diff
changeset
|
53 D1(4,1) = -0.5806281691622644; |
4d9d8064e58b
Implementation of D1 based on Gauss quadrature formula with 4 nodes.
Martin Almquist <martin.almquist@it.uu.se>
parents:
diff
changeset
|
54 D1(4,2) = 2.1087823484951789; |
4d9d8064e58b
Implementation of D1 based on Gauss quadrature formula with 4 nodes.
Martin Almquist <martin.almquist@it.uu.se>
parents:
diff
changeset
|
55 D1(4,3) = -4.8601544156851962; |
4d9d8064e58b
Implementation of D1 based on Gauss quadrature formula with 4 nodes.
Martin Almquist <martin.almquist@it.uu.se>
parents:
diff
changeset
|
56 D1(4,4) = 3.3320002363522817; |
4d9d8064e58b
Implementation of D1 based on Gauss quadrature formula with 4 nodes.
Martin Almquist <martin.almquist@it.uu.se>
parents:
diff
changeset
|
57 %%%%%%%%%%%%%%%%%%%%%%%%% |
4d9d8064e58b
Implementation of D1 based on Gauss quadrature formula with 4 nodes.
Martin Almquist <martin.almquist@it.uu.se>
parents:
diff
changeset
|
58 |
4d9d8064e58b
Implementation of D1 based on Gauss quadrature formula with 4 nodes.
Martin Almquist <martin.almquist@it.uu.se>
parents:
diff
changeset
|
59 % D1 on [0,L] |
4d9d8064e58b
Implementation of D1 based on Gauss quadrature formula with 4 nodes.
Martin Almquist <martin.almquist@it.uu.se>
parents:
diff
changeset
|
60 D1 = D1*2/L; |