comparison +rv/+time/BdfDerivative.m @ 1152:010bb2677230 feature/rv

Clean up in +rv/+time. Make the time stepping more efficient by not storing unnessecary properties in the RK-RV time steppers
author Vidar Stiernström <vidar.stiernstrom@it.uu.se>
date Tue, 05 Mar 2019 10:53:34 +0100
parents 4b42999874c0
children a4c00628a39d
comparison
equal deleted inserted replaced
1151:03ecf18d035f 1152:010bb2677230
1 classdef BdfDerivative < handle 1 classdef BdfDerivative < handle
2 properties 2 properties
3 coefficients 3 coefficients
4 end 4 end
5 methods %TBD: Decide if the BDF order should be passed in construction 5 methods
6 % and only a row of coefficients stored based on the order.
7 % There would still be an implicit dependancy on the number
8 % of vectors in v_prev and elements in coefficients.
9 % In addition, dt could be stored, but this would be
10 % inflexible if different step sizes are employed.
11 function obj = BdfDerivative() 6 function obj = BdfDerivative()
12 obj.coefficients = obj.getBdfCoefficients(); 7 obj.coefficients = obj.getBdfCoefficients();
13 end 8 end
14 % Add asserts here?
15 function DvDt = evaluate(obj, v, v_prev, dt) 9 function DvDt = evaluate(obj, v, v_prev, dt)
16 order = size(v_prev,2); 10 order = size(v_prev,2);
17 DvDt = (obj.coefficients(order,1)*v - sum(obj.coefficients(order,2:order+1).*v_prev,2))/dt; 11 DvDt = (obj.coefficients(order,1)*v - sum(obj.coefficients(order,2:order+1).*v_prev,2))/dt;
18 end 12 end
19 end 13 end