Mercurial > repos > public > sbplib
changeset 1165:745ae0d134c9 feature/rv
Pass RHS of unstabilized ode to RKExterirorRvMg
author | Vidar Stiernström <vidar.stiernstrom@it.uu.se> |
---|---|
date | Thu, 27 Jun 2019 17:14:30 +0200 |
parents | fc2631ba4da5 |
children | 17bb3c46472c |
files | +rv/+time/RungekuttaExteriorRvMg.m |
diffstat | 1 files changed, 8 insertions(+), 7 deletions(-) [+] |
line wrap: on
line diff
--- a/+rv/+time/RungekuttaExteriorRvMg.m Thu Jun 27 17:13:28 2019 +0200 +++ b/+rv/+time/RungekuttaExteriorRvMg.m Thu Jun 27 17:14:30 2019 +0200 @@ -1,6 +1,7 @@ classdef RungekuttaExteriorRvMg < time.Timestepper properties - F % RHS of the ODE + F % RHS of the ODE + F_unstable % RHS of the unstabalized ODE k % Time step t % Time point v % Solution vector @@ -13,8 +14,9 @@ end methods - function obj = RungekuttaExteriorRvMg(F, k, t0, v0, RV, DvDt, order) + function obj = RungekuttaExteriorRvMg(F, F_unstable, k, t0, v0, RV, DvDt, order) obj.F = F; + obj.F_unstable = F_unstable; obj.k = k; obj.t = t0; obj.v = v0; @@ -44,19 +46,18 @@ function state = getState(obj) dvdt = obj.DvDt(obj.v_unstable); [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); + state = struct('v', obj.v, 'dvdt', dvdt, 'Df', Df, 'viscosity', obj.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) - % Fix the viscosity of the RHS function F m = length(obj.viscosity); + obj.v_unstable = obj.rkScheme(obj.v, obj.t, obj.k, obj.F_unstable); + obj.viscosity = obj.RV.evaluateViscosity(obj.v, obj.DvDt(obj.v_unstable)); + % Fix the viscosity of the stabilized RHS F_stable = @(v,t) obj.F(v,t,spdiags(obj.viscosity,0,m,m)); - F_unstable = @(v,t) obj.F(v,t,spdiags(0*obj.viscosity,0,m,m)); obj.v = obj.rkScheme(obj.v, obj.t, obj.k, F_stable); - obj.v_unstable = obj.rkScheme(obj.v, obj.t, obj.k, F_unstable); - obj.viscosity = obj.RV.evaluateViscosity(obj.v, obj.DvDt(obj.v_unstable)); obj.t = obj.t + obj.k; obj.n = obj.n + 1; end