Mercurial > repos > public > sbplib
annotate +scheme/Utux.m @ 1198:2924b3a9b921 feature/d2_compatible
Add OpSet for fully compatible D2Variable, created from regular D2Variable by replacing d1 by first row of D1. Formal reduction by one order of accuracy at the boundary point.
author | Martin Almquist <malmquist@stanford.edu> |
---|---|
date | Fri, 16 Aug 2019 14:30:28 -0700 |
parents | 0c504a21432d |
children | 433c89bf19e0 |
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 | |
905
459eeb99130f
Include type as (optional) input parameter in the interface method of all schemes.
Martin Almquist <malmquist@stanford.edu>
parents:
573
diff
changeset
|
19 methods |
949
6d2167719557
Remove half-commented switch in Utux.
Martin Almquist <malmquist@stanford.edu>
parents:
946
diff
changeset
|
20 function obj = Utux(g, order, opSet) |
6d2167719557
Remove half-commented switch in Utux.
Martin Almquist <malmquist@stanford.edu>
parents:
946
diff
changeset
|
21 default_arg('opSet',@sbp.D2Standard); |
905
459eeb99130f
Include type as (optional) input parameter in the interface method of all schemes.
Martin Almquist <malmquist@stanford.edu>
parents:
573
diff
changeset
|
22 |
949
6d2167719557
Remove half-commented switch in Utux.
Martin Almquist <malmquist@stanford.edu>
parents:
946
diff
changeset
|
23 m = g.size(); |
6d2167719557
Remove half-commented switch in Utux.
Martin Almquist <malmquist@stanford.edu>
parents:
946
diff
changeset
|
24 xl = g.getBoundary('l'); |
6d2167719557
Remove half-commented switch in Utux.
Martin Almquist <malmquist@stanford.edu>
parents:
946
diff
changeset
|
25 xr = g.getBoundary('r'); |
6d2167719557
Remove half-commented switch in Utux.
Martin Almquist <malmquist@stanford.edu>
parents:
946
diff
changeset
|
26 xlim = {xl, xr}; |
6d2167719557
Remove half-commented switch in Utux.
Martin Almquist <malmquist@stanford.edu>
parents:
946
diff
changeset
|
27 |
6d2167719557
Remove half-commented switch in Utux.
Martin Almquist <malmquist@stanford.edu>
parents:
946
diff
changeset
|
28 ops = opSet(m, xlim, order); |
6d2167719557
Remove half-commented switch in Utux.
Martin Almquist <malmquist@stanford.edu>
parents:
946
diff
changeset
|
29 obj.D1 = ops.D1; |
905
459eeb99130f
Include type as (optional) input parameter in the interface method of all schemes.
Martin Almquist <malmquist@stanford.edu>
parents:
573
diff
changeset
|
30 |
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
|
31 obj.grid = g; |
270 | 32 |
290
d32f674bcbe5
A first attempt to make a general scheme fo hyperbolic systems
Ylva Rydin <ylva.rydin@telia.com>
parents:
270
diff
changeset
|
33 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
|
34 obj.Hi = ops.HI; |
905
459eeb99130f
Include type as (optional) input parameter in the interface method of all schemes.
Martin Almquist <malmquist@stanford.edu>
parents:
573
diff
changeset
|
35 |
290
d32f674bcbe5
A first attempt to make a general scheme fo hyperbolic systems
Ylva Rydin <ylva.rydin@telia.com>
parents:
270
diff
changeset
|
36 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
|
37 obj.e_r = ops.e_r; |
571
38c3da9675a5
Bug fixes in scheme.Utux
Martin Almquist <martin.almquist@it.uu.se>
parents:
367
diff
changeset
|
38 obj.D = -obj.D1; |
270 | 39 |
40 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
|
41 obj.h = ops.h; |
270 | 42 obj.order = order; |
43 | |
44 end | |
45 % Closure functions return the opertors applied to the own doamin to close the boundary | |
46 % Penalty functions return the opertors to force the solution. In the case of an interface it returns the operator applied to the other doamin. | |
47 % boundary is a string specifying the boundary e.g. 'l','r' or 'e','w','n','s'. | |
48 % type is a string specifying the type of boundary condition if there are several. | |
49 % data is a function returning the data that should be applied at the boundary. | |
50 % neighbour_scheme is an instance of Scheme that should be interfaced to. | |
51 % 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
|
52 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
|
53 default_arg('type','dirichlet'); |
905
459eeb99130f
Include type as (optional) input parameter in the interface method of all schemes.
Martin Almquist <malmquist@stanford.edu>
parents:
573
diff
changeset
|
54 tau =-1*obj.e_l; |
459eeb99130f
Include type as (optional) input parameter in the interface method of all schemes.
Martin Almquist <malmquist@stanford.edu>
parents:
573
diff
changeset
|
55 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
|
56 penalty = -obj.Hi*tau; |
905
459eeb99130f
Include type as (optional) input parameter in the interface method of all schemes.
Martin Almquist <malmquist@stanford.edu>
parents:
573
diff
changeset
|
57 |
270 | 58 end |
905
459eeb99130f
Include type as (optional) input parameter in the interface method of all schemes.
Martin Almquist <malmquist@stanford.edu>
parents:
573
diff
changeset
|
59 |
946
706d1c2b4199
Raname opts to type in a bunch of interface methods
Jonatan Werpers <jonatan@werpers.com>
parents:
910
diff
changeset
|
60 function [closure, penalty] = interface(obj, boundary, neighbour_scheme, neighbour_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
|
61 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
|
62 % 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
|
63 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
|
64 tau = -1*obj.e_l; |
905
459eeb99130f
Include type as (optional) input parameter in the interface method of all schemes.
Martin Almquist <malmquist@stanford.edu>
parents:
573
diff
changeset
|
65 closure = obj.Hi*tau*obj.e_l'; |
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
|
66 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
|
67 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
|
68 tau = 0*obj.e_r; |
905
459eeb99130f
Include type as (optional) input parameter in the interface method of all schemes.
Martin Almquist <malmquist@stanford.edu>
parents:
573
diff
changeset
|
69 closure = obj.Hi*tau*obj.e_r'; |
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
|
70 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
|
71 end |
905
459eeb99130f
Include type as (optional) input parameter in the interface method of all schemes.
Martin Almquist <malmquist@stanford.edu>
parents:
573
diff
changeset
|
72 |
270 | 73 end |
905
459eeb99130f
Include type as (optional) input parameter in the interface method of all schemes.
Martin Almquist <malmquist@stanford.edu>
parents:
573
diff
changeset
|
74 |
998
2b1b944deae1
Add getBoundaryOperator to all 1d schemes. Did not add getBoundaryQuadrature because it doesnt make sense in 1d (?)
Martin Almquist <malmquist@stanford.edu>
parents:
949
diff
changeset
|
75 % Returns the boundary operator op for the boundary specified by the string boundary. |
1048
adbb80e60b10
Clean up Elastic2dVariable (partially), Utux, and Utux2d.
Martin Almquist <malmquist@stanford.edu>
parents:
1044
diff
changeset
|
76 % op -- string |
998
2b1b944deae1
Add getBoundaryOperator to all 1d schemes. Did not add getBoundaryQuadrature because it doesnt make sense in 1d (?)
Martin Almquist <malmquist@stanford.edu>
parents:
949
diff
changeset
|
77 % boundary -- string |
1048
adbb80e60b10
Clean up Elastic2dVariable (partially), Utux, and Utux2d.
Martin Almquist <malmquist@stanford.edu>
parents:
1044
diff
changeset
|
78 function o = getBoundaryOperator(obj, op, boundary) |
adbb80e60b10
Clean up Elastic2dVariable (partially), Utux, and Utux2d.
Martin Almquist <malmquist@stanford.edu>
parents:
1044
diff
changeset
|
79 assertIsMember(op, {'e'}) |
1042
8d73fcdb07a5
Add asserts to boundary identifier inputs
Jonatan Werpers <jonatan@werpers.com>
parents:
998
diff
changeset
|
80 assertIsMember(boundary, {'l', 'r'}) |
998
2b1b944deae1
Add getBoundaryOperator to all 1d schemes. Did not add getBoundaryQuadrature because it doesnt make sense in 1d (?)
Martin Almquist <malmquist@stanford.edu>
parents:
949
diff
changeset
|
81 |
1048
adbb80e60b10
Clean up Elastic2dVariable (partially), Utux, and Utux2d.
Martin Almquist <malmquist@stanford.edu>
parents:
1044
diff
changeset
|
82 o = obj.([op, '_', boundary]); |
998
2b1b944deae1
Add getBoundaryOperator to all 1d schemes. Did not add getBoundaryQuadrature because it doesnt make sense in 1d (?)
Martin Almquist <malmquist@stanford.edu>
parents:
949
diff
changeset
|
83 end |
2b1b944deae1
Add getBoundaryOperator to all 1d schemes. Did not add getBoundaryQuadrature because it doesnt make sense in 1d (?)
Martin Almquist <malmquist@stanford.edu>
parents:
949
diff
changeset
|
84 |
1049
0c504a21432d
Add getBoundaryQuadrature to all 1d diffOps
Martin Almquist <malmquist@stanford.edu>
parents:
1048
diff
changeset
|
85 % Returns square boundary quadrature matrix, of dimension |
0c504a21432d
Add getBoundaryQuadrature to all 1d diffOps
Martin Almquist <malmquist@stanford.edu>
parents:
1048
diff
changeset
|
86 % corresponding to the number of boundary points |
0c504a21432d
Add getBoundaryQuadrature to all 1d diffOps
Martin Almquist <malmquist@stanford.edu>
parents:
1048
diff
changeset
|
87 % |
0c504a21432d
Add getBoundaryQuadrature to all 1d diffOps
Martin Almquist <malmquist@stanford.edu>
parents:
1048
diff
changeset
|
88 % boundary -- string |
0c504a21432d
Add getBoundaryQuadrature to all 1d diffOps
Martin Almquist <malmquist@stanford.edu>
parents:
1048
diff
changeset
|
89 % Note: for 1d diffOps, the boundary quadrature is the scalar 1. |
0c504a21432d
Add getBoundaryQuadrature to all 1d diffOps
Martin Almquist <malmquist@stanford.edu>
parents:
1048
diff
changeset
|
90 function H_b = getBoundaryQuadrature(obj, boundary) |
0c504a21432d
Add getBoundaryQuadrature to all 1d diffOps
Martin Almquist <malmquist@stanford.edu>
parents:
1048
diff
changeset
|
91 assertIsMember(boundary, {'l', 'r'}) |
0c504a21432d
Add getBoundaryQuadrature to all 1d diffOps
Martin Almquist <malmquist@stanford.edu>
parents:
1048
diff
changeset
|
92 |
0c504a21432d
Add getBoundaryQuadrature to all 1d diffOps
Martin Almquist <malmquist@stanford.edu>
parents:
1048
diff
changeset
|
93 H_b = 1; |
0c504a21432d
Add getBoundaryQuadrature to all 1d diffOps
Martin Almquist <malmquist@stanford.edu>
parents:
1048
diff
changeset
|
94 end |
0c504a21432d
Add getBoundaryQuadrature to all 1d diffOps
Martin Almquist <malmquist@stanford.edu>
parents:
1048
diff
changeset
|
95 |
270 | 96 function N = size(obj) |
97 N = obj.m; | |
98 end | |
99 | |
100 end | |
1043
c12b84fe9b00
Remove static method `interface_coupling` that shouldn't have existed in the first place
Jonatan Werpers <jonatan@werpers.com>
parents:
949
diff
changeset
|
101 end |