-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathmake_projection_g2g_h_gen.m
55 lines (45 loc) · 1.23 KB
/
make_projection_g2g_h_gen.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
function [Pc2f, Pf2c] = make_projection_g2g_h_gen(N, xi_c)
% [Pc2f, Pf2c] = make_projection_g2g_h_gen(N, xi_c)
%
% Generate projection operators to go from the f grid to the c grid both with
% the same order of accuracy N:
%
% c f
% o o
% | |
% | |
% | |
% | o
% | |
% | |
% | |
% | o
% | |
% | |
% | |
% o o
%
% xi_c(i,j) is the xi component of the i'th vertex of the j'th cell for the
% left mesh (assumed to be ordered from smallest to largest).
%
% It is assumed that xi_c(1,1) and xi_c(2,end) are the components of the
% f cell.
[r, ~] = Gaussian_quad(N);
K = size(xi_c, 2);
VX = [xi_c(1,:), xi_c(2,end)];
fa = xi_c(1,1);
fb = xi_c(2,end);
VX = 2/(fb-fa) * VX + 1 - 2*fb/(fb-fa);
va = (1:K)'; vb = (2:K+1)';
x = ones(N+1,1)*VX(va) + 0.5*(r+1)*(VX(vb)-VX(va));
Jc = (VX(vb) - VX(va))/2;
Jf = 1;
Pc2f = zeros(length(x(:)), length(r(:)));
m = (2./(2*(0:N)+1));
Vr = Legendre_Vandermonde(r, N);
sq_invm_invVr = diag(sqrt(1./m)) / Vr;
for k = 1:K
Pc2f((k-1)*(N+1)+1:k*(N+1), :) = ...
sq_invm_invVr * Legendre_Vandermonde(x(:,k),N) * diag(sqrt(m));
end
Pf2c = (1/Jf) * diag(1./m) * Pc2f' * kron(diag(Jc), diag(m));