Mercurial > repos > public > sbplib
comparison +scheme/Utux.m @ 572:4a73b2aab91f feature/utux2D
Edit scheme.Utux: Add interface function. Compatible with new grids. Works with Utux_1D_interface.
author | Martin Almquist <martin.almquist@it.uu.se> |
---|---|
date | Thu, 31 Aug 2017 14:57:34 +0200 |
parents | 38c3da9675a5 |
children | efe2dbf9796e |
comparison
equal
deleted
inserted
replaced
571:38c3da9675a5 | 572:4a73b2aab91f |
---|---|
15 v0 | 15 v0 |
16 end | 16 end |
17 | 17 |
18 | 18 |
19 methods | 19 methods |
20 function obj = Utux(m,xlim,order,operator) | 20 function obj = Utux(g ,order, operator) |
21 default_arg('operator','Standard'); | 21 default_arg('operator','Standard'); |
22 | 22 |
23 %Old operators | 23 m = g.size(); |
24 % [x, h] = util.get_grid(xlim{:},m); | 24 xl = g.getBoundary('l'); |
25 %ops = sbp.Ordinary(m,h,order); | 25 xr = g.getBoundary('r'); |
26 | 26 xlim = {xl, xr}; |
27 | 27 |
28 switch operator | 28 switch operator |
29 case 'NonEquidistant' | 29 % case 'NonEquidistant' |
30 ops = sbp.D1Nonequidistant(m,xlim,order); | 30 % ops = sbp.D1Nonequidistant(m,xlim,order); |
31 obj.D1 = ops.D1; | 31 % obj.D1 = ops.D1; |
32 case 'Standard' | 32 case 'Standard' |
33 ops = sbp.D2Standard(m,xlim,order); | 33 ops = sbp.D2Standard(m,xlim,order); |
34 obj.D1 = ops.D1; | 34 obj.D1 = ops.D1; |
35 case 'Upwind' | 35 % case 'Upwind' |
36 ops = sbp.D1Upwind(m,xlim,order); | 36 % ops = sbp.D1Upwind(m,xlim,order); |
37 obj.D1 = ops.Dm; | 37 % obj.D1 = ops.Dm; |
38 otherwise | 38 otherwise |
39 error('Unvalid operator') | 39 error('Unvalid operator') |
40 end | 40 end |
41 | 41 |
42 obj.grid=ops.x; | 42 obj.grid = g; |
43 | 43 |
44 obj.H = ops.H; | 44 obj.H = ops.H; |
45 obj.Hi = ops.HI; | 45 obj.Hi = ops.HI; |
46 | 46 |
47 obj.e_l = ops.e_l; | 47 obj.e_l = ops.e_l; |
59 % type is a string specifying the type of boundary condition if there are several. | 59 % type is a string specifying the type of boundary condition if there are several. |
60 % data is a function returning the data that should be applied at the boundary. | 60 % data is a function returning the data that should be applied at the boundary. |
61 % neighbour_scheme is an instance of Scheme that should be interfaced to. | 61 % neighbour_scheme is an instance of Scheme that should be interfaced to. |
62 % neighbour_boundary is a string specifying which boundary to interface to. | 62 % neighbour_boundary is a string specifying which boundary to interface to. |
63 function [closure, penalty] = boundary_condition(obj,boundary,type,data) | 63 function [closure, penalty] = boundary_condition(obj,boundary,type,data) |
64 default_arg('type','neumann'); | 64 default_arg('type','dirichlet'); |
65 default_arg('data',0); | 65 default_arg('data',0); |
66 tau =-1*obj.e_l; | 66 tau =-1*obj.e_l; |
67 closure = obj.Hi*tau*obj.e_l'; | 67 closure = obj.Hi*tau*obj.e_l'; |
68 penalty = 0*obj.e_l; | 68 penalty = 0*obj.e_l; |
69 | 69 |
70 end | 70 end |
71 | 71 |
72 function [closure, penalty] = interface(obj,boundary,neighbour_scheme,neighbour_boundary) | 72 function [closure, penalty] = interface(obj,boundary,neighbour_scheme,neighbour_boundary) |
73 error('An interface function does not exist yet'); | 73 switch boundary |
74 % Upwind coupling | |
75 case {'l','left'} | |
76 tau = -1*obj.e_l; | |
77 closure = obj.Hi*tau*obj.e_l'; | |
78 penalty = -obj.Hi*tau*neighbour_scheme.e_r'; | |
79 case {'r','right'} | |
80 tau = 0*obj.e_r; | |
81 closure = obj.Hi*tau*obj.e_r'; | |
82 penalty = -obj.Hi*tau*neighbour_scheme.e_l'; | |
83 end | |
84 | |
74 end | 85 end |
75 | 86 |
76 function N = size(obj) | 87 function N = size(obj) |
77 N = obj.m; | 88 N = obj.m; |
78 end | 89 end |
80 end | 91 end |
81 | 92 |
82 methods(Static) | 93 methods(Static) |
83 % Calculates the matrcis need for the inteface coupling between boundary bound_u of scheme schm_u | 94 % Calculates the matrcis need for the inteface coupling between boundary bound_u of scheme schm_u |
84 % and bound_v of scheme schm_v. | 95 % and bound_v of scheme schm_v. |
85 % [uu, uv, vv, vu] = inteface_couplong(A,'r',B,'l') | 96 % [uu, uv, vv, vu] = inteface_coupling(A,'r',B,'l') |
86 function [uu, uv, vv, vu] = interface_coupling(schm_u,bound_u,schm_v,bound_v) | 97 function [uu, uv, vv, vu] = interface_coupling(schm_u,bound_u,schm_v,bound_v) |
87 [uu,uv] = schm_u.interface(bound_u,schm_v,bound_v); | 98 [uu,uv] = schm_u.interface(bound_u,schm_v,bound_v); |
88 [vv,vu] = schm_v.interface(bound_v,schm_u,bound_u); | 99 [vv,vu] = schm_v.interface(bound_v,schm_u,bound_u); |
89 end | 100 end |
90 end | 101 end |