@@ -5,19 +5,30 @@ Set initial salinity and temperature staircases in `model`.
55function set_staircase_initial_conditions! (model, ics:: StepInitialConditions )
66
77 depth_of_steps = ics. depth_of_steps
8+ z = znodes (model. grid, Center ())
89 S = ics. salinity_values
910 T = ics. temperature_values
10- initial_S_steps (x, y, z) = set_steps (z, S, depth_of_steps)
11- initial_T_steps (x, y, z) = set_steps (z, T, depth_of_steps)
1211
13- set! (model, S = initial_S_steps, T = initial_T_steps)
12+ S₀ = similar (interior (model. tracers. S, :, :, :))
13+ T₀ = similar (interior (model. tracers. T, :, :, :))
14+ S₀[:, :, z .> depth_of_steps[1 ]] .= S[1 ]
15+ T₀[:, :, z .> depth_of_steps[1 ]] .= T[1 ]
16+ for i ∈ 1 : length (depth_of_steps)- 1
17+ S₀[:, :, depth_of_steps[i+ 1 ] .≤ z .< depth_of_steps[i]] .= S[i]
18+ T₀[:, :, depth_of_steps[i+ 1 ] .≤ z .< depth_of_steps[i]] .= T[i]
19+ end
20+ S₀[:, :, z .< depth_of_steps[end ]] .= S[end ]
21+ T₀[:, :, z .< depth_of_steps[end ]] .= T[end ]
22+
23+ set! (model, S = S₀, T = T₀)
1424
1525 return nothing
1626end
1727function set_staircase_initial_conditions! (model, ics:: SmoothStepInitialConditions )
1828
1929 # TODO : write methods to set smooth changes using the function provied in
20- # `ics::SmoothStepInitialConditions`.
30+ # `ics::SmoothStepInitialConditions`. I can use something like the above
31+ # normalise then set with the smoothing function
2132 # set!(model, S = initial_S_steps, T = initial_T_steps)
2233
2334 return nothing
0 commit comments