Mercurial > repos > public > sbplib
annotate +sbp/+implementations/d4_lonely_6_3.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 | b19e142fcae1 |
children |
rev | line source |
---|---|
324
c0cbffcf6513
Created new operator class for lonely D4 operators. Removed some output parameters of implementations.
Jonatan Werpers <jonatan@werpers.com>
parents:
322
diff
changeset
|
1 function [H, HI, D4, e_l, e_r, M4, d2_l, d2_r, d3_l, d3_r, d1_l, d1_r] = d4_variable_6_3(m,h) |
312 | 2 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
3 %%% 6:te ordn. SBP Finita differens %%% | |
4 %%% operatorer med diagonal norm %%% | |
5 %%% Extension to variable koeff %%% | |
6 %%% %%% | |
7 %%% H (Normen) %%% | |
8 %%% D1=H^(-1)Q (approx f?rsta derivatan) %%% | |
9 %%% D2 (approx andra derivatan) %%% | |
10 %%% D2=HI*(R+C*D*S %%% | |
11 %%% %%% | |
12 %%% R=-D1'*H*C*D1-RR %%% | |
13 %%% %%% | |
14 %%% RR ?r dissipation) %%% | |
15 %%% Dissipationen uppbyggd av D4: %%% | |
16 %%% DI=D4*B*H*D4 %%% | |
17 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% | |
246
fe26791489e0
Added a bunch of new operators. Still non-functional.
Jonatan Werpers <jonatan@werpers.com>
parents:
diff
changeset
|
18 |
312 | 19 % H?r med 7 RP ist?llet f?r 8 f?r D4 operatorn, dock samma randderivator |
20 % Denna ?r noggrannare, och har 2a ordningens randdslutning och b?r ge 6te | |
21 % ordningens konvergens. Hade 2 fria parametrar att optimera | |
246
fe26791489e0
Added a bunch of new operators. Still non-functional.
Jonatan Werpers <jonatan@werpers.com>
parents:
diff
changeset
|
22 |
322
def409c10800
Clean up of d4_variable_6_3.m
Jonatan Werpers <jonatan@werpers.com>
parents:
318
diff
changeset
|
23 % Norm |
def409c10800
Clean up of d4_variable_6_3.m
Jonatan Werpers <jonatan@werpers.com>
parents:
318
diff
changeset
|
24 Hv = ones(m,1); |
def409c10800
Clean up of d4_variable_6_3.m
Jonatan Werpers <jonatan@werpers.com>
parents:
318
diff
changeset
|
25 Hv(1:7) = [0.414837907e9/0.1191965760e10, 0.475278367e9/0.397321920e9, 0.13872751e8/0.12416310e8, 0.346739027e9/0.595982880e9, 0.560227469e9/0.397321920e9, 0.322971631e9/0.397321920e9, 0.616122491e9/0.595982880e9]; |
def409c10800
Clean up of d4_variable_6_3.m
Jonatan Werpers <jonatan@werpers.com>
parents:
318
diff
changeset
|
26 Hv(m-6:m) = rot90(Hv(1:7),2); |
def409c10800
Clean up of d4_variable_6_3.m
Jonatan Werpers <jonatan@werpers.com>
parents:
318
diff
changeset
|
27 Hv = h*Hv; |
def409c10800
Clean up of d4_variable_6_3.m
Jonatan Werpers <jonatan@werpers.com>
parents:
318
diff
changeset
|
28 H = spdiag(Hv, 0); |
def409c10800
Clean up of d4_variable_6_3.m
Jonatan Werpers <jonatan@werpers.com>
parents:
318
diff
changeset
|
29 HI = spdiag(1./Hv, 0); |
246
fe26791489e0
Added a bunch of new operators. Still non-functional.
Jonatan Werpers <jonatan@werpers.com>
parents:
diff
changeset
|
30 |
fe26791489e0
Added a bunch of new operators. Still non-functional.
Jonatan Werpers <jonatan@werpers.com>
parents:
diff
changeset
|
31 |
322
def409c10800
Clean up of d4_variable_6_3.m
Jonatan Werpers <jonatan@werpers.com>
parents:
318
diff
changeset
|
32 % Boundary operators |
def409c10800
Clean up of d4_variable_6_3.m
Jonatan Werpers <jonatan@werpers.com>
parents:
318
diff
changeset
|
33 e_l = sparse(m,1); |
def409c10800
Clean up of d4_variable_6_3.m
Jonatan Werpers <jonatan@werpers.com>
parents:
318
diff
changeset
|
34 e_l(1) = 1; |
def409c10800
Clean up of d4_variable_6_3.m
Jonatan Werpers <jonatan@werpers.com>
parents:
318
diff
changeset
|
35 e_r = rot90(e_l, 2); |
def409c10800
Clean up of d4_variable_6_3.m
Jonatan Werpers <jonatan@werpers.com>
parents:
318
diff
changeset
|
36 |
def409c10800
Clean up of d4_variable_6_3.m
Jonatan Werpers <jonatan@werpers.com>
parents:
318
diff
changeset
|
37 d1_l = sparse(m,1); |
def409c10800
Clean up of d4_variable_6_3.m
Jonatan Werpers <jonatan@werpers.com>
parents:
318
diff
changeset
|
38 d1_l(1:6) = [-0.137e3/0.60e2 5 -5 0.10e2/0.3e1 -0.5e1/0.4e1 0.1e1/0.5e1;]/h; |
326
b19e142fcae1
Fixed bug in setting of boundary derivative.
Jonatan Werpers <jonatan@werpers.com>
parents:
325
diff
changeset
|
39 d1_r = -rot90(d1_l, 2); |
322
def409c10800
Clean up of d4_variable_6_3.m
Jonatan Werpers <jonatan@werpers.com>
parents:
318
diff
changeset
|
40 |
def409c10800
Clean up of d4_variable_6_3.m
Jonatan Werpers <jonatan@werpers.com>
parents:
318
diff
changeset
|
41 d2_l = sparse(m,1); |
def409c10800
Clean up of d4_variable_6_3.m
Jonatan Werpers <jonatan@werpers.com>
parents:
318
diff
changeset
|
42 d2_l(1:6) = [0.15e2/0.4e1 -0.77e2/0.6e1 0.107e3/0.6e1 -13 0.61e2/0.12e2 -0.5e1/0.6e1;]/h^2; |
def409c10800
Clean up of d4_variable_6_3.m
Jonatan Werpers <jonatan@werpers.com>
parents:
318
diff
changeset
|
43 d2_r = rot90(d2_l, 2); |
def409c10800
Clean up of d4_variable_6_3.m
Jonatan Werpers <jonatan@werpers.com>
parents:
318
diff
changeset
|
44 |
def409c10800
Clean up of d4_variable_6_3.m
Jonatan Werpers <jonatan@werpers.com>
parents:
318
diff
changeset
|
45 d3_l = sparse(m,1); |
def409c10800
Clean up of d4_variable_6_3.m
Jonatan Werpers <jonatan@werpers.com>
parents:
318
diff
changeset
|
46 d3_l(1:6) = [-0.17e2/0.4e1 0.71e2/0.4e1 -0.59e2/0.2e1 0.49e2/0.2e1 -0.41e2/0.4e1 0.7e1/0.4e1;]/h^3; |
def409c10800
Clean up of d4_variable_6_3.m
Jonatan Werpers <jonatan@werpers.com>
parents:
318
diff
changeset
|
47 d3_r = -rot90(d3_l, 2); |
316
203afa156f59
Collected boundary operators.
Jonatan Werpers <jonatan@werpers.com>
parents:
312
diff
changeset
|
48 |
203afa156f59
Collected boundary operators.
Jonatan Werpers <jonatan@werpers.com>
parents:
312
diff
changeset
|
49 |
322
def409c10800
Clean up of d4_variable_6_3.m
Jonatan Werpers <jonatan@werpers.com>
parents:
318
diff
changeset
|
50 % Fourth derivative, 1th order accurate at first 8 boundary points |
def409c10800
Clean up of d4_variable_6_3.m
Jonatan Werpers <jonatan@werpers.com>
parents:
318
diff
changeset
|
51 stencil = [7/240, -2/5, 169/60, -122/15, 91/8, -122/15, 169/60, -2/5, 7/240]; |
def409c10800
Clean up of d4_variable_6_3.m
Jonatan Werpers <jonatan@werpers.com>
parents:
318
diff
changeset
|
52 diags = -4:4; |
def409c10800
Clean up of d4_variable_6_3.m
Jonatan Werpers <jonatan@werpers.com>
parents:
318
diff
changeset
|
53 M4 = stripeMatrix(stencil, diags, m); |
246
fe26791489e0
Added a bunch of new operators. Still non-functional.
Jonatan Werpers <jonatan@werpers.com>
parents:
diff
changeset
|
54 |
312 | 55 M4_U = [ |
56 0.1399708478939e13/0.263487168000e12 -0.13482796013041e14/0.834376032000e12 0.344344095859e12/0.17565811200e11 -0.3166261424681e13/0.250312809600e12 0.1508605165681e13/0.333750412800e12 -0.486270829441e12/0.834376032000e12 -0.221976356359e12/0.5006256192000e13; | |
57 -0.13482796013041e14/0.834376032000e12 0.7260475818391e13/0.139062672000e12 -0.27224036353e11/0.406022400e9 0.1847477458951e13/0.41718801600e11 -0.848984558161e12/0.55625068800e11 0.247494925991e12/0.139062672000e12 0.165585445559e12/0.834376032000e12; | |
58 0.344344095859e12/0.17565811200e11 -0.27224036353e11/0.406022400e9 0.2044938640393e13/0.22250027520e11 -0.1071086785417e13/0.16687520640e11 0.502199537033e12/0.22250027520e11 -0.143589154441e12/0.55625068800e11 -0.88181965559e11/0.333750412800e12; | |
59 -0.3166261424681e13/0.250312809600e12 0.1847477458951e13/0.41718801600e11 -0.1071086785417e13/0.16687520640e11 0.628860435593e12/0.12515640480e11 -0.73736245829e11/0.3337504128e10 0.195760572271e12/0.41718801600e11 -0.81156046361e11/0.250312809600e12; | |
60 0.1508605165681e13/0.333750412800e12 -0.848984558161e12/0.55625068800e11 0.502199537033e12/0.22250027520e11 -0.73736245829e11/0.3337504128e10 0.76725285869e11/0.4450005504e10 -0.3912429433e10/0.406022400e9 0.53227370659e11/0.17565811200e11; | |
61 -0.486270829441e12/0.834376032000e12 0.247494925991e12/0.139062672000e12 -0.143589154441e12/0.55625068800e11 0.195760572271e12/0.41718801600e11 -0.3912429433e10/0.406022400e9 0.1699707221791e13/0.139062672000e12 -0.6959018412841e13/0.834376032000e12; | |
62 -0.221976356359e12/0.5006256192000e13 0.165585445559e12/0.834376032000e12 -0.88181965559e11/0.333750412800e12 -0.81156046361e11/0.250312809600e12 0.53227370659e11/0.17565811200e11 -0.6959018412841e13/0.834376032000e12 0.3012195053939e13/0.263487168000e12; | |
63 ]; | |
64 | |
65 M4(1:7,1:7) = M4_U; | |
322
def409c10800
Clean up of d4_variable_6_3.m
Jonatan Werpers <jonatan@werpers.com>
parents:
318
diff
changeset
|
66 M4(m-6:m,m-6:m) = rot90(M4_U, 2); |
def409c10800
Clean up of d4_variable_6_3.m
Jonatan Werpers <jonatan@werpers.com>
parents:
318
diff
changeset
|
67 M4 = 1/h^3*M4; |
246
fe26791489e0
Added a bunch of new operators. Still non-functional.
Jonatan Werpers <jonatan@werpers.com>
parents:
diff
changeset
|
68 |
322
def409c10800
Clean up of d4_variable_6_3.m
Jonatan Werpers <jonatan@werpers.com>
parents:
318
diff
changeset
|
69 D4=HI*(M4 - e_l*d3_l'+e_r*d3_r' + d1_l*d2_l'-d1_r*d2_r'); |
312 | 70 end |