Mercurial > repos > public > sbplib
comparison +rv/+time/RungekuttaExteriorRvBdf.m @ 1031:2ef20d00b386 feature/advectionRV
For easier comparison, return both the first order and residual viscosity when evaluating the residual. Add the first order and residual viscosity to the state of the RungekuttaRV time steppers
author | Vidar Stiernström <vidar.stiernstrom@it.uu.se> |
---|---|
date | Thu, 17 Jan 2019 10:25:06 +0100 |
parents | dce08a74e0ad |
children | 010bb2677230 |
comparison
equal
deleted
inserted
replaced
1030:78c75c95b7dd | 1031:2ef20d00b386 |
---|---|
7 n % Time level | 7 n % Time level |
8 coeffs % The coefficents used for the RK time integration | 8 coeffs % The coefficents used for the RK time integration |
9 | 9 |
10 % Properties related to the residual viscositys | 10 % Properties related to the residual viscositys |
11 RV % Residual Viscosity operator | 11 RV % Residual Viscosity operator |
12 viscosity % Viscosity vector | |
13 v_prev % Solution vector at previous time levels, used for the RV evaluation | 12 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 | 13 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. | 14 lowerBdfOrder % Orders of the approximation of the time deriative, used for the RV evaluation. |
16 % dictates which accuracy the boot-strapping should start from. | 15 % dictates which accuracy the boot-strapping should start from. |
17 upperBdfOrder % Orders of the approximation of the time deriative, used for the RV evaluation. | 16 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. | 17 % Dictates the order of accuracy used once the boot-strapping is complete. |
19 | 18 |
20 % Convenience properties. Only for plotting | 19 % Convenience properties. Only for plotting |
21 residual | 20 viscosity % Total viscosity |
22 dvdt | 21 residualViscosity % Residual viscosity |
23 Df | 22 firstOrderViscosity % first order viscosity |
23 dvdt % Evaluated time derivative in residual | |
24 Df % Evaluated flux in residual | |
24 end | 25 end |
25 methods | 26 methods |
26 function obj = RungekuttaExteriorRvBdf(F, k, t0, v0, RV, rkOrder, bdfOrders) | 27 function obj = RungekuttaExteriorRvBdf(F, k, t0, v0, RV, rkOrder, bdfOrders) |
27 obj.F = F; | 28 obj.F = F; |
28 obj.k = k; | 29 obj.k = k; |
45 obj.upperBdfOrder = bdfOrders.upperBdfOrder; | 46 obj.upperBdfOrder = bdfOrders.upperBdfOrder; |
46 assert((obj.lowerBdfOrder >= 1) && (obj.upperBdfOrder <= 6)); | 47 assert((obj.lowerBdfOrder >= 1) && (obj.upperBdfOrder <= 6)); |
47 obj.v_prev = []; | 48 obj.v_prev = []; |
48 obj.DvDt = rv.time.BdfDerivative(); | 49 obj.DvDt = rv.time.BdfDerivative(); |
49 obj.viscosity = zeros(size(v0)); | 50 obj.viscosity = zeros(size(v0)); |
50 obj.residual = zeros(size(v0)); | 51 obj.firstOrderViscosity = zeros(size(v0)); |
52 obj.residualViscosity = zeros(size(v0)); | |
51 obj.dvdt = zeros(size(v0)); | 53 obj.dvdt = zeros(size(v0)); |
52 obj.Df = zeros(size(v0)); | 54 obj.Df = zeros(size(v0)); |
53 end | 55 end |
54 | 56 |
55 function [v, t] = getV(obj) | 57 function [v, t] = getV(obj) |
56 v = obj.v; | 58 v = obj.v; |
57 t = obj.t; | 59 t = obj.t; |
58 end | 60 end |
59 | 61 |
60 function state = getState(obj) | 62 function state = getState(obj) |
61 state = struct('v', obj.v, 'residual', obj.residual, 'dvdt', obj.dvdt, 'Df', obj.Df, 'viscosity', obj.viscosity, 't', obj.t); | 63 state = struct('v', obj.v, 'dvdt', obj.dvdt, 'Df', obj.Df, 'viscosity', obj.viscosity, 'residualViscosity', obj.residualViscosity, 'firstOrderViscosity', obj.firstOrderViscosity, 't', obj.t); |
62 end | 64 end |
63 | 65 |
64 function obj = step(obj) | 66 function obj = step(obj) |
65 % Store current time level and update v_prev | 67 % Store current time level and update v_prev |
66 numStoredStages = size(obj.v_prev,2); | 68 numStoredStages = size(obj.v_prev,2); |
79 obj.n = obj.n + 1; | 81 obj.n = obj.n + 1; |
80 | 82 |
81 %Calculate dvdt and evaluate RV for the new time level | 83 %Calculate dvdt and evaluate RV for the new time level |
82 if ((numStoredStages >= obj.lowerBdfOrder) && (numStoredStages <= obj.upperBdfOrder)) | 84 if ((numStoredStages >= obj.lowerBdfOrder) && (numStoredStages <= obj.upperBdfOrder)) |
83 obj.dvdt = obj.DvDt.evaluate(obj.v, obj.v_prev, obj.k); | 85 obj.dvdt = obj.DvDt.evaluate(obj.v, obj.v_prev, obj.k); |
84 [obj.viscosity, obj.Df] = obj.RV.evaluate(obj.v,obj.dvdt); | 86 [obj.viscosity, obj.Df, obj.firstOrderViscosity, obj.residualViscosity] = obj.RV.evaluate(obj.v,obj.dvdt); |
85 obj.residual = obj.dvdt + obj.Df; | |
86 end | 87 end |
87 end | 88 end |
88 end | 89 end |
89 end | 90 end |