-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathSolveSpectralBIE.m
43 lines (40 loc) · 1.75 KB
/
SolveSpectralBIE.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
function [u, au, bu, cu, FLAG, RELRES, ITER] = ...
SolveSpectralBIE(axi, bxi, xi, ...
RotationMatrix, ...
NGSphere, NGthet, NGphi, ...
eta, wg, ...
af, bf, auinf, buinf, ...
nlat, nlon, mask_a, mask_b, ...
mu, lam, N, ToleranceGMRES, ...
cuprev)
cxi = [axi(mask_a); bxi(mask_b)];
CHI = reshape(xi,nlat*nlon,3)';
%% Compute uinf - Gf
cf = [af(mask_a); bf(mask_b)];
cGf = computeGf(cf, cxi, CHI, RotationMatrix, ...
eta, wg, mask_a, mask_b, mu, ...
nlat, nlon, N, NGSphere, NGphi);
cuinf = [auinf(mask_a); buinf(mask_b)];
rhs = cuinf - cGf;
%% Compute u + (lam-1)/8/pi*Ku
Kernel = computeK(cxi, CHI, RotationMatrix, ...
eta, wg, mask_a, mask_b, ...
nlat, nlon, N, NGSphere, NGthet, NGphi);
%% Solve spectal Galerkin BIE
[cu, FLAG, RELRES, ITER] = gmres(@computeSpectralBIE,rhs,[], ...
ToleranceGMRES,3*(N+1)^2,[],[],cuprev);
au = zeros(size(axi)); bu = zeros(size(bxi));
au(mask_a) = cu(1:3*(N+1)*(N+2)/2);
bu(mask_b) = cu(3*(N+1)*(N+2)/2+1:3*(N+1)^2);
u = shsgcm(au, bu);
%%
function c = computeSpectralBIE(cu)
%%
au = zeros(size(axi)); bu = zeros(size(bxi));
au(mask_a) = cu(1:3*(N+1)*(N+2)/2);
bu(mask_b) = cu(3*(N+1)*(N+2)/2+1:3*(N+1)^2);
u = shsgcm(au, bu);
c = computeKu(Kernel, cu, u, RotationMatrix, ...
mask_a, mask_b, lam, N, nlat, nlon, NGSphere);
end
end