Mercurial > repos > public > sbplib
comparison +time/Rungekutta4RV.m @ 835:008496ca38f3 feature/burgers1d
Compute the residual in between each runge-kutta stage.
Note: It is not clear whether the correct residual is used when computing the stages. Must investigate further.
author | Vidar Stiernström <vidar.stiernstrom@it.uu.se> |
---|---|
date | Thu, 13 Sep 2018 18:14:54 +0200 |
parents | d0934d1143b7 |
children | 1e057b0f2fed |
comparison
equal
deleted
inserted
replaced
834:f1f0bf087e1c | 835:008496ca38f3 |
---|---|
26 function [v, t] = getV(obj) | 26 function [v, t] = getV(obj) |
27 v = obj.v; | 27 v = obj.v; |
28 t = obj.t; | 28 t = obj.t; |
29 end | 29 end |
30 | 30 |
31 function [residual, viscosity, t] = getRV(obj) | 31 function state = getState(obj) |
32 residual = obj.RV.getResidual(); | 32 [residual, u_t, f_x] = obj.RV.getResidual(); |
33 viscosity = obj.RV.getViscosity(); | 33 state = struct('v', obj.v, 'residual', residual, 'u_t', u_t, 'f_x', f_x, 'viscosity', obj.RV.getViscosity(), 't', obj.t); |
34 t = obj.t; | |
35 end | 34 end |
36 | 35 |
37 function obj = step(obj) | 36 function obj = step(obj) |
38 v_prev = obj.v; | 37 obj.v = time.rk4.rungekutta_4RV(obj.v, obj.t, obj.k, obj.F, obj.RV); |
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.RV.update(obj.v, v_prev, obj.k); | |
42 obj.t = obj.t + obj.k; | 38 obj.t = obj.t + obj.k; |
43 obj.n = obj.n + 1; | 39 obj.n = obj.n + 1; |
44 end | 40 end |
45 end | 41 end |
46 | 42 |