comparison +rv/+time/RungeKuttaRvInstage.m @ 1169:d02e5b8a0b24 feature/rv

Rename RungekuttaRV time steppers. Add RungekuttaRVMultiStage time stepper
author Vidar Stiernström <vidar.stiernstrom@it.uu.se>
date Fri, 28 Jun 2019 13:13:17 +0200
parents +rv/+time/RungekuttaInteriorRv.m@010bb2677230
children 9ac86ccfd6a1
comparison
equal deleted inserted replaced
1168:af3c4eb0cbbd 1169:d02e5b8a0b24
1 classdef RungekuttaRvInstage < 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 coeffs % The coefficents used for the RK time integration
9 RV % Residual Viscosity
10 DvDt % Function for computing the time deriative used for the RV evaluation
11 end
12
13 methods
14 function obj = RungekuttaRvInstage(F, k, t0, v0, RV, DvDt, order)
15 obj.F = F;
16 obj.k = k;
17 obj.t = t0;
18 obj.v = v0;
19 obj.n = 0;
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 obj.RV = RV;
25 obj.DvDt = DvDt;
26 end
27
28 function [v, t] = getV(obj)
29 v = obj.v;
30 t = obj.t;
31 end
32
33 function state = getState(obj)
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);
37 end
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
41 function obj = step(obj)
42 obj.v = rv.time.rungekuttaRV(obj.v, obj.t, obj.k, obj.F, obj.RV, obj.DvDt, obj.coeffs);
43 obj.t = obj.t + obj.k;
44 obj.n = obj.n + 1;
45 end
46 end
47 end