comparison +time/ExplicitRungeKuttaDiscreteData.m @ 890:c70131daaa6e feature/d1_staggered

Merge with feature/poroelastic.
author Martin Almquist <malmquist@stanford.edu>
date Wed, 21 Nov 2018 18:29:29 -0800
parents 44c46bd6913a 4c7532db42cd
children
comparison
equal deleted inserted replaced
885:18e10217dca9 890:c70131daaa6e
1 classdef ExplicitRungeKuttaDiscreteData < time.Timestepper 1 classdef ExplicitRungeKuttaDiscreteData < time.Timestepper
2 properties 2 properties
3 D 3 D
4 S % Function handle for time-dependent data 4 S % Function handle for time-dependent data
5 data % Matrix of data vectors, one column per stage 5 data % Matrix of data vectors, one column per stage
6 F
7 k 6 k
8 t 7 t
9 v 8 v
10 m 9 m
11 n 10 n
55 54
56 function [a,b,c,s] = getTableau(obj) 55 function [a,b,c,s] = getTableau(obj)
57 a = obj.a; 56 a = obj.a;
58 b = obj.b; 57 b = obj.b;
59 c = obj.c; 58 c = obj.c;
60 s = obj.s; 59 s = obj.s;
60 end
61
62 % Returns quadrature weights for stages in one time step
63 function quadWeights = getTimeStepQuadrature(obj)
64 [~, b] = obj.getTableau();
65 quadWeights = obj.k*b;
61 end 66 end
62 67
63 function obj = step(obj) 68 function obj = step(obj)
64 v = obj.v; 69 v = obj.v;
65 a = obj.a; 70 a = obj.a;
80 end 85 end
81 86
82 K(:,i) = D*U(:,i); 87 K(:,i) = D*U(:,i);
83 obj.T(i) = obj.t + c(i)*dt; 88 obj.T(i) = obj.t + c(i)*dt;
84 89
85 % Data from continuos function and discrete time-points. 90 % Data from continuous function and discrete time-points.
86 if ~isempty(S) 91 if ~isempty(S)
87 K(:,i) = K(:,i) + S(obj.T(i)); 92 K(:,i) = K(:,i) + S(obj.T(i));
88 end 93 end
89 if ~isempty(data) 94 if ~isempty(data)
90 K(:,i) = K(:,i) + data(:,obj.n*s + i); 95 K(:,i) = K(:,i) + data(:,obj.n*s + i);
91 end 96 end
92 97
93 end 98 end
94 99
95 obj.v = v + dt*K*b; 100 obj.v = v + dt*K*b;
100 end 105 end
101 end 106 end
102 107
103 108
104 methods (Static) 109 methods (Static)
105 function k = getTimeStep(lambda) 110 function k = getTimeStep(lambda, order)
106 111 default_arg('order', 4);
107 switch obj.order 112 switch order
108 case 4 113 case 4
109 k = rk4.get_rk4_time_step(lambda); 114 k = time.rk4.get_rk4_time_step(lambda);
110 otherwise 115 otherwise
111 error('Time-step function not available for this order'); 116 error('Time-step function not available for this order');
112 end 117 end
113 end 118 end
114 end 119 end