Mercurial > repos > public > sbplib
view +rv/ResidualViscosity.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 | 4b42999874c0 |
children | 2ef20d00b386 |
line wrap: on
line source
classdef ResidualViscosity < handle properties Df % Diff op approximating the gradient of the flux f(u) waveSpeed % Wave speed at each grid point, e.g f'(u). %TBD: Better naming? Cmax % Constant controlling relative amount of upwind dissipation Cres % Constant controling relative amount of upwind dissipation h % Length scale used for scaling the viscosity. Typically grid spacing. normalization % Function used to normalize the residual such that it is amplified in the % shocks. end methods % TBD: Decide on how to treat waveSpeed. It would be nice to just pass a constant value without % wrapping it in a function. function obj = ResidualViscosity(Df, waveSpeed, Cmax, Cres, h, normalization) default_arg('normalization',@(v)norm(v-mean(v),inf)); obj.Df = Df; obj.waveSpeed = waveSpeed; obj.h = h; obj.Cmax = Cmax; obj.Cres = Cres; obj.normalization = normalization; end function [viscosity, Df] = evaluate(obj, v, dvdt) Df = obj.Df(v); viscosity = min(obj.Cmax*obj.h*abs(obj.waveSpeed(v)), obj.Cres*obj.h^2*abs(dvdt + Df)/obj.normalization(v)); end end end