-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathse_bvfilter_matrices.m
More file actions
68 lines (57 loc) · 1.68 KB
/
se_bvfilter_matrices.m
File metadata and controls
68 lines (57 loc) · 1.68 KB
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
function [M1,M2,M3] = se_bvfilter_matrices(npts, mu, porder, s)
% se_laplacian_matrices - Generate matrices for the Boyd-Vandeven filter.
%
% Syntax: [M1,M2,M3] = se_bvfilter_matrices(npts)
%
% Inputs:
% npts - Order of the spectral element method
% mu - Non-dimensional filter coefficient
% porder - Order of the Boyd-Vandeven filter
% s - Filter lag
%
% Outputs:
% M1 - Matrix of left coefficients (npts-1 x npts-1)
% M2 - Matrix of center coefficients (npts-1 x npts-1)
% M3 - Matrix of right coefficients (npts-1 x npts-1)
%
% Example:
% >> [L1,L2,L3] = se_bvfilter_matrices(4);
%
% Author: Paul Ullrich
% University of California, Davis
% Email address: paullrich@ucdavis.edu
% Last revision: 19-Apr-2018
%------------- BEGIN CODE --------------
% Check arguments
if (~isscalar(npts))
error('npts argument must be a scalar');
end
% Compute Gauss-Legendre-Lobatto points on [0,1] interval
[myroots,myweights] = lglnodes(npts,0,1);
% Calculate modal transform matrix
D = zeros(npts,npts);
for n = 1:npts
D(:,n) = legendreP((n-1), (2*myroots-1));
end
% Coefficient weights at each node
coeffs = zeros(npts);
for k = 1:npts
kx = k-1;
if (kx < s)
coeffs(k,k) = 1;
else
Omega = abs((kx-s)/(npts-s)) - 0.5;
coeffs(k,k) = 0.5 * (1 - erf(2 * sqrt(porder) * sign(Omega) * sqrt(-log(1 - 4 * Omega^2) / 4)));
end
end
% Build filter
MD = (1 - mu) * eye(npts) + mu * real(D * coeffs * inv(D));
MD(1,2:npts) = 0.5 * MD(1,2:npts);
MD(npts,1:npts-1) = 0.5 * MD(npts,1:npts-1);
% Exract submatrices
M1 = zeros(npts-1,npts-1);
M1(1,:) = MD(npts,1:npts-1);
M2 = MD(1:npts-1,1:npts-1);
M3 = zeros(npts-1,npts-1);
M3(:,1) = MD(1:npts-1,npts);
myweights;