22# computes the advection term (needed for the time derivatives). Two versions of each function
33# are defined, each just depends on what type of structure I'm passing for RHS
44
5- function comp_u_v_eta_t! (
6- nx:: Int ,
7- rhs:: RHS_terms ,
8- params:: Params ,
9- interp:: Interps ,
10- grad:: Derivatives ,
11- advec:: Advection
12- )
13-
14- rhs. h .= rhs. eta1 .+ params. H
15-
16- rhs. h_u .= interp. ITu * rhs. h
17- rhs. h_v .= interp. ITv * rhs. h
18- rhs. h_q .= interp. ITq * rhs. h
19-
20- rhs. U .= rhs. u1 .* rhs. h_u
21- rhs. V .= rhs. v1 .* rhs. h_v
22-
23- rhs. kinetic .= interp. IuT * (rhs. u1.^ 2 ) .+ interp. IvT * (rhs. v1.^ 2 )
24-
25- # Kloewer defined new terms q and p corresponding to potential vorticity and
26- # Bernoulli potential respectively. To avoid errors in my mimic I'm following
27- # along and doing the same
28- rhs. q .= (params. coriolis .+ grad. Gvx * rhs. v1 .- grad. Guy * rhs. u1) ./ rhs. h_q
29- rhs. p .= 0.5 .* rhs. kinetic .+ params. g .* rhs. h
30-
31- # bottom friction
32- rhs. kinetic_sq .= sqrt .(rhs. kinetic)
33- rhs. bfric_u .= params. bottom_drag .* ((interp. ITu * rhs. kinetic_sq) .* rhs. u1) ./ rhs. h_u
34- rhs. bfric_v .= params. bottom_drag .* ((interp. ITv * rhs. kinetic_sq) .* rhs. v1) ./ rhs. h_v
35-
36- # deal with the advection term
37- comp_advection (nx, rhs, advec)
38-
39- # rhs.Mu .= params.A_h .* (grad.LLu * rhs.u1)
40- # rhs.Mv .= params.A_h .* (grad.LLv * rhs.v1)
5+ # function comp_u_v_eta_t(
6+ # nx::Int,
7+ # rhs::RHS_terms,
8+ # params::Params,
9+ # interp::Interps,
10+ # grad::Derivatives,
11+ # advec::Advection
12+ # )
13+
14+ # rhs.h .= rhs.eta1 .+ params.H
15+
16+ # rhs.h_u .= interp.ITu * rhs.h
17+ # rhs.h_v .= interp.ITv * rhs.h
18+ # rhs.h_q .= interp.ITq * rhs.h
19+
20+ # rhs.U .= rhs.u1 .* rhs.h_u
21+ # rhs.V .= rhs.v1 .* rhs.h_v
22+
23+ # rhs.kinetic .= interp.IuT * (rhs.u1.^2) .+ interp.IvT * (rhs.v1.^2)
24+
25+ # # Kloewer defined new terms q and p corresponding to potential vorticity and
26+ # # Bernoulli potential respectively. To avoid errors in my mimic I'm following
27+ # # along and doing the same
28+ # rhs.q .= (params.coriolis .+ grad.Gvx * rhs.v1 .- grad.Guy * rhs.u1) ./ rhs.h_q
29+ # rhs.p .= 0.5 .* rhs.kinetic .+ params.g .* rhs.h
30+
31+ # # bottom friction
32+ # rhs.kinetic_sq .= sqrt.(rhs.kinetic)
33+ # rhs.bfric_u .= params.bottom_drag .* ((interp.ITu * rhs.kinetic_sq) .* rhs.u1) ./ rhs.h_u
34+ # rhs.bfric_v .= params.bottom_drag .* ((interp.ITv * rhs.kinetic_sq) .* rhs.v1) ./ rhs.h_v
35+
36+ # # deal with the advection term
37+ # comp_advection(nx, rhs, advec)
38+
39+ # # rhs.Mu .= params.A_h .* (grad.LLu * rhs.u1)
40+ # # rhs.Mv .= params.A_h .* (grad.LLv * rhs.v1)
4141
42- rhs. Mu .= (interp. ITu * params. nu) .* (grad. LLu * rhs. u1)
43- rhs. Mv .= (interp. ITv * params. nu) .* (grad. LLv * rhs. v1)
42+ # rhs.Mu .= (interp.ITu * params.nu) .* (grad.LLu * rhs.u1)
43+ # rhs.Mv .= (interp.ITv * params.nu) .* (grad.LLv * rhs.v1)
4444
45- rhs. u_t .= rhs. adv_u .- grad. GTx * rhs. p .+ params. wind_stress ./ rhs. h_u .- rhs. Mu .- rhs. bfric_u
45+ # rhs.u_t .= rhs.adv_u .- grad.GTx * rhs.p .+ params.wind_stress ./ rhs.h_u .- rhs.Mu .- rhs.bfric_u
4646
47- rhs. v_t .= rhs. adv_v .- grad. GTy * rhs. p .- rhs. Mv .- rhs. bfric_v
47+ # rhs.v_t .= rhs.adv_v .- grad.GTy * rhs.p .- rhs.Mv .- rhs.bfric_v
4848
49- rhs. eta_t .= - (grad. Gux * rhs. U .+ grad. Gvy * rhs. V)
49+ # rhs.eta_t .= - (grad.Gux * rhs.U .+ grad.Gvy * rhs.V)
5050
51- return nothing
51+ # return nothing
5252
53- end
53+ # end
5454
55- function comp_u_v_eta_t! (nx:: Int ,
55+ function comp_u_v_eta_t (nx:: Int ,
5656 rhs:: SWM_pde ,
5757 params:: Params ,
5858 interp:: Interps ,
@@ -83,25 +83,25 @@ function comp_u_v_eta_t!(nx::Int,
8383 rhs. bfric_v .= params. bottom_drag .* ((interp. ITv * rhs. kinetic_sq) .* rhs. v1) ./ rhs. h_v
8484
8585 # deal with the advection term
86- comp_advection! (nx, rhs, advec)
86+ comp_advection (nx, rhs, advec)
8787
8888 # rhs.Mu .= params.A_h .* (grad.LLu * rhs.u1)
8989 # rhs.Mv .= params.A_h .* (grad.LLv * rhs.v1)
9090
91+ # ## Important: Need to apply Laplacian to nu for when nu varies spatially ##################
9192 rhs. Mu .= (interp. ITu * params. nu) .* (grad. LLu * rhs. u1)
9293 rhs. Mv .= (interp. ITv * params. nu) .* (grad. LLv * rhs. v1)
9394
9495 rhs. u_t .= rhs. adv_u .- grad. GTx * rhs. p .+ params. wind_stress ./ rhs. h_u .- rhs. Mu .- rhs. bfric_u
95-
9696 rhs. v_t .= rhs. adv_v .- grad. GTy * rhs. p .- rhs. Mv .- rhs. bfric_v
97-
9897 rhs. eta_t .= - (grad. Gux * rhs. U .+ grad. Gvy * rhs. V)
9998
10099 return nothing
101100
102101end
103102
104- function comp_advection! (
103+ # Arakawa and Lamb advection scheme
104+ function comp_advection (
105105 nx:: Int ,
106106 rhs:: SWM_pde ,
107107 advec:: Advection
@@ -132,29 +132,29 @@ function comp_advection!(
132132
133133end
134134
135- function comp_advection (nx:: Int , rhs:: RHS_terms , advec:: Advection )
135+ # function comp_advection(nx::Int, rhs::RHS_terms, advec::Advection)
136136
137- rhs. AL1q .= advec. AL1 * rhs. q
138- rhs. AL2q .= advec. AL2 * rhs. q
137+ # rhs.AL1q .= advec.AL1 * rhs.q
138+ # rhs.AL2q .= advec.AL2 * rhs.q
139139
140- AL1q_au = @view rhs. AL1q[1 : end - nx]
141- AL2q_bu = @view rhs. AL2q[nx+ 1 : end ]
142- AL2q_cu = @view rhs. AL2q[1 : end - nx]
143- AL1q_du = @view rhs. AL1q[nx+ 1 : end ]
140+ # AL1q_au = @view rhs.AL1q[1:end-nx]
141+ # AL2q_bu = @view rhs.AL2q[nx+1:end]
142+ # AL2q_cu = @view rhs.AL2q[1:end-nx]
143+ # AL1q_du = @view rhs.AL1q[nx+1:end]
144144
145- AL1q_av = @view rhs. AL1q[advec. index_av]
146- AL2q_bv = @view rhs. AL2q[advec. index_bv]
147- AL2q_cv = @view rhs. AL2q[advec. index_cv]
148- AL1q_dv = @view rhs. AL1q[advec. index_dv]
145+ # AL1q_av = @view rhs.AL1q[advec.index_av]
146+ # AL2q_bv = @view rhs.AL2q[advec.index_bv]
147+ # AL2q_cv = @view rhs.AL2q[advec.index_cv]
148+ # AL1q_dv = @view rhs.AL1q[advec.index_dv]
149149
150- rhs. adv_u .= advec. Seur * (advec. ALeur * rhs. q .* rhs. U) .+ advec. Seul * (advec. ALeul * rhs. q .* rhs. U) .+
151- advec. Sau * (AL1q_au .* rhs. V) .+ advec. Sbu * (AL2q_bu .* rhs. V) .+
152- advec. Scu * (AL2q_cu .* rhs. V) .+ advec. Sdu * (AL1q_du .* rhs. V)
150+ # rhs.adv_u .= advec.Seur * (advec.ALeur * rhs.q .* rhs.U) .+ advec.Seul * (advec.ALeul * rhs.q .* rhs.U) .+
151+ # advec.Sau * (AL1q_au .* rhs.V) .+ advec.Sbu * (AL2q_bu .* rhs.V) .+
152+ # advec.Scu * (AL2q_cu .* rhs.V) .+ advec.Sdu * (AL1q_du .* rhs.V)
153153
154- rhs. adv_v .= advec. Spvu * ((advec. ALpvu * rhs. q) .* rhs. V) .+ advec. Spvd * ((advec. ALpvd * rhs. q) .* rhs. V) .-
155- advec. Sav * (AL1q_av .* rhs. U) .- advec. Sbv * (AL2q_bv .* rhs. U) .-
156- advec. Scv * (AL2q_cv .* rhs. U) .- advec. Sdv * (AL1q_dv .* rhs. U)
154+ # rhs.adv_v .= advec.Spvu * ((advec.ALpvu * rhs.q) .* rhs.V) .+ advec.Spvd * ((advec.ALpvd * rhs.q) .* rhs.V) .-
155+ # advec.Sav * (AL1q_av .* rhs.U) .- advec.Sbv * (AL2q_bv .* rhs.U) .-
156+ # advec.Scv * (AL2q_cv .* rhs.U) .- advec.Sdv * (AL1q_dv .* rhs.U)
157157
158- return nothing
158+ # return nothing
159159
160- end
160+ # end
0 commit comments