comparison +time/Rungekutta4RV.m @ 815:fae41958af4f feature/burgers1d

Add support for artificial viscosity to the 1d burgers scheme. - Add support for artificial viscosity by parametrizing the discretization operator and boundary closure on the viscosity. - Add a time stepper which evaluates and updates the residual viscosity of the solution.
author Vidar Stiernstrom <vidar.stiernstrom@it.uu.se>
date Thu, 06 Sep 2018 12:43:51 +0200
parents
children d0934d1143b7
comparison
equal deleted inserted replaced
814:3a5e635a93fd 815:fae41958af4f
1 classdef Rungekutta4RV < time.Timestepper
2 properties
3 F
4 k
5 t
6 v
7 m
8 n
9
10 % Additional members used for the RV update
11 RV
12 end
13
14
15 methods
16 function obj = Rungekutta4RV(F, k, t0, v0, RV)
17 obj.F = F;
18 obj.k = k;
19 obj.t = t0;
20 obj.v = v0;
21 obj.m = length(v0);
22 obj.n = 0;
23 obj.RV = RV;
24 end
25
26 function [v, t] = getV(obj)
27 v = obj.v;
28 t = obj.t;
29 end
30
31 function [residual, viscosity, t] = getRV(obj)
32 residual = obj.RV.getResidual();
33 viscosity = obj.RV.getViscosity();
34 t = obj.t;
35 end
36
37 function obj = step(obj)
38 v_prev = obj.v;
39 F = @(v,t) obj.F(v, t, obj.RV.getViscosity());
40 obj.v = time.rk4.rungekutta_4(obj.v, obj.t, obj.k, F);
41 obj.t = obj.t + obj.k;
42 obj.n = obj.n + 1;
43 obj.RV.update(obj.v, v_prev, obj.k);
44 end
45 end
46
47
48 methods (Static)
49 function k = getTimeStep(lambda)
50 k = rk4.get_rk4_time_step(lambda);
51 end
52 end
53
54 end