Skip to content

Commit 4379d5e

Browse files
committed
ridges with adjustable position
1 parent 4f7924b commit 4379d5e

File tree

1 file changed

+12
-12
lines changed

1 file changed

+12
-12
lines changed

src/forcing.jl

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -167,24 +167,24 @@ function Ridge(::Type{T},P::Parameter,G::Grid) where {T<:AbstractFloat}
167167
return T.(Hx),T.(Hy)
168168
end
169169

170-
"""Same as Ridge() but for 3 ridges at 1/4,1/2,3/4 of the domain."""
170+
"""Same as Ridge() but for n ridges at various x positions."""
171171
function Ridges(::Type{T},P::Parameter,G::Grid) where {T<:AbstractFloat}
172172

173173
@unpack x_T_halo,y_T_halo,Lx,Ly = G
174174
@unpack topo_width,topo_height,H = P
175+
@unpack topo_ridges_positions = P
176+
n_ridges = length(topo_ridges_positions)
175177

176178
xx_T,yy_T = meshgrid(x_T_halo,y_T_halo)
177179

178-
# bumps in x direction
179-
# shift slightly left/right to avoid a symmetric solution
180-
b0x = exp.(-(xx_T.^2)/(2*topo_width^2))
181-
b1x = exp.(-((xx_T .- 0.99*Lx/4).^2)/(2*topo_width^2))
182-
b2x = exp.(-((xx_T .- 1.01*Lx/2).^2)/(2*topo_width^2))
183-
b3x = exp.(-((xx_T .- 0.99*3*Lx/4).^2)/(2*topo_width^2))
184-
b4x = exp.(-((xx_T .- Lx).^2)/(2*topo_width^2))
180+
# loop over bumps in x direction
181+
R = zero(xx_T) .+ H
185182

186-
th = topo_height # for convenience
187-
return T.(H .- th*b0x .- th*b1x .- th*b2x .- th*b3x .- th*b4x)
183+
for i in 1:n_ridges
184+
R .-= topo_height*exp.(-((xx_T .- topo_ridges_positions[i]*Lx).^2)/(2*topo_width^2))
185+
end
186+
187+
return T.(R)
188188
end
189189

190190
"""Returns a matrix of constant water depth H."""
@@ -213,5 +213,5 @@ end
213213

214214
"""Time evolution of forcing."""
215215
function Ftime(::Type{T},t::Int::Real) where {T<:AbstractFloat}
216-
return T(sin*t))
217-
end
216+
return convert(T,sin*t))
217+
end

0 commit comments

Comments
 (0)