Skip to content

Commit b7c6f14

Browse files
authored
Merge pull request #146 from milankl/ssprk
Keep UV and PVadv on every substep
2 parents ef6181e + 3d6f4c9 commit b7c6f14

File tree

4 files changed

+14
-15
lines changed

4 files changed

+14
-15
lines changed

src/Continuity.jl

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -80,8 +80,7 @@ function continuity!( u::AbstractMatrix,
8080
@unpack nstep_advcor = S.grid
8181
@unpack time_scheme,surface_relax,surface_forcing = S.parameters
8282

83-
if nstep_advcor > 0 || # then UV wasn't calculated inside rhs!
84-
time_scheme != "RK" # then u,v changed before evaluating semi-implciti continuity
83+
if time_scheme != "RK" # then u,v changed before evaluating semi-implicit continuity
8584
UVfluxes!(u,v,η,Diag,S)
8685
end
8786

src/DefaultParameters.jl

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@
4949
# TIME STEPPING OPTIONS
5050
time_scheme::String="RK" # Runge-Kutta ("RK") or strong-stability preserving RK ("SSPRK2","SSPRK3")
5151
RKo::Int=4 # Order of the RK time stepping scheme (2, 3 or 4)
52-
RKs::Int=2 # Number of stages for SSPRK2
52+
RKs::Int=3 # Number of stages for SSPRK2
5353
cfl::Real=1.0 # CFL number (1.0 recommended for RK4, 0.6 for RK3)
5454
Ndays::Real=10.0 # number of days to integrate for
5555
nstep_diff::Int=1 # diffusive part every nstep_diff time steps.
@@ -148,10 +148,9 @@ end
148148
"""
149149
Creates a Parameter struct with following options and default values
150150
151-
T::DataType=Float32 # number format
152-
153-
Tprog::DataType=T # number format for prognostic variables
154-
Tcomm::DataType=Tprog # number format for ghost-point copies
151+
T=Float32 # number format
152+
Tprog=T # number format for prognostic variables
153+
Tcomm=Tprog # number format for ghost-point copies
155154
156155
# DOMAIN RESOLUTION AND RATIO
157156
nx::Int=100 # number of grid cells in x-direction
@@ -195,8 +194,10 @@ Creates a Parameter struct with following options and default values
195194
wk::Real=10e3 # width [m] in y of Gaussian used for surface forcing
196195
197196
# TIME STEPPING OPTIONS
198-
RKo::Int=4 # Order of the RK time stepping scheme (2,3 or 4)
199-
cfl::Real=1.0 # CFL number (1.0 recommended for RK4, 0.6 for RK3, 0.1 for RK2)
197+
time_scheme::String="RK" # Runge-Kutta ("RK") or strong-stability preserving RK ("SSPRK2","SSPRK3")
198+
RKo::Int=4 # Order of the RK time stepping scheme (2, 3 or 4)
199+
RKs::Int=2 # Number of stages for SSPRK2
200+
cfl::Real=1.0 # CFL number (1.0 recommended for RK4, 0.6 for RK3)
200201
Ndays::Real=10.0 # number of days to integrate for
201202
nstep_diff::Int=1 # diffusive part every nstep_diff time steps.
202203
nstep_advcor::Int=0 # advection and coriolis update every nstep_advcor time steps.
@@ -243,7 +244,7 @@ Creates a Parameter struct with following options and default values
243244
244245
# OUTPUT OPTIONS
245246
output::Bool=false # netcdf output?
246-
output_vars::Array{String,1}=["u","v","η","sst"] # which variables to output? q,ζ,du,dv,dη also allowed.
247+
output_vars::Array{String,1}=["u","v","η","sst"] # which variables to output? "du","dv","dη" also allowed
247248
output_dt::Real=6 # output time step [hours]
248249
outpath::String=pwd() # path to output folder
249250

src/TimeIntegration.jl

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -163,7 +163,6 @@ function time_integration( Prog::PrognosticVars{Tprog},
163163
if dynamics == "nonlinear" && nstep_advcor > 0 && (i % nstep_advcor) == 0
164164
UVfluxes!(u0rhs,v0rhs,η0rhs,Diag,S)
165165
advection_coriolis!(u0rhs,v0rhs,η0rhs,Diag,S)
166-
PVadvection!(Diag,S)
167166
end
168167

169168
# DIFFUSIVE TERMS - SEMI-IMPLICIT EULER

src/rhs.jl

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -32,12 +32,12 @@ function rhs_nonlinear!(u::AbstractMatrix,
3232
@unpack H = S.forcing
3333
@unpack ep = S.grid
3434

35-
if S.grid.nstep_advcor == 0 # then evaluate every RK substep
36-
UVfluxes!(u,v,η,Diag,S) # U,V needed for PV advection and in the continuity equation
35+
UVfluxes!(u,v,η,Diag,S) # U,V needed for PV advection and in the continuity equation
36+
if S.grid.nstep_advcor == 0 # evaluate every RK substep
3737
advection_coriolis!(u,v,η,Diag,S) # PV and non-linear Bernoulli terms
38-
PVadvection!(Diag,S) # advect the PV with u,v
3938
end
40-
39+
PVadvection!(Diag,S) # advect the PV with U,V
40+
4141
# Bernoulli potential - recalculate for new η, KEu,KEv are only updated in advection_coriolis
4242
@unpack p,KEu,KEv,dpdx,dpdy = Diag.Bernoulli
4343
@unpack g = S.constants

0 commit comments

Comments
 (0)