comparison +rv/+time/RungekuttaInteriorRv.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 2ef20d00b386
children
comparison
equal deleted inserted replaced
1151:03ecf18d035f 1152:010bb2677230
6 v % Solution vector 6 v % Solution vector
7 n % Time level 7 n % Time level
8 coeffs % The coefficents used for the RK time integration 8 coeffs % The coefficents used for the RK time integration
9 RV % Residual Viscosity 9 RV % Residual Viscosity
10 DvDt % Function for computing the time deriative used for the RV evaluation 10 DvDt % Function for computing the time deriative used for the RV evaluation
11
12 % Convenience properties. Only for plotting
13 viscosity % Total viscosity
14 residualViscosity % Residual viscosity
15 firstOrderViscosity % first order viscosity
16 dvdt % Evaluated time derivative in residual
17 Df % Evaluated flux in residual
18 end 11 end
19 12
20 methods 13 methods
21 function obj = RungekuttaInteriorRv(F, k, t0, v0, RV, DvDt, order) 14 function obj = RungekuttaInteriorRv(F, k, t0, v0, RV, DvDt, order)
22 obj.F = F; 15 obj.F = F;
28 % used for the RK updates from the Butcher tableua. 21 % used for the RK updates from the Butcher tableua.
29 [s,a,b,c] = time.rk.butcherTableau(order); 22 [s,a,b,c] = time.rk.butcherTableau(order);
30 obj.coeffs = struct('s',s,'a',a,'b',b,'c',c); 23 obj.coeffs = struct('s',s,'a',a,'b',b,'c',c);
31 obj.RV = RV; 24 obj.RV = RV;
32 obj.DvDt = DvDt; 25 obj.DvDt = DvDt;
33 obj.dvdt = obj.DvDt(obj.v);
34 [obj.viscosity, obj.Df, obj.firstOrderViscosity, obj.residualViscosity] = obj.RV.evaluate(obj.v,obj.dvdt);
35 end 26 end
36 27
37 function [v, t] = getV(obj) 28 function [v, t] = getV(obj)
38 v = obj.v; 29 v = obj.v;
39 t = obj.t; 30 t = obj.t;
40 end 31 end
41 32
42 function state = getState(obj) 33 function state = getState(obj)
43 state = struct('v', obj.v, 'dvdt', obj.dvdt, 'Df', obj.Df, 'viscosity', obj.viscosity, 'residualViscosity', obj.residualViscosity, 'firstOrderViscosity', obj.firstOrderViscosity, 't', obj.t); 34 dvdt = obj.DvDt(obj.v);
35 [viscosity, Df, firstOrderViscosity, residualViscosity] = obj.RV.evaluate(obj.v, dvdt);
36 state = struct('v', obj.v, 'dvdt', dvdt, 'Df', Df, 'viscosity', viscosity, 'residualViscosity', residualViscosity, 'firstOrderViscosity', firstOrderViscosity, 't', obj.t);
44 end 37 end
45 38
39 % Advances the solution vector one time step using the Runge-Kutta method given by
40 % obj.coeffs, updating the Residual Viscosity in each Runge-Kutta stage
46 function obj = step(obj) 41 function obj = step(obj)
47 obj.v = rv.time.rungekuttaRV(obj.v, obj.t, obj.k, obj.F, obj.RV, obj.DvDt, obj.coeffs); 42 obj.v = rv.time.rungekuttaRV(obj.v, obj.t, obj.k, obj.F, obj.RV, obj.DvDt, obj.coeffs);
48 obj.t = obj.t + obj.k; 43 obj.t = obj.t + obj.k;
49 obj.n = obj.n + 1; 44 obj.n = obj.n + 1;
50 obj.dvdt = obj.DvDt(obj.v);
51 [obj.viscosity, obj.Df, obj.firstOrderViscosity, obj.residualViscosity] = obj.RV.evaluate(obj.v,obj.dvdt);
52 end 45 end
53 end 46 end
54 end 47 end