annotate +sbp/D2Variable.m @ 774:66eb4a2bbb72 feature/grids

Remove default scaling of the system. The scaling doens't seem to help actual solutions. One example that fails in the flexural code. With large timesteps the solutions seems to blow up. One particular example is profilePresentation on the tdb_presentation_figures branch with k = 0.0005
author Jonatan Werpers <jonatan@werpers.com>
date Wed, 18 Jul 2018 15:42:52 -0700
parents 359861563866
children 43ea848b6aa1
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
252
07fa0d6a05bb Renamned class files and added nonequidistant operators.
Martin Almquist <martin.almquist@it.uu.se>
parents:
diff changeset
1 classdef D2Variable < sbp.OpSet
07fa0d6a05bb Renamned class files and added nonequidistant operators.
Martin Almquist <martin.almquist@it.uu.se>
parents:
diff changeset
2 properties
263
21a180acbd49 Renamed standard class to D2Standard etc, Rewrote class properties.
Martin Almquist <martin.almquist@it.uu.se>
parents: 262
diff changeset
3 D1 % SBP operator approximating first derivative
21a180acbd49 Renamed standard class to D2Standard etc, Rewrote class properties.
Martin Almquist <martin.almquist@it.uu.se>
parents: 262
diff changeset
4 H % Norm matrix
21a180acbd49 Renamed standard class to D2Standard etc, Rewrote class properties.
Martin Almquist <martin.almquist@it.uu.se>
parents: 262
diff changeset
5 HI % H^-1
21a180acbd49 Renamed standard class to D2Standard etc, Rewrote class properties.
Martin Almquist <martin.almquist@it.uu.se>
parents: 262
diff changeset
6 Q % Skew-symmetric matrix
268
4b9310edcdf8 Renamned boundary operators!
Martin Almquist <martin.almquist@it.uu.se>
parents: 264
diff changeset
7 e_l % Left boundary operator
4b9310edcdf8 Renamned boundary operators!
Martin Almquist <martin.almquist@it.uu.se>
parents: 264
diff changeset
8 e_r % Right boundary operator
263
21a180acbd49 Renamed standard class to D2Standard etc, Rewrote class properties.
Martin Almquist <martin.almquist@it.uu.se>
parents: 262
diff changeset
9 D2 % SBP operator for second derivative
21a180acbd49 Renamed standard class to D2Standard etc, Rewrote class properties.
Martin Almquist <martin.almquist@it.uu.se>
parents: 262
diff changeset
10 M % Norm matrix, second derivative
268
4b9310edcdf8 Renamned boundary operators!
Martin Almquist <martin.almquist@it.uu.se>
parents: 264
diff changeset
11 d1_l % Left boundary first derivative
4b9310edcdf8 Renamned boundary operators!
Martin Almquist <martin.almquist@it.uu.se>
parents: 264
diff changeset
12 d1_r % Right boundary first derivative
252
07fa0d6a05bb Renamned class files and added nonequidistant operators.
Martin Almquist <martin.almquist@it.uu.se>
parents:
diff changeset
13 m % Number of grid points.
07fa0d6a05bb Renamned class files and added nonequidistant operators.
Martin Almquist <martin.almquist@it.uu.se>
parents:
diff changeset
14 h % Step size
263
21a180acbd49 Renamed standard class to D2Standard etc, Rewrote class properties.
Martin Almquist <martin.almquist@it.uu.se>
parents: 262
diff changeset
15 x % grid
21a180acbd49 Renamed standard class to D2Standard etc, Rewrote class properties.
Martin Almquist <martin.almquist@it.uu.se>
parents: 262
diff changeset
16 borrowing % Struct with borrowing limits for different norm matrices
252
07fa0d6a05bb Renamned class files and added nonequidistant operators.
Martin Almquist <martin.almquist@it.uu.se>
parents:
diff changeset
17 end
07fa0d6a05bb Renamned class files and added nonequidistant operators.
Martin Almquist <martin.almquist@it.uu.se>
parents:
diff changeset
18
07fa0d6a05bb Renamned class files and added nonequidistant operators.
Martin Almquist <martin.almquist@it.uu.se>
parents:
diff changeset
19 methods
264
8a625c5a3633 Changed input parameter L (domain length) to lim (cell with domain boundaries)
Martin Almquist <martin.almquist@it.uu.se>
parents: 263
diff changeset
20 function obj = D2Variable(m,lim,order)
336
f36d172e196b Added missing string method.
Jonatan Werpers <jonatan@werpers.com>
parents: 268
diff changeset
21
264
8a625c5a3633 Changed input parameter L (domain length) to lim (cell with domain boundaries)
Martin Almquist <martin.almquist@it.uu.se>
parents: 263
diff changeset
22 x_l = lim{1};
8a625c5a3633 Changed input parameter L (domain length) to lim (cell with domain boundaries)
Martin Almquist <martin.almquist@it.uu.se>
parents: 263
diff changeset
23 x_r = lim{2};
8a625c5a3633 Changed input parameter L (domain length) to lim (cell with domain boundaries)
Martin Almquist <martin.almquist@it.uu.se>
parents: 263
diff changeset
24 L = x_r-x_l;
263
21a180acbd49 Renamed standard class to D2Standard etc, Rewrote class properties.
Martin Almquist <martin.almquist@it.uu.se>
parents: 262
diff changeset
25 obj.h = L/(m-1);
264
8a625c5a3633 Changed input parameter L (domain length) to lim (cell with domain boundaries)
Martin Almquist <martin.almquist@it.uu.se>
parents: 263
diff changeset
26 obj.x = linspace(x_l,x_r,m)';
252
07fa0d6a05bb Renamned class files and added nonequidistant operators.
Martin Almquist <martin.almquist@it.uu.se>
parents:
diff changeset
27
07fa0d6a05bb Renamned class files and added nonequidistant operators.
Martin Almquist <martin.almquist@it.uu.se>
parents:
diff changeset
28 switch order
07fa0d6a05bb Renamned class files and added nonequidistant operators.
Martin Almquist <martin.almquist@it.uu.se>
parents:
diff changeset
29 case 4
268
4b9310edcdf8 Renamned boundary operators!
Martin Almquist <martin.almquist@it.uu.se>
parents: 264
diff changeset
30 [obj.H, obj.HI, obj.D1, obj.D2, obj.e_l,...
4b9310edcdf8 Renamned boundary operators!
Martin Almquist <martin.almquist@it.uu.se>
parents: 264
diff changeset
31 obj.e_r, obj.d1_l, obj.d1_r] = ...
263
21a180acbd49 Renamed standard class to D2Standard etc, Rewrote class properties.
Martin Almquist <martin.almquist@it.uu.se>
parents: 262
diff changeset
32 sbp.implementations.d2_variable_4(m,obj.h);
389
42c89b5eedc0 Add borrowing constants for D2 operators in D4Variable
Jonatan Werpers <jonatan@werpers.com>
parents: 336
diff changeset
33 obj.borrowing.M.d1 = 0.2505765857;
362
ded4156e53e2 Added 2nd order accurate 2nd derivative with variable coefficents in a separate implementation file, used by the class D2Variable.
Martin Almquist <martin.almquist@it.uu.se>
parents: 268
diff changeset
34 case 2
ded4156e53e2 Added 2nd order accurate 2nd derivative with variable coefficents in a separate implementation file, used by the class D2Variable.
Martin Almquist <martin.almquist@it.uu.se>
parents: 268
diff changeset
35 [obj.H, obj.HI, obj.D1, obj.D2, obj.e_l,...
ded4156e53e2 Added 2nd order accurate 2nd derivative with variable coefficents in a separate implementation file, used by the class D2Variable.
Martin Almquist <martin.almquist@it.uu.se>
parents: 268
diff changeset
36 obj.e_r, obj.d1_l, obj.d1_r] = ...
ded4156e53e2 Added 2nd order accurate 2nd derivative with variable coefficents in a separate implementation file, used by the class D2Variable.
Martin Almquist <martin.almquist@it.uu.se>
parents: 268
diff changeset
37 sbp.implementations.d2_variable_2(m,obj.h);
395
359861563866 Merge with default.
Jonatan Werpers <jonatan@werpers.com>
parents: 389 362
diff changeset
38 obj.borrowing.M.d1 = 0.3636363636;
362
ded4156e53e2 Added 2nd order accurate 2nd derivative with variable coefficents in a separate implementation file, used by the class D2Variable.
Martin Almquist <martin.almquist@it.uu.se>
parents: 268
diff changeset
39 % Borrowing const taken from Virta 2014
ded4156e53e2 Added 2nd order accurate 2nd derivative with variable coefficents in a separate implementation file, used by the class D2Variable.
Martin Almquist <martin.almquist@it.uu.se>
parents: 268
diff changeset
40
252
07fa0d6a05bb Renamned class files and added nonequidistant operators.
Martin Almquist <martin.almquist@it.uu.se>
parents:
diff changeset
41 otherwise
07fa0d6a05bb Renamned class files and added nonequidistant operators.
Martin Almquist <martin.almquist@it.uu.se>
parents:
diff changeset
42 error('Invalid operator order %d.',order);
07fa0d6a05bb Renamned class files and added nonequidistant operators.
Martin Almquist <martin.almquist@it.uu.se>
parents:
diff changeset
43 end
07fa0d6a05bb Renamned class files and added nonequidistant operators.
Martin Almquist <martin.almquist@it.uu.se>
parents:
diff changeset
44
07fa0d6a05bb Renamned class files and added nonequidistant operators.
Martin Almquist <martin.almquist@it.uu.se>
parents:
diff changeset
45 obj.m = m;
263
21a180acbd49 Renamed standard class to D2Standard etc, Rewrote class properties.
Martin Almquist <martin.almquist@it.uu.se>
parents: 262
diff changeset
46 obj.M = [];
252
07fa0d6a05bb Renamned class files and added nonequidistant operators.
Martin Almquist <martin.almquist@it.uu.se>
parents:
diff changeset
47 end
336
f36d172e196b Added missing string method.
Jonatan Werpers <jonatan@werpers.com>
parents: 268
diff changeset
48 function str = string(obj)
f36d172e196b Added missing string method.
Jonatan Werpers <jonatan@werpers.com>
parents: 268
diff changeset
49 str = [class(obj) '_' num2str(obj.order)];
252
07fa0d6a05bb Renamned class files and added nonequidistant operators.
Martin Almquist <martin.almquist@it.uu.se>
parents:
diff changeset
50 end
07fa0d6a05bb Renamned class files and added nonequidistant operators.
Martin Almquist <martin.almquist@it.uu.se>
parents:
diff changeset
51 end
07fa0d6a05bb Renamned class files and added nonequidistant operators.
Martin Almquist <martin.almquist@it.uu.se>
parents:
diff changeset
52
336
f36d172e196b Added missing string method.
Jonatan Werpers <jonatan@werpers.com>
parents: 268
diff changeset
53
252
07fa0d6a05bb Renamned class files and added nonequidistant operators.
Martin Almquist <martin.almquist@it.uu.se>
parents:
diff changeset
54 end
07fa0d6a05bb Renamned class files and added nonequidistant operators.
Martin Almquist <martin.almquist@it.uu.se>
parents:
diff changeset
55
07fa0d6a05bb Renamned class files and added nonequidistant operators.
Martin Almquist <martin.almquist@it.uu.se>
parents:
diff changeset
56
07fa0d6a05bb Renamned class files and added nonequidistant operators.
Martin Almquist <martin.almquist@it.uu.se>
parents:
diff changeset
57
07fa0d6a05bb Renamned class files and added nonequidistant operators.
Martin Almquist <martin.almquist@it.uu.se>
parents:
diff changeset
58
07fa0d6a05bb Renamned class files and added nonequidistant operators.
Martin Almquist <martin.almquist@it.uu.se>
parents:
diff changeset
59