Skip to content
This repository has been archived by the owner on Mar 1, 2023. It is now read-only.

Commit

Permalink
drive shallow water model by HB model
Browse files Browse the repository at this point in the history
  • Loading branch information
blallen committed Jun 25, 2020
1 parent d202d8b commit 6c6b594
Show file tree
Hide file tree
Showing 3 changed files with 40 additions and 8 deletions.
32 changes: 28 additions & 4 deletions src/Ocean/ShallowWater/ShallowWaterModel.jl
Original file line number Diff line number Diff line change
Expand Up @@ -45,11 +45,16 @@ end
abstract type AdvectionTerm end
struct NonLinearAdvection <: AdvectionTerm end

struct ShallowWaterModel{PS, P, T, A, S} <: BalanceLaw
abstract type BarotropicForcingTerm end
struct SurfaceStress <: BarotropicForcingTerm end
struct IntegratedTendency <: BarotropicForcingTerm end

struct ShallowWaterModel{PS, P, T, A, F, S} <: BalanceLaw
param_set::PS
problem::P
turbulence::T
advection::A
forcing::F
c::S
end

Expand Down Expand Up @@ -213,22 +218,41 @@ end
m::SWModel{P},
S::Vars,
q::Vars,
diffusive::Vars,
d::Vars,
α::Vars,
t::Real,
direction,
) where {P}
S.U += α.τ

# f × u
f = α.f
U, V = q.U
S.U -= @SVector [-f * V, f * U]

forcing_term!(m, m.forcing, S, q, α, t)
linear_drag!(m.turbulence, S, q, α, t)

return nothing
end

@inline function forcing_term!(
::ShallowWaterModel,
::IntegratedTendency,
S,
Q,
A,
t,
)
# S.U += A.Gᵁ

return nothing
end

@inline function forcing_term!(::ShallowWaterModel, ::SurfaceStress, S, Q, A, t)
S.U += A.τ

return nothing
end

linear_drag!(::ConstantViscosity, _...) = nothing

@inline function linear_drag!(T::LinearDrag, S::Vars, q::Vars, α::Vars, t::Real)
Expand Down
1 change: 1 addition & 0 deletions test/Ocean/ShallowWater/2D_hydrostatic_spindown.jl
Original file line number Diff line number Diff line change
Expand Up @@ -104,6 +104,7 @@ function run_hydrostatic_spindown(; refDat = ())
prob_2D,
ShallowWater.ConstantViscosity{FT}(5e3),
nothing,
ShallowWater.SurfaceStress(),
FT(1),
)

Expand Down
15 changes: 11 additions & 4 deletions test/Ocean/SplitExplicit/hydrostatic_spindown.jl
Original file line number Diff line number Diff line change
Expand Up @@ -147,6 +147,7 @@ function run_hydrostatic_spindown(;
prob_2D,
ShallowWater.ConstantViscosity{FT}(model_3D.νʰ),
nothing,
ShallowWater.IntegratedTendency(),
FT(1),
)

Expand Down Expand Up @@ -204,7 +205,12 @@ function run_hydrostatic_spindown(;
lsrk_3D = LSRK54CarpenterKennedy(dg_3D, Q_3D, dt = dt_slow, t0 = 0)
lsrk_2D = LSRK54CarpenterKennedy(dg_2D, Q_2D, dt = dt_fast, t0 = 0)

odesolver = SplitExplicitSolver(lsrk_3D, lsrk_2D; coupled = coupled)
odesolver = SplitExplicitSolver(
lsrk_3D,
lsrk_2D;
coupled = coupled,
reconcile = reconcile,
)

step = [0, 0]
cbvector = make_callbacks(
Expand Down Expand Up @@ -323,8 +329,9 @@ function make_callbacks(
cbcs_dg = ClimateMachine.StateCheck.sccreate(
[
(Q_slow, "3D state"),
# dg_slow.state_auxiliary, "3D aux"),
(dg_slow.state_auxiliary, "3D aux"),
(Q_fast, "2D state"),
(dg_fast.state_auxiliary, "2D aux"),
],
nout;
prec = 12,
Expand All @@ -341,8 +348,8 @@ vtkpath = "vtk_split"

const timeend = 24 * 3600 # s
const tout = 2 * 3600 # s
const timeend = 1200 # s
const tout = 300 # s
# const timeend = 1200 # s
# const tout = 300 # s

const N = 4
const= 5
Expand Down

0 comments on commit 6c6b594

Please sign in to comment.