comparison +rv/+time/RungekuttaExteriorRv.m @ 1030:78c75c95b7dd feature/advectionRV

Rename Rungekutta-Rv classes according to naming convention
author Vidar Stiernström <vidar.stiernstrom@it.uu.se>
date Fri, 11 Jan 2019 15:52:48 +0100
parents +rv/+time/RungekuttaExteriorRV.m@dce08a74e0ad
children 2ef20d00b386
comparison
equal deleted inserted replaced
1029:dce08a74e0ad 1030:78c75c95b7dd
1 classdef RungekuttaExteriorRv < 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
10 % Properties related to the residual viscositys
11 RV % Residual Viscosity operator
12 viscosity % Viscosity vector
13 v_prev % Solution vector at previous time levels, used for the RV evaluation
14 DvDt % Function for computing the time deriative used for the RV evaluation
15 lowerBdfOrder % Orders of the approximation of the time deriative, used for the RV evaluation.
16 % dictates which accuracy the boot-strapping should start from.
17 upperBdfOrder % Orders of the approximation of the time deriative, used for the RV evaluation.
18 % Dictates the order of accuracy used once the boot-strapping is complete.
19
20 % Convenience properties. Only for plotting
21 residual
22 dvdt
23 Df
24 end
25 methods
26
27 function obj = RungekuttaExteriorRv(F, k, t0, v0, RV, DvDt, order)
28 obj.F = F;
29 obj.k = k;
30 obj.t = t0;
31 obj.v = v0;
32 obj.n = 0;
33 % Extract the coefficients for the specified order
34 % used for the RK updates from the Butcher tableua.
35 [s,a,b,c] = time.rk.butcherTableau(order);
36 obj.coeffs = struct('s',s,'a',a,'b',b,'c',c);
37
38 obj.RV = RV;
39 obj.DvDt = DvDt;
40 obj.dvdt = obj.DvDt(obj.v);
41 [obj.viscosity, obj.Df] = RV.evaluate(obj.v,obj.dvdt);
42 obj.residual = obj.dvdt + obj.Df;
43 end
44
45 function [v, t] = getV(obj)
46 v = obj.v;
47 t = obj.t;
48 end
49
50 function state = getState(obj)
51 state = struct('v', obj.v, 'residual', obj.residual, 'dvdt', obj.dvdt, 'Df', obj.Df, 'viscosity', obj.viscosity, 't', obj.t);
52 end
53
54 function obj = step(obj)
55 obj.dvdt = obj.DvDt(obj.v);
56 [obj.viscosity, obj.Df] = obj.RV.evaluate(obj.v,obj.dvdt);
57 obj.residual = obj.dvdt + obj.Df;
58
59 % Fix the viscosity of the RHS function F
60 F_visc = @(v,t) obj.F(v,t,obj.viscosity);
61 obj.v = time.rk.rungekutta(obj.v, obj.t, obj.k, F_visc, obj.coeffs);
62 obj.t = obj.t + obj.k;
63 obj.n = obj.n + 1;
64 end
65 end
66 end