diff +rv/+time/rungekuttaRV.m @ 1017:2d7c1333bd6c feature/advectionRV

Add support for using the ODE to approximate the time derivative in the residual
author Vidar Stiernström <vidar.stiernstrom@it.uu.se>
date Tue, 11 Dec 2018 16:29:21 +0100
parents 1e437c9e5132
children 010bb2677230
line wrap: on
line diff
--- a/+rv/+time/rungekuttaRV.m	Fri Dec 07 13:11:53 2018 +0100
+++ b/+rv/+time/rungekuttaRV.m	Tue Dec 11 16:29:21 2018 +0100
@@ -3,11 +3,11 @@
 % 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, coeffs)
+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.getViscosity());
+    k(:,1) = F(v,t,RV.evaluate(v,DvDt(v)));
 
     % Compute the intermediate stages k
     for i = 2:coeffs.s
@@ -15,8 +15,8 @@
         for j = 1:i-1
             u = u + dt*coeffs.a(i,j)*k(:,j);
         end
-        RV.update(0.5*(u+v),(u-v)/(coeffs.c(i)*dt)); % Crank-Nicholson for time discretization
-        k(:,i) = F(u,t+coeffs.c(i)*dt, RV.getViscosity());
+        %RV.update(0.5*(u+v),(u-v)/(coeffs.c(i)*dt)); % Crank-Nicholson for time discretization
+        k(:,i) = F(u,t+coeffs.c(i)*dt, RV.evaluate(u,DvDt(u)));
     end
 
     % Compute the updated solution as a linear combination
@@ -25,6 +25,6 @@
     for i = 1:coeffs.s
         u = u + dt*coeffs.b(i)*k(:,i);
     end
-    RV.update(0.5*(u+v),(u-v)/dt); % Crank-Nicholson for time discretization
+    %RV.update(0.5*(u+v),(u-v)/dt); % Crank-Nicholson for time discretization
     v = u;
 end