comparison +rv/+time/RungekuttaInteriorRV.m @ 1012:1e437c9e5132 feature/advectionRV

Create residual viscosity package +rv and generalize the ResidualViscosity class - Generalize residual viscosity, by passing user-defined flux and calculating the time derivative outside of the update. - Create separate RungekuttaRV specifically using interior RV updates - Separate the artifical dissipation operator from the scheme AdvectionRV1D so that the same scheme can be reused for creating the diff op used by the ResidualViscosity class
author Vidar Stiernström <vidar.stiernstrom@it.uu.se>
date Wed, 05 Dec 2018 13:44:10 +0100
parents
children 2d7c1333bd6c
comparison
equal deleted inserted replaced
1011:e0560bc4fb7d 1012:1e437c9e5132
1 classdef RungekuttaInteriorRV < time.Timestepper
2 properties
3 F % RHS of the ODE
4 k % Time step
5 t % Time point
6 v % Solution vector
7 n % Time level
8 coeffs % The coefficents used for the RK time integration
9 RV % Residual Viscosity
10 end
11
12 methods
13 function obj = RungekuttaInteriorRV(F, k, t0, v0, RV, order)
14 obj.F = F;
15 obj.k = k;
16 obj.t = t0;
17 obj.v = v0;
18 obj.n = 0;
19 obj.RV = RV;
20 % Extract the coefficients for the specified order
21 % used for the RK updates from the Butcher tableua.
22 [s,a,b,c] = time.rk.butcherTableau(order);
23 obj.coeffs = struct('s',s,'a',a,'b',b,'c',c);
24 end
25
26 function [v, t] = getV(obj)
27 v = obj.v;
28 t = obj.t;
29 end
30
31 function state = getState(obj)
32 [residual, u_t, grad_f] = obj.RV.getResidual();
33 state = struct('v', obj.v, 'residual', residual, 'u_t', u_t, 'grad_f', grad_f, 'viscosity', obj.RV.getViscosity(), 't', obj.t);
34 end
35
36 function obj = step(obj)
37 obj.v = rv.time.rungekuttaRV(obj.v, obj.t, obj.k, obj.F, obj.RV, obj.coeffs);
38 obj.t = obj.t + obj.k;
39 obj.n = obj.n + 1;
40 end
41 end
42 end