comparison +time/RungekuttaRV.m @ 846:c6fcee3fcf1b feature/burgers1d

Add generalized RungeKutta and RungeKuttaRV class which extracts its coefficients from a butcher tableau, specified on the scheme.
author Vidar Stiernström <vidar.stiernstrom@it.uu.se>
date Thu, 20 Sep 2018 17:51:19 +0200
parents
children ab2e5a24ddde
comparison
equal deleted inserted replaced
845:1e057b0f2fed 846:c6fcee3fcf1b
1 classdef RungekuttaRV < time.Timestepper
2 properties
3 F % RHS of the ODE
4 k % Time step
5 t % Time point
6 v % Solution vector
7 n % Time level
8 RV % Residual Viscosity
9 coeffs % The coefficents used for the RK time integration
10 end
11
12 methods
13 function obj = RungekuttaRV(F, k, t0, v0, RV, order)
14 obj.F = F;
15 obj.k = k;
16 obj.t = t0;
17 obj.v = v0;
18 obj.n = 0;
19 obj.RV = RV;
20 % Extract the coefficients for the specified order
21 % used for the RK updates from the Butcher tableua.
22 [s,a,b,c] = time.rk.butcherTableau(order);
23 obj.coeffs = struct('s',s,'a',a,'b',b,'c',c);
24 end
25
26 function [v, t] = getV(obj)
27 v = obj.v;
28 t = obj.t;
29 end
30
31 function state = getState(obj)
32 [residual, u_t, f_x] = obj.RV.getResidual();
33 state = struct('v', obj.v, 'residual', residual, 'u_t', u_t, 'f_x', f_x, 'viscosity', obj.RV.getViscosity(), 't', obj.t);
34 end
35
36 function obj = step(obj)
37 obj.v = time.rk.rungekuttaRV(obj.v, obj.t, obj.k, obj.F, obj.RV, obj.coeffs);
38 obj.t = obj.t + obj.k;
39 obj.n = obj.n + 1;
40 end
41 end
42
43
44 methods (Static)
45 function k = getTimeStep(lambda)
46 k = rk4.get_rk4_time_step(lambda);
47 end
48 end
49
50 end