Mercurial > repos > public > sbplib
annotate +sbp/+implementations/d1_gauss_4.m @ 409:42c4f0b545d6 feature/SBPInTimeGauss
Remove m as input to implementation function. Fix error message for invalid m to D1Gauss
author | Jonatan Werpers <jonatan@werpers.com> |
---|---|
date | Tue, 07 Feb 2017 13:49:46 +0100 |
parents | ba73c9c8d1a6 |
children | 0bc37a25ed88 |
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 |
4d9d8064e58b
Implementation of D1 based on Gauss quadrature formula with 4 nodes.
Martin Almquist <martin.almquist@it.uu.se>
parents:
diff
changeset
|
4 % N: 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
|
5 if(nargin < 2) |
4d9d8064e58b
Implementation of D1 based on Gauss quadrature formula with 4 nodes.
Martin Almquist <martin.almquist@it.uu.se>
parents:
diff
changeset
|
6 L = 1; |
4d9d8064e58b
Implementation of D1 based on Gauss quadrature formula with 4 nodes.
Martin Almquist <martin.almquist@it.uu.se>
parents:
diff
changeset
|
7 end |
4d9d8064e58b
Implementation of D1 based on Gauss quadrature formula with 4 nodes.
Martin Almquist <martin.almquist@it.uu.se>
parents:
diff
changeset
|
8 |
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
|
9 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
|
10 |
4d9d8064e58b
Implementation of D1 based on Gauss quadrature formula with 4 nodes.
Martin Almquist <martin.almquist@it.uu.se>
parents:
diff
changeset
|
11 % 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
|
12 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
|
13 |
4d9d8064e58b
Implementation of D1 based on Gauss quadrature formula with 4 nodes.
Martin Almquist <martin.almquist@it.uu.se>
parents:
diff
changeset
|
14 % 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
|
15 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
|
16 |
4d9d8064e58b
Implementation of D1 based on Gauss quadrature formula with 4 nodes.
Martin Almquist <martin.almquist@it.uu.se>
parents:
diff
changeset
|
17 % 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
|
18 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
|
19 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
|
20 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
|
21 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
|
22 |
4d9d8064e58b
Implementation of D1 based on Gauss quadrature formula with 4 nodes.
Martin Almquist <martin.almquist@it.uu.se>
parents:
diff
changeset
|
23 %%%% 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
|
24 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
|
25 %%%%%%%%%%%%%%%%%%%%%%%%% |
4d9d8064e58b
Implementation of D1 based on Gauss quadrature formula with 4 nodes.
Martin Almquist <martin.almquist@it.uu.se>
parents:
diff
changeset
|
26 |
4d9d8064e58b
Implementation of D1 based on Gauss quadrature formula with 4 nodes.
Martin Almquist <martin.almquist@it.uu.se>
parents:
diff
changeset
|
27 %%%% 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
|
28 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
|
29 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
|
30 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
|
31 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
|
32 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
|
33 %%%%%%%%%%%%%%%%%%%%%%%%% |
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 %%%% 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
|
36 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
|
37 %%%%%%%%%%%%%%%%%%%%%%%%% |
4d9d8064e58b
Implementation of D1 based on Gauss quadrature formula with 4 nodes.
Martin Almquist <martin.almquist@it.uu.se>
parents:
diff
changeset
|
38 |
4d9d8064e58b
Implementation of D1 based on Gauss quadrature formula with 4 nodes.
Martin Almquist <martin.almquist@it.uu.se>
parents:
diff
changeset
|
39 %%%% 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
|
40 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
|
41 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
|
42 D1(1,2) = 4.8601544156851962; |
408
ba73c9c8d1a6
Remove extra whitespace.
Jonatan Werpers <jonatan@werpers.com>
parents:
405
diff
changeset
|
43 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
|
44 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
|
45 |
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,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
|
47 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
|
48 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
|
49 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
|
50 |
4d9d8064e58b
Implementation of D1 based on Gauss quadrature formula with 4 nodes.
Martin Almquist <martin.almquist@it.uu.se>
parents:
diff
changeset
|
51 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
|
52 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
|
53 D1(3,3) = 0.3844143922232086; |
408
ba73c9c8d1a6
Remove extra whitespace.
Jonatan Werpers <jonatan@werpers.com>
parents:
405
diff
changeset
|
54 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
|
55 |
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,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
|
57 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
|
58 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
|
59 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
|
60 %%%%%%%%%%%%%%%%%%%%%%%%% |
4d9d8064e58b
Implementation of D1 based on Gauss quadrature formula with 4 nodes.
Martin Almquist <martin.almquist@it.uu.se>
parents:
diff
changeset
|
61 |
4d9d8064e58b
Implementation of D1 based on Gauss quadrature formula with 4 nodes.
Martin Almquist <martin.almquist@it.uu.se>
parents:
diff
changeset
|
62 % 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
|
63 D1 = D1*2/L; |