Mercurial > repos > public > sbplib
annotate +scheme/Utux.m @ 719:b3f8fb9cefd2 feature/utux2D
Add interpolation to Schrödinger 2D scheme.
| author | Martin Almquist <malmquist@stanford.edu> |
|---|---|
| date | Sun, 11 Mar 2018 21:39:49 -0700 |
| parents | efe2dbf9796e |
| children | 459eeb99130f |
| rev | line source |
|---|---|
| 270 | 1 classdef Utux < scheme.Scheme |
| 2 properties | |
| 3 m % Number of points in each direction, possibly a vector | |
| 4 h % Grid spacing | |
|
571
38c3da9675a5
Bug fixes in scheme.Utux
Martin Almquist <martin.almquist@it.uu.se>
parents:
367
diff
changeset
|
5 grid % Grid |
| 270 | 6 order % Order accuracy for the approximation |
| 7 | |
| 8 H % Discrete norm | |
| 9 D | |
| 10 | |
| 11 D1 | |
| 12 Hi | |
| 13 e_l | |
| 14 e_r | |
| 15 v0 | |
| 16 end | |
| 17 | |
| 18 | |
| 19 methods | |
|
572
4a73b2aab91f
Edit scheme.Utux: Add interface function. Compatible with new grids. Works with Utux_1D_interface.
Martin Almquist <martin.almquist@it.uu.se>
parents:
571
diff
changeset
|
20 function obj = Utux(g ,order, operator) |
|
571
38c3da9675a5
Bug fixes in scheme.Utux
Martin Almquist <martin.almquist@it.uu.se>
parents:
367
diff
changeset
|
21 default_arg('operator','Standard'); |
|
572
4a73b2aab91f
Edit scheme.Utux: Add interface function. Compatible with new grids. Works with Utux_1D_interface.
Martin Almquist <martin.almquist@it.uu.se>
parents:
571
diff
changeset
|
22 |
|
4a73b2aab91f
Edit scheme.Utux: Add interface function. Compatible with new grids. Works with Utux_1D_interface.
Martin Almquist <martin.almquist@it.uu.se>
parents:
571
diff
changeset
|
23 m = g.size(); |
|
4a73b2aab91f
Edit scheme.Utux: Add interface function. Compatible with new grids. Works with Utux_1D_interface.
Martin Almquist <martin.almquist@it.uu.se>
parents:
571
diff
changeset
|
24 xl = g.getBoundary('l'); |
|
4a73b2aab91f
Edit scheme.Utux: Add interface function. Compatible with new grids. Works with Utux_1D_interface.
Martin Almquist <martin.almquist@it.uu.se>
parents:
571
diff
changeset
|
25 xr = g.getBoundary('r'); |
|
4a73b2aab91f
Edit scheme.Utux: Add interface function. Compatible with new grids. Works with Utux_1D_interface.
Martin Almquist <martin.almquist@it.uu.se>
parents:
571
diff
changeset
|
26 xlim = {xl, xr}; |
|
4a73b2aab91f
Edit scheme.Utux: Add interface function. Compatible with new grids. Works with Utux_1D_interface.
Martin Almquist <martin.almquist@it.uu.se>
parents:
571
diff
changeset
|
27 |
|
367
05947fc2505c
Added different operators to Utux
Ylva Rydin <ylva.rydin@telia.com>
parents:
354
diff
changeset
|
28 switch operator |
|
572
4a73b2aab91f
Edit scheme.Utux: Add interface function. Compatible with new grids. Works with Utux_1D_interface.
Martin Almquist <martin.almquist@it.uu.se>
parents:
571
diff
changeset
|
29 % case 'NonEquidistant' |
|
4a73b2aab91f
Edit scheme.Utux: Add interface function. Compatible with new grids. Works with Utux_1D_interface.
Martin Almquist <martin.almquist@it.uu.se>
parents:
571
diff
changeset
|
30 % ops = sbp.D1Nonequidistant(m,xlim,order); |
|
4a73b2aab91f
Edit scheme.Utux: Add interface function. Compatible with new grids. Works with Utux_1D_interface.
Martin Almquist <martin.almquist@it.uu.se>
parents:
571
diff
changeset
|
31 % obj.D1 = ops.D1; |
|
367
05947fc2505c
Added different operators to Utux
Ylva Rydin <ylva.rydin@telia.com>
parents:
354
diff
changeset
|
32 case 'Standard' |
|
354
dbac99d2c318
Removed inv(Vi) to save time
Ylva Rydin <ylva.rydin@telia.com>
parents:
352
diff
changeset
|
33 ops = sbp.D2Standard(m,xlim,order); |
|
367
05947fc2505c
Added different operators to Utux
Ylva Rydin <ylva.rydin@telia.com>
parents:
354
diff
changeset
|
34 obj.D1 = ops.D1; |
|
572
4a73b2aab91f
Edit scheme.Utux: Add interface function. Compatible with new grids. Works with Utux_1D_interface.
Martin Almquist <martin.almquist@it.uu.se>
parents:
571
diff
changeset
|
35 % case 'Upwind' |
|
4a73b2aab91f
Edit scheme.Utux: Add interface function. Compatible with new grids. Works with Utux_1D_interface.
Martin Almquist <martin.almquist@it.uu.se>
parents:
571
diff
changeset
|
36 % ops = sbp.D1Upwind(m,xlim,order); |
|
4a73b2aab91f
Edit scheme.Utux: Add interface function. Compatible with new grids. Works with Utux_1D_interface.
Martin Almquist <martin.almquist@it.uu.se>
parents:
571
diff
changeset
|
37 % obj.D1 = ops.Dm; |
|
367
05947fc2505c
Added different operators to Utux
Ylva Rydin <ylva.rydin@telia.com>
parents:
354
diff
changeset
|
38 otherwise |
|
05947fc2505c
Added different operators to Utux
Ylva Rydin <ylva.rydin@telia.com>
parents:
354
diff
changeset
|
39 error('Unvalid operator') |
|
05947fc2505c
Added different operators to Utux
Ylva Rydin <ylva.rydin@telia.com>
parents:
354
diff
changeset
|
40 end |
|
571
38c3da9675a5
Bug fixes in scheme.Utux
Martin Almquist <martin.almquist@it.uu.se>
parents:
367
diff
changeset
|
41 |
|
572
4a73b2aab91f
Edit scheme.Utux: Add interface function. Compatible with new grids. Works with Utux_1D_interface.
Martin Almquist <martin.almquist@it.uu.se>
parents:
571
diff
changeset
|
42 obj.grid = g; |
| 270 | 43 |
|
290
d32f674bcbe5
A first attempt to make a general scheme fo hyperbolic systems
Ylva Rydin <ylva.rydin@telia.com>
parents:
270
diff
changeset
|
44 obj.H = ops.H; |
|
d32f674bcbe5
A first attempt to make a general scheme fo hyperbolic systems
Ylva Rydin <ylva.rydin@telia.com>
parents:
270
diff
changeset
|
45 obj.Hi = ops.HI; |
|
d32f674bcbe5
A first attempt to make a general scheme fo hyperbolic systems
Ylva Rydin <ylva.rydin@telia.com>
parents:
270
diff
changeset
|
46 |
|
d32f674bcbe5
A first attempt to make a general scheme fo hyperbolic systems
Ylva Rydin <ylva.rydin@telia.com>
parents:
270
diff
changeset
|
47 obj.e_l = ops.e_l; |
|
d32f674bcbe5
A first attempt to make a general scheme fo hyperbolic systems
Ylva Rydin <ylva.rydin@telia.com>
parents:
270
diff
changeset
|
48 obj.e_r = ops.e_r; |
|
571
38c3da9675a5
Bug fixes in scheme.Utux
Martin Almquist <martin.almquist@it.uu.se>
parents:
367
diff
changeset
|
49 obj.D = -obj.D1; |
| 270 | 50 |
| 51 obj.m = m; | |
|
290
d32f674bcbe5
A first attempt to make a general scheme fo hyperbolic systems
Ylva Rydin <ylva.rydin@telia.com>
parents:
270
diff
changeset
|
52 obj.h = ops.h; |
| 270 | 53 obj.order = order; |
| 54 | |
| 55 end | |
| 56 % Closure functions return the opertors applied to the own doamin to close the boundary | |
| 57 % Penalty functions return the opertors to force the solution. In the case of an interface it returns the operator applied to the other doamin. | |
| 58 % boundary is a string specifying the boundary e.g. 'l','r' or 'e','w','n','s'. | |
| 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. | |
| 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. | |
|
573
efe2dbf9796e
Remove data input from boundary condition function
Martin Almquist <martin.almquist@it.uu.se>
parents:
572
diff
changeset
|
63 function [closure, penalty] = boundary_condition(obj,boundary,type) |
|
572
4a73b2aab91f
Edit scheme.Utux: Add interface function. Compatible with new grids. Works with Utux_1D_interface.
Martin Almquist <martin.almquist@it.uu.se>
parents:
571
diff
changeset
|
64 default_arg('type','dirichlet'); |
|
290
d32f674bcbe5
A first attempt to make a general scheme fo hyperbolic systems
Ylva Rydin <ylva.rydin@telia.com>
parents:
270
diff
changeset
|
65 tau =-1*obj.e_l; |
| 270 | 66 closure = obj.Hi*tau*obj.e_l'; |
|
573
efe2dbf9796e
Remove data input from boundary condition function
Martin Almquist <martin.almquist@it.uu.se>
parents:
572
diff
changeset
|
67 penalty = -obj.Hi*tau; |
| 270 | 68 |
| 69 end | |
| 70 | |
| 71 function [closure, penalty] = interface(obj,boundary,neighbour_scheme,neighbour_boundary) | |
|
572
4a73b2aab91f
Edit scheme.Utux: Add interface function. Compatible with new grids. Works with Utux_1D_interface.
Martin Almquist <martin.almquist@it.uu.se>
parents:
571
diff
changeset
|
72 switch boundary |
|
4a73b2aab91f
Edit scheme.Utux: Add interface function. Compatible with new grids. Works with Utux_1D_interface.
Martin Almquist <martin.almquist@it.uu.se>
parents:
571
diff
changeset
|
73 % Upwind coupling |
|
4a73b2aab91f
Edit scheme.Utux: Add interface function. Compatible with new grids. Works with Utux_1D_interface.
Martin Almquist <martin.almquist@it.uu.se>
parents:
571
diff
changeset
|
74 case {'l','left'} |
|
4a73b2aab91f
Edit scheme.Utux: Add interface function. Compatible with new grids. Works with Utux_1D_interface.
Martin Almquist <martin.almquist@it.uu.se>
parents:
571
diff
changeset
|
75 tau = -1*obj.e_l; |
|
4a73b2aab91f
Edit scheme.Utux: Add interface function. Compatible with new grids. Works with Utux_1D_interface.
Martin Almquist <martin.almquist@it.uu.se>
parents:
571
diff
changeset
|
76 closure = obj.Hi*tau*obj.e_l'; |
|
4a73b2aab91f
Edit scheme.Utux: Add interface function. Compatible with new grids. Works with Utux_1D_interface.
Martin Almquist <martin.almquist@it.uu.se>
parents:
571
diff
changeset
|
77 penalty = -obj.Hi*tau*neighbour_scheme.e_r'; |
|
4a73b2aab91f
Edit scheme.Utux: Add interface function. Compatible with new grids. Works with Utux_1D_interface.
Martin Almquist <martin.almquist@it.uu.se>
parents:
571
diff
changeset
|
78 case {'r','right'} |
|
4a73b2aab91f
Edit scheme.Utux: Add interface function. Compatible with new grids. Works with Utux_1D_interface.
Martin Almquist <martin.almquist@it.uu.se>
parents:
571
diff
changeset
|
79 tau = 0*obj.e_r; |
|
4a73b2aab91f
Edit scheme.Utux: Add interface function. Compatible with new grids. Works with Utux_1D_interface.
Martin Almquist <martin.almquist@it.uu.se>
parents:
571
diff
changeset
|
80 closure = obj.Hi*tau*obj.e_r'; |
|
4a73b2aab91f
Edit scheme.Utux: Add interface function. Compatible with new grids. Works with Utux_1D_interface.
Martin Almquist <martin.almquist@it.uu.se>
parents:
571
diff
changeset
|
81 penalty = -obj.Hi*tau*neighbour_scheme.e_l'; |
|
4a73b2aab91f
Edit scheme.Utux: Add interface function. Compatible with new grids. Works with Utux_1D_interface.
Martin Almquist <martin.almquist@it.uu.se>
parents:
571
diff
changeset
|
82 end |
|
4a73b2aab91f
Edit scheme.Utux: Add interface function. Compatible with new grids. Works with Utux_1D_interface.
Martin Almquist <martin.almquist@it.uu.se>
parents:
571
diff
changeset
|
83 |
| 270 | 84 end |
| 85 | |
| 86 function N = size(obj) | |
| 87 N = obj.m; | |
| 88 end | |
| 89 | |
| 90 end | |
| 91 | |
| 92 methods(Static) | |
|
573
efe2dbf9796e
Remove data input from boundary condition function
Martin Almquist <martin.almquist@it.uu.se>
parents:
572
diff
changeset
|
93 % Calculates the matrices needed for the inteface coupling between boundary bound_u of scheme schm_u |
| 270 | 94 % and bound_v of scheme schm_v. |
|
572
4a73b2aab91f
Edit scheme.Utux: Add interface function. Compatible with new grids. Works with Utux_1D_interface.
Martin Almquist <martin.almquist@it.uu.se>
parents:
571
diff
changeset
|
95 % [uu, uv, vv, vu] = inteface_coupling(A,'r',B,'l') |
| 270 | 96 function [uu, uv, vv, vu] = interface_coupling(schm_u,bound_u,schm_v,bound_v) |
| 97 [uu,uv] = schm_u.interface(bound_u,schm_v,bound_v); | |
| 98 [vv,vu] = schm_v.interface(bound_v,schm_u,bound_u); | |
| 99 end | |
| 100 end | |
| 101 end |
