Skip to content

Commit

Permalink
update_subgrid_level!
Browse files Browse the repository at this point in the history
  • Loading branch information
visr committed Dec 16, 2024
1 parent f4c2139 commit 24b8fff
Showing 1 changed file with 14 additions and 3 deletions.
17 changes: 14 additions & 3 deletions core/src/callback.jl
Original file line number Diff line number Diff line change
Expand Up @@ -671,12 +671,23 @@ function apply_parameter_update!(parameter_update)::Nothing
end

function update_subgrid_level!(integrator)::Nothing
(; p) = integrator
(; p, t) = integrator
du = get_du(integrator)
basin_level = p.basin.current_properties.current_level[parent(du)]
subgrid = integrator.p.subgrid
for (i, (index, interp)) in enumerate(zip(subgrid.basin_index, subgrid.interpolations))
subgrid.level[i] = interp(basin_level[index])

i = 0
# First update the all the subgrids with static h(h) relations
for (index, hh_itp) in zip(subgrid.basin_index, subgrid.interpolations)
i += 1
subgrid.level[i] = hh_itp(basin_level[index])
end
# Then update the subgrids with dynamic h(h) relations
for (index, lookup) in zip(subgrid.basin_index_time, current_interpolation_index)
i += 1
itp_index = lookup(t)
hh_itp = subgrid.interpolations_time[itp_index]
subgrid.level[i] = hh_itp(basin_level[index])
end
end

Expand Down

0 comments on commit 24b8fff

Please sign in to comment.