changeset 1181:9ac86ccfd6a1 feature/rv

Move instage rungekutta time stepping to RungekuttaRvInstage
author Vidar Stiernström <vidar.stiernstrom@it.uu.se>
date Fri, 05 Jul 2019 16:51:05 +0200
parents beecb580c5bf
children f35ff0861d5a
files +rv/+time/RungeKuttaRvInstage.m +rv/+time/rungekuttaRV.m
diffstat 2 files changed, 32 insertions(+), 28 deletions(-) [+]
line wrap: on
line diff
--- a/+rv/+time/RungeKuttaRvInstage.m	Fri Jul 05 16:49:19 2019 +0200
+++ b/+rv/+time/RungeKuttaRvInstage.m	Fri Jul 05 16:51:05 2019 +0200
@@ -44,4 +44,36 @@
             obj.n = obj.n + 1;
         end
     end
+
+    % Takes one time step of size dt using the rungekutta method
+    % starting from v and where the function F(v,t,RV) gives the
+    % time derivatives. coeffs is a struct holding the RK coefficients
+    % for the specific method. RV is the residual viscosity which is updated
+    % in between the stages and after the updated solution is computed.
+    methods (Static)
+    function v = rungekuttaRV(v, t , dt, F, RV, DvDt, coeffs)
+        % Move one stage outside to avoid branching for updating the
+        % residual inside the loop.
+        k = zeros(length(v), coeffs.s);
+        k(:,1) = F(v,t,RV.evaluateViscosity(v,DvDt(v)));
+
+        % Compute the intermediate stages k
+        for i = 2:coeffs.s
+            u = v;
+            for j = 1:i-1
+                u = u + dt*coeffs.a(i,j)*k(:,j);
+            end
+            k(:,i) = F(u,t+coeffs.c(i)*dt, RV.evaluateViscosity(u,DvDt(u)));
+        end
+
+        % Compute the updated solution as a linear combination
+        % of the intermediate stages.
+        u = v;
+        for i = 1:coeffs.s
+            u = u + dt*coeffs.b(i)*k(:,i);
+        end
+        v = u;
+    end
+
+
 end
\ No newline at end of file
--- a/+rv/+time/rungekuttaRV.m	Fri Jul 05 16:49:19 2019 +0200
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,28 +0,0 @@
-% Takes one time step of size dt using the rungekutta method
-% starting from v and where the function F(v,t,RV) gives the
-% time derivatives. coeffs is a struct holding the RK coefficients
-% for the specific method. RV is the residual viscosity which is updated
-% in between the stages and after the updated solution is computed.
-function v = rungekuttaRV(v, t , dt, F, RV, DvDt, coeffs)
-    % Move one stage outside to avoid branching for updating the
-    % residual inside the loop.
-    k = zeros(length(v), coeffs.s);
-    k(:,1) = F(v,t,RV.evaluateViscosity(v,DvDt(v)));
-
-    % Compute the intermediate stages k
-    for i = 2:coeffs.s
-        u = v;
-        for j = 1:i-1
-            u = u + dt*coeffs.a(i,j)*k(:,j);
-        end
-        k(:,i) = F(u,t+coeffs.c(i)*dt, RV.evaluateViscosity(u,DvDt(u)));
-    end
-
-    % Compute the updated solution as a linear combination
-    % of the intermediate stages.
-    u = v;
-    for i = 1:coeffs.s
-        u = u + dt*coeffs.b(i)*k(:,i);
-    end
-    v = u;
-end