Skip to content

Commit 9168ccf

Browse files
committed
always unpack psi in if conditions
1 parent 0a50229 commit 9168ccf

File tree

1 file changed

+8
-6
lines changed

1 file changed

+8
-6
lines changed

src/equations/serre_green_naghdi_1d.jl

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1019,9 +1019,6 @@ function rhs_sgn_central!(dq, q, t, equations, source_terms, solver, cache,
10191019
# Compute all derivatives required below
10201020
(; h, h_x, v_x, h_hpb_x, b, b_x, hv_x, v2_x,
10211021
h2_v_vx_x, h_vx_x, p_h, p_x, tmp) = cache
1022-
if equations.bathymetry_type isa BathymetryVariable
1023-
(; psi) = cache
1024-
end
10251022

10261023
@.. b = equations.eta0 - D
10271024
@.. h = eta - b
@@ -1050,16 +1047,19 @@ function rhs_sgn_central!(dq, q, t, equations, source_terms, solver, cache,
10501047
mul!(p_x, D1, tmp)
10511048
@.. p_h += 0.25 * p_x
10521049
if equations.bathymetry_type isa BathymetryVariable
1050+
(; psi) = cache
10531051
@.. psi = 0.125 * p_x
10541052
end
10551053
@.. tmp = b_x * v
10561054
mul!(p_x, D1, tmp)
10571055
@.. p_h += 0.25 * h * v * p_x
10581056
if equations.bathymetry_type isa BathymetryVariable
1057+
(; psi) = cache
10591058
@.. psi += 0.125 * h * v * p_x
10601059
end
10611060
@.. p_h = p_h - 0.25 * (h_x * v + h * v_x) * b_x * v
10621061
if equations.bathymetry_type isa BathymetryVariable
1062+
(; psi) = cache
10631063
@.. psi -= 0.125 * (h_x * v + h * v_x) * b_x * v
10641064
end
10651065
@.. tmp = p_h * h
@@ -1086,6 +1086,7 @@ function rhs_sgn_central!(dq, q, t, equations, source_terms, solver, cache,
10861086
+ p_x
10871087
+ 1.5 * p_h * b_x)
10881088
if equations.bathymetry_type isa BathymetryVariable
1089+
(; psi) = cache
10891090
@.. dv = dv - psi * b_x
10901091
end
10911092
end
@@ -1134,9 +1135,6 @@ function rhs_sgn_upwind!(dq, q, t, equations, source_terms, solver, cache,
11341135
# Compute all derivatives required below
11351136
(; h, h_x, v_x, v_x_upwind, h_hpb_x, b, b_x, hv_x, v2_x,
11361137
h2_v_vx_x, h_vx_x, p_h, p_0, p_x, tmp) = cache
1137-
if equations.bathymetry_type isa BathymetryVariable
1138-
(; psi) = cache
1139-
end
11401138

11411139
@.. b = equations.eta0 - D
11421140
@.. h = eta - b
@@ -1165,12 +1163,14 @@ function rhs_sgn_upwind!(dq, q, t, equations, source_terms, solver, cache,
11651163
mul!(p_x, D1, tmp)
11661164
@.. p_h += 0.25 * p_x
11671165
if equations.bathymetry_type isa BathymetryVariable
1166+
(; psi) = cache
11681167
@.. psi = 0.125 * p_x
11691168
end
11701169
@.. tmp = b_x * v
11711170
mul!(p_x, D1, tmp)
11721171
@.. p_h += 0.25 * h * v * p_x
11731172
if equations.bathymetry_type isa BathymetryVariable
1173+
(; psi) = cache
11741174
@.. psi += 0.125 * h * v * p_x
11751175
end
11761176
@.. p_0 = p_h * h
@@ -1180,6 +1180,7 @@ function rhs_sgn_upwind!(dq, q, t, equations, source_terms, solver, cache,
11801180
-
11811181
0.25 * (h_x * v + h * v_x) * b_x * v)
11821182
if equations.bathymetry_type isa BathymetryVariable
1183+
(; psi) = cache
11831184
@.. psi -= 0.125 * (h_x * v + h * v_x) * b_x * v
11841185
end
11851186
@.. p_h = p_h + tmp
@@ -1207,6 +1208,7 @@ function rhs_sgn_upwind!(dq, q, t, equations, source_terms, solver, cache,
12071208
+ p_x
12081209
+ 1.5 * p_h * b_x)
12091210
if equations.bathymetry_type isa BathymetryVariable
1211+
(; psi) = cache
12101212
@.. dv = dv - psi * b_x
12111213
end
12121214
end

0 commit comments

Comments
 (0)