Mercurial > repos > public > sbplib
comparison +time/SBPInTimeImplicitFormulation.m @ 1113:47e86b5270ad feature/timesteppers
Change name of property k to dt in time.Timestepper
author | Jonatan Werpers <jonatan@werpers.com> |
---|---|
date | Wed, 10 Apr 2019 22:40:55 +0200 |
parents | 5df7f99206b2 |
children |
comparison
equal
deleted
inserted
replaced
1112:835c8fa456ec | 1113:47e86b5270ad |
---|---|
3 % Implemented for A*v_t = B*v + f(t), v(0) = v0 | 3 % Implemented for A*v_t = B*v + f(t), v(0) = v0 |
4 properties | 4 properties |
5 A,B | 5 A,B |
6 f | 6 f |
7 | 7 |
8 k % total time step. | 8 dt % total time step. |
9 | 9 |
10 blockSize % number of points in each block | 10 blockSize % number of points in each block |
11 N % Number of components | 11 N % Number of components |
12 | 12 |
13 order | 13 order |
22 v | 22 v |
23 n | 23 n |
24 end | 24 end |
25 | 25 |
26 methods | 26 methods |
27 function obj = SBPInTimeImplicitFormulation(A, B, f, k, t0, v0, TYPE, order, blockSize) | 27 function obj = SBPInTimeImplicitFormulation(A, B, f, dt, t0, v0, TYPE, order, blockSize) |
28 | 28 |
29 default_arg('TYPE','gauss'); | 29 default_arg('TYPE','gauss'); |
30 default_arg('f',[]); | 30 default_arg('f',[]); |
31 | 31 |
32 if(strcmp(TYPE,'gauss')) | 32 if(strcmp(TYPE,'gauss')) |
44 obj.f = f; | 44 obj.f = f; |
45 else | 45 else |
46 obj.f = @(t)sparse(length(v0),1); | 46 obj.f = @(t)sparse(length(v0),1); |
47 end | 47 end |
48 | 48 |
49 obj.k = k; | 49 obj.dt = dt; |
50 obj.blockSize = blockSize; | 50 obj.blockSize = blockSize; |
51 obj.N = length(v0); | 51 obj.N = length(v0); |
52 | 52 |
53 obj.n = 0; | 53 obj.n = 0; |
54 obj.t = t0; | 54 obj.t = t0; |
55 | 55 |
56 %==== Build the time discretization matrix =====% | 56 %==== Build the time discretization matrix =====% |
57 switch TYPE | 57 switch TYPE |
58 case 'equidistant' | 58 case 'equidistant' |
59 ops = sbp.D2Standard(blockSize,{0,obj.k},order); | 59 ops = sbp.D2Standard(blockSize,{0,obj.dt},order); |
60 case 'optimal' | 60 case 'optimal' |
61 ops = sbp.D1Nonequidistant(blockSize,{0,obj.k},order); | 61 ops = sbp.D1Nonequidistant(blockSize,{0,obj.dt},order); |
62 case 'minimal' | 62 case 'minimal' |
63 ops = sbp.D1Nonequidistant(blockSize,{0,obj.k},order,'minimal'); | 63 ops = sbp.D1Nonequidistant(blockSize,{0,obj.dt},order,'minimal'); |
64 case 'gauss' | 64 case 'gauss' |
65 ops = sbp.D1Gauss(blockSize,{0,obj.k}); | 65 ops = sbp.D1Gauss(blockSize,{0,obj.dt}); |
66 end | 66 end |
67 | 67 |
68 I = speye(size(A)); | 68 I = speye(size(A)); |
69 I_t = speye(blockSize,blockSize); | 69 I_t = speye(blockSize,blockSize); |
70 | 70 |
110 w = zeros(size(z)); | 110 w = zeros(size(z)); |
111 w(obj.q) = z; | 111 w(obj.q) = z; |
112 | 112 |
113 obj.v = obj.e_T'*w; | 113 obj.v = obj.e_T'*w; |
114 | 114 |
115 obj.t = obj.t + obj.k; | 115 obj.t = obj.t + obj.dt; |
116 obj.n = obj.n + 1; | 116 obj.n = obj.n + 1; |
117 end | 117 end |
118 end | 118 end |
119 | 119 |
120 methods(Static) | 120 methods(Static) |