comparison +rv/ResidualViscosity.m @ 1033:037f203b9bf5 feature/burgers1d

Merge with branch feature/advectioRV to utilize the +rv package
author Vidar Stiernström <vidar.stiernstrom@it.uu.se>
date Thu, 17 Jan 2019 10:44:12 +0100
parents 2ef20d00b386
children a8ee5eca0e6c
comparison
equal deleted inserted replaced
854:18162a0a5bb5 1033:037f203b9bf5
1 classdef ResidualViscosity < handle
2 properties
3 Df % Diff op approximating the gradient of the flux f(u)
4 waveSpeed % Wave speed at each grid point, e.g f'(u). %TBD: Better naming?
5 Cmax % Constant controlling relative amount of upwind dissipation
6 Cres % Constant controling relative amount of upwind dissipation
7 h % Length scale used for scaling the viscosity. Typically grid spacing.
8 normalization % Function used to normalize the residual such that it is amplified in the
9 % shocks.
10 end
11
12 methods
13 % TBD: Decide on how to treat waveSpeed. It would be nice to just pass a constant value without
14 % wrapping it in a function.
15 function obj = ResidualViscosity(Df, waveSpeed, Cmax, Cres, h, normalization)
16 default_arg('normalization',@(v)norm(v-mean(v),inf));
17 obj.Df = Df;
18 obj.waveSpeed = waveSpeed;
19 obj.h = h;
20 obj.Cmax = Cmax;
21 obj.Cres = Cres;
22 obj.normalization = normalization;
23 end
24
25 function [viscosity, Df, firstOrderViscosity, residualViscosity] = evaluate(obj, v, dvdt)
26 Df = obj.Df(v);
27 firstOrderViscosity = obj.Cmax*obj.h*abs(obj.waveSpeed(v));
28 residualViscosity = obj.Cres*obj.h^2*abs(dvdt + Df)/obj.normalization(v);
29 viscosity = min(firstOrderViscosity, residualViscosity);
30 %viscosity = obj.Cmax*obj.h*abs(obj.waveSpeed(v));
31 end
32 end
33 end