diff +rv/+time/RungekuttaExteriorRv.m @ 1152:010bb2677230 feature/rv

Clean up in +rv/+time. Make the time stepping more efficient by not storing unnessecary properties in the RK-RV time steppers
author Vidar Stiernström <vidar.stiernstrom@it.uu.se>
date Tue, 05 Mar 2019 10:53:34 +0100
parents 2ef20d00b386
children 3108963cc42c
line wrap: on
line diff
--- a/+rv/+time/RungekuttaExteriorRv.m	Mon Feb 18 09:00:00 2019 +0100
+++ b/+rv/+time/RungekuttaExteriorRv.m	Tue Mar 05 10:53:34 2019 +0100
@@ -6,22 +6,8 @@
         v       % Solution vector
         n       % Time level
         coeffs  % The coefficents used for the RK time integration
-        
-        % Properties related to the residual viscositys
         RV              % Residual Viscosity operator
-        v_prev          % Solution vector at previous time levels, used for the RV evaluation
         DvDt            % Function for computing the time deriative used for the RV evaluation
-        lowerBdfOrder   % Orders of the approximation of the time deriative, used for the RV evaluation.
-                        % dictates which accuracy the boot-strapping should start from.
-        upperBdfOrder   % Orders of the approximation of the time deriative, used for the RV evaluation.
-                        % Dictates the order of accuracy used once the boot-strapping is complete.
-        
-        % Convenience properties. Only for plotting
-        viscosity % Total viscosity
-        residualViscosity % Residual viscosity
-        firstOrderViscosity % first order viscosity
-        dvdt % Evaluated time derivative in residual
-        Df % Evaluated flux in residual
     end
     methods
 
@@ -38,8 +24,6 @@
         
             obj.RV = RV;
             obj.DvDt = DvDt;
-            obj.dvdt = obj.DvDt(obj.v);
-            [obj.viscosity,  obj.Df, obj.firstOrderViscosity, obj.residualViscosity] = RV.evaluate(obj.v,obj.dvdt);
         end
 
         function [v, t] = getV(obj)
@@ -48,15 +32,16 @@
         end
 
         function state = getState(obj)
-            state = struct('v', obj.v, 'dvdt', obj.dvdt, 'Df', obj.Df, 'viscosity', obj.viscosity, 'residualViscosity', obj.residualViscosity, 'firstOrderViscosity', obj.firstOrderViscosity, 't', obj.t);
+            dvdt = obj.DvDt(obj.v);
+            [viscosity, Df, firstOrderViscosity, residualViscosity] = obj.RV.evaluate(obj.v, dvdt);
+            state = struct('v', obj.v, 'dvdt', dvdt, 'Df', Df, 'viscosity', viscosity, 'residualViscosity', residualViscosity, 'firstOrderViscosity', firstOrderViscosity, 't', obj.t);
         end
 
+        % Advances the solution vector one time step using the Runge-Kutta method given by
+        % obj.coeffs, using a fixed residual viscosity for the Runge-Kutta substeps
         function obj = step(obj)            
-            obj.dvdt = obj.DvDt(obj.v);
-            [obj.viscosity, obj.Df, obj.firstOrderViscosity, obj.residualViscosity] = obj.RV.evaluate(obj.v,obj.dvdt);
-
             % Fix the viscosity of the RHS function F
-            F_visc = @(v,t) obj.F(v,t,obj.viscosity);
+            F_visc = @(v,t) obj.F(v,t,obj.RV.evaluateViscosity(obj.v, obj.DvDt(obj.v)));
             obj.v = time.rk.rungekutta(obj.v, obj.t, obj.k, F_visc, obj.coeffs);
             obj.t = obj.t + obj.k;
             obj.n = obj.n + 1;