-
Notifications
You must be signed in to change notification settings - Fork 4
/
CorrectionPolynomial.m
199 lines (178 loc) · 7.46 KB
/
CorrectionPolynomial.m
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
classdef CorrectionPolynomial
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%CORRECTIONPOLYNOMIAL class
% Build Correction Polynomials of degree K for CPR scheme.
%
% by Manuel Diaz, NTU, 2013.10.12
%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
properties
pDeg
pType
kxi
L
R
end
properties (Dependent = true, SetAccess = private)
xi % local coordiante
P % Correction Polynomail
dP % derivate of correction Polynomial
end
methods (Static)
function legP = LegendreP(l)
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% Legendre Polynomials
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%
% Input : kDeg: Polynomial Degree requested
% Output : legP: symbolic Legendre polynomial
%
x = sym('x');
legP = simplify(1/(2^l*factorial(l))*diff((x^2-1)^l,x,l));
end
end % Methods
methods
function obj = CorrectionPolynomial(type,Kdeg,solutionPoints)
obj.pDeg = Kdeg;
obj.pType = type;
obj.kxi = solutionPoints;
end
function cpoly = get.P(obj)
switch obj.pType
case 'Legendre'
cpoly = obj.LegendreP(obj.pDeg);
case 'LGL'
cpoly = obj.LobattoP(obj.pDeg);
case 'RadauRight'
cpoly = obj.RadauRightP(obj.pDeg);
case 'RadauLeft'
cpoly = obj.RadauLeftP(obj.pDeg);
case 'DGRight'
cpoly = obj.NDGRightP(obj.pDeg);
case 'DGLeft'
cpoly = obj.NDGLeftP(obj.pDeg);
case 'SDRight'
cpoly = obj.SDRightP(obj.pDeg);
case 'SDLeft'
cpoly = obj.SDLeftP(obj.pDeg);
case 'HURight'
cpoly = obj.HURightP(obj.pDeg);
case 'HULeft'
cpoly = obj.HULeftP(obj.pDeg);
case 'CinftyRight'
cpoly = obj.RadauRightP(obj.pDeg);
case 'CinftyLeft'
cpoly = obj.RadauLeftP(obj.pDeg);
otherwise
error('correction polynomial not available')
end
end
function RRP = RadauRightP(obj,kDeg)
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% Load from table the coefs for Radau Polynomials
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%
% Input : kDeg: Polynomial Degree requested
% Output : RRP: Right Radau polynomial
%
RRP = (-1)^(kDeg)/2*(obj.LegendreP(kDeg) - obj.LegendreP(kDeg-1));
end
function RLP = RadauLeftP(obj,kDeg)
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% Load from table the coefs for Radau Polynomials
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%
% Input : kDeg: Polynomial Degree requested
% Output : RLP: Left Radau polynomial
%
RLP = (1/2)*(obj.LegendreP(kDeg) + obj.LegendreP(kDeg-1) );
end
function lobP = LobattoP(obj,kDeg)
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% Lobatto Polynomials
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%
% Input : kDeg: Polynomial Degree requested
% Output : lobP: Symbolic Lobatto polynomial
%
lobP = obj.LegendreP(kDeg) - obj.LegendreP(kDeg-2);
end
function DGRP = NDGRightP(obj,kDeg)
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% Load from table the coefs for NDG correction polynomials
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%
% Input : kDeg: Polynomial Degree requested
% Output : DGRP: Right Radau polynomial
%
DGRP = (-1)^(kDeg)/2*(obj.LegendreP(kDeg) - obj.LegendreP(kDeg+1));
end
function DGLP = NDGLeftP(obj,kDeg)
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% Load from table the coefs for NDG correction polynomials
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%
% Input : kDeg: Polynomial Degree requested
% Output : DGLP: Left Radau polynomial
%
DGLP = (1/2)*(obj.LegendreP(kDeg) + obj.LegendreP(kDeg+1) );
end
function SDRP = SDRightP(obj,kDeg)
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% Load from table the coefs for SD correction polynomials
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%
% Input : kDeg: Polynomial Degree requested
% Output : SDRP: Right Radau polynomial
%
x = sym('x');
SDRP = (-1)^(kDeg)/2*(1-x)*obj.LegendreP(kDeg);
end
function SDLP = SDLeftP(obj,kDeg)
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% Load from table the coefs for SD correction polynomials
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%
% Input : kDeg: Polynomial Degree requested
% Output : SDLP: Left Radau polynomial
%
x = sym('x');
SDLP = (1/2)*(1+x)*obj.LegendreP(kDeg);
end
function HURP = HURightP(obj,k)
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% Load from table the coefs for Huyng correction polynomials
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%
% Input : k: Polynomial Degree requested
% Output : HURP: Right Radau polynomial
%
HURP = (-1)^(k)/2*(obj.LegendreP(k) - ...
((k+1)*obj.LegendreP(k-1) + k*obj.LegendreP(k+1))/(2*k+1));
end
function HULP = HULeftP(obj,k)
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% Load from table the coefs for Huyng correction polynomials
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%
% Input : kDeg: Polynomial Degree requested
% Output : HULP: Left Radau polynomial
%
HULP = (1/2)*(obj.LegendreP(k) + ...
((k+1)*obj.LegendreP(k-1) + k*obj.LegendreP(k+1))/(2*k+1));
end
function dcorrection = get.dP(obj)
x = sym('x'); dcorrection = diff(obj.P,x);
end
function dg = eval_dP(obj,solutionPoints)
dg.Right = double(subs(obj.dP,solutionPoints));
dg.Left = -flipud(dg.Right);
end
function dgR = get.R(obj)
dgR = double(subs(obj.dP,obj.kxi));
end
function dgL = get.L(obj)
dgL = -flipud(double(subs(obj.dP,obj.kxi)));
end
end % Methods
end % Class