Skip to content

Commit 81cd444

Browse files
committed
Cleanup and corrections
1 parent 3a5a4b6 commit 81cd444

File tree

2 files changed

+12
-28
lines changed

2 files changed

+12
-28
lines changed

src/+otp/+qg/QuasiGeostrophicProblem.m

Lines changed: 5 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -147,49 +147,33 @@ function onSettingsChanged(obj)
147147

148148
% do decompositions for the eigenvalue sylvester method. see
149149
%
150-
% Kirsten, Gerhardus Petrus. Comparison of methods for solving Sylvester systems. Stellenbosch University, 2018.
150+
% Kirsten, Gerhardus Petrus. Comparison of methods for solving Sylvester systems. Stellenbosch University, 2018.
151151
%
152152
% for a detailed method, the "Eigenvalue Method" which makes this
153153
% particularly efficient
154154

155-
%nfLx = -full(Lx);
156-
%nfLy = -full(Ly);
157-
%[P1, Lambda] = eig(nfLx);
158-
%[P2, D] = eig(nfLy);
159-
160-
% We can represent the eigenvalues as
161-
%dLambda = ((2*sinpi((1:nx)/(2*(nx + 1)))/hx).^2).';
162-
%dD = ((2*sinpi((1:ny)/(2*(ny + 1)))/hy).^2).';
163-
%L12 = 1./(dLambda + dD.');
164155
hx2 = hx^2;
165156
hy2 = hy^2;
166157
cx = (1:nx)/(nx + 1);
167158
cy = (1:ny)/(ny + 1);
168159
L12 = -(hx2*hy2./(2*(-hx2 - hy2 + hy2*cospi(cx).' + hx2*cospi(cy))));
169160
P1 = sqrt(2/(nx + 1))*sinpi((1:nx).'*(1:nx)/(nx + 1));
170161
P2 = sqrt(2/(ny + 1))*sinpi((1:ny).'*(1:ny)/(ny + 1));
171-
172-
173-
%L12 = 1./(diag(Lambda) + diag(D).');
174-
%P1T = P1.';
175-
%P2T = P2.';
176162

177163
ys = linspace(ydomain(1), ydomain(end), ny + 2);
178164
ys = ys(2:end-1);
179165

180166
ymat = repmat(ys.', 1, nx);
181-
%ymat = reshape(ymat.', prod(n), 1);
182-
%F = sin(pi*(ymat - 1));
183167
F = sin(pi*(ymat.' - 1));
184168

185169
obj.Rhs = otp.Rhs(@(t, psi) ...
186170
otp.qg.f(psi, Lx, Ly, P1, P2, L12, Dx, DyT, F, Re, Ro), ...
187171
...
188-
otp.Rhs.FieldNames.JacobianVectorProduct, @(t, psi, u) ...
189-
otp.qg.jvp(psi, u, L, RdnL, PdnL, Ddx, Ddy, Re, Ro), ...
172+
otp.Rhs.FieldNames.JacobianVectorProduct, @(t, psi, v) ...
173+
otp.qg.jvp(psi, v, Lx, Ly, P1, P2, L12, Dx, DyT, F, Re, Ro), ...
190174
...
191-
otp.Rhs.FieldNames.JacobianAdjointVectorProduct, @(t, psi, u) ...
192-
otp.qg.javp(psi, u, L, RdnL, PdnL, Ddx, Ddy, Re, Ro));
175+
otp.Rhs.FieldNames.JacobianAdjointVectorProduct, @(t, psi, v) ...
176+
otp.qg.javp(psi, v, L, RdnL, PdnL, Ddx, Ddy, Re, Ro));
193177

194178

195179
% AD LES

src/+otp/+qg/jvp.m

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
1-
function jvp = jvp(psi, u, L, RdnL, PdnL, Ddx, Ddy, Re, Ro)
1+
function jvp = jvp(psi, v, Lx, Ly, P1, P2, L12, Dx, DyT, ~, Re, Ro)
22

33
[nx, ny] = size(L12);
44

55
psi = reshape(psi, nx, ny);
6-
u = reshape(u, nx, ny);
6+
v = reshape(v, nx, ny);
77

88
% Calculate the vorticity
99
q = -(Lx*psi + psi*Ly);
@@ -14,9 +14,9 @@
1414
dqx = Dx*q;
1515
dqy = q*DyT;
1616

17-
nLu = -(Lx*u + u*Ly);
18-
Dxu = Dx*u;
19-
Dyu = u*DyT;
17+
nLu = -(Lx*v + v*Ly);
18+
Dxu = Dx*v;
19+
Dyu = v*DyT;
2020

2121
DxnLu = Dx*nLu;
2222
DynLu = nLu*DyT;
@@ -25,8 +25,8 @@
2525
dJpsi1u = dpsix.*DynLu + dqy.*Dxu ...
2626
- dpsiy.*DxnLu - dqx.*Dyu;
2727

28-
dJpsi2u = Dx*(psi.*DynLu) + Dx*(dqy.*u) ...
29-
- (psi.*DxnLu)*DyT - (dqx.*u)*DyT;
28+
dJpsi2u = Dx*(psi.*DynLu) + Dx*(dqy.*v) ...
29+
- (psi.*DxnLu)*DyT - (dqx.*v)*DyT;
3030

3131
dJpsi3u = (dpsix.*nLu)*DyT + (q.*Dxu)*DyT ...
3232
- Dx*(dpsiy.*nLu) - Dx*(q.*Dyu);

0 commit comments

Comments
 (0)