Mercurial > repos > public > sbplib
changeset 1027:d6ab5ceba496 feature/advectionRV
Support variable wave speed and upwind operators in Utux
author | Vidar Stiernström <vidar.stiernstrom@it.uu.se> |
---|---|
date | Mon, 07 Jan 2019 16:35:04 +0100 |
parents | 44c3ea38097e |
children | 5df155ededcd |
files | +scheme/Utux.m |
diffstat | 1 files changed, 42 insertions(+), 9 deletions(-) [+] |
line wrap: on
line diff
diff -r 44c3ea38097e -r d6ab5ceba496 +scheme/Utux.m --- a/+scheme/Utux.m Mon Jan 07 16:32:40 2019 +0100 +++ b/+scheme/Utux.m Mon Jan 07 16:35:04 2019 +0100 @@ -5,6 +5,9 @@ grid % Grid order % Order accuracy for the approximation + a % Wave speed + % Can either be a constant or function handle. + H % Discrete norm D @@ -12,13 +15,21 @@ Hi e_l e_r - v0 end methods - function obj = Utux(g, order, opSet) + function obj = Utux(g, order, opSet, a, fluxSplitting) default_arg('opSet',@sbp.D2Standard); + default_arg('a',1); + default_arg('fluxSplitting',[]); + + assertType(g, 'grid.Cartesian'); + if isa(a, 'function_handle') + obj.a = spdiag(grid.evalOn(g, a)); + else + obj.a = a; + end m = g.size(); xl = g.getBoundary('l'); @@ -26,7 +37,15 @@ xlim = {xl, xr}; ops = opSet(m, xlim, order); - obj.D1 = ops.D1; + + if (isequal(opSet, @sbp.D1Upwind)) + obj.D1 = (ops.Dp + ops.Dm)/2; + DissOp = (ops.Dm - ops.Dp)/2; + obj.D = -(obj.a*obj.D1 + fluxSplitting*DissOp); + else + obj.D1 = ops.D1; + obj.D = -obj.a*obj.D1; + end obj.grid = g; @@ -35,12 +54,10 @@ obj.e_l = ops.e_l; obj.e_r = ops.e_r; - obj.D = -obj.D1; obj.m = m; obj.h = ops.h; obj.order = order; - end % Closure functions return the opertors applied to the own doamin to close the boundary % Penalty functions return the opertors to force the solution. In the case of an interface it returns the operator applied to the other doamin. @@ -51,8 +68,24 @@ % neighbour_boundary is a string specifying which boundary to interface to. function [closure, penalty] = boundary_condition(obj,boundary,type) default_arg('type','dirichlet'); - tau =-1*obj.e_l; - closure = obj.Hi*tau*obj.e_l'; + sigma_left = -1; % Scalar penalty parameter for left boundary + sigma_right = 1; % Scalar penalty parameter for right boundary + switch boundary + % Can only specify boundary condition where there is inflow + % Extract the postivie resp. negative part of a, for the left + % resp. right boundary, and set other values of a to zero. + % Then the closure will effectively only contribute to inflow boundaries + case {'l','L','left','Left'} + a_inflow = obj.a; + a_inflow(a_inflow < 0) = 0; + tau = sigma_left*a_inflow*obj.e_l; + closure = obj.Hi*tau*obj.e_l'; + case {'r','R','right','Right'} + a_inflow = obj.a; + a_inflow(a_inflow > 0) = 0; + tau = sigma_right*a_inflow*obj.e_r; + closure = obj.Hi*tau*obj.e_r'; + end penalty = -obj.Hi*tau; end @@ -61,11 +94,11 @@ switch boundary % Upwind coupling case {'l','left'} - tau = -1*obj.e_l; + tau = -1*obj.a*obj.e_l; closure = obj.Hi*tau*obj.e_l'; penalty = -obj.Hi*tau*neighbour_scheme.e_r'; case {'r','right'} - tau = 0*obj.e_r; + tau = 0*obj.a*obj.e_r; closure = obj.Hi*tau*obj.e_r'; penalty = -obj.Hi*tau*neighbour_scheme.e_l'; end