Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
110 commits
Select commit Hold shift + click to select a range
858d248
Add `floodplain` to kinematic river flow
vers-w Mar 11, 2026
bf8276e
Move `floodplain` to separate file
vers-w Mar 11, 2026
5032ea5
Add `bankfull_storage` to kinematic wave river
vers-w Mar 11, 2026
935d4d9
Separate init kinwave and local inertial floodplain
vers-w Mar 12, 2026
4d2f16c
Refactor surface flow routing
vers-w Mar 17, 2026
94a1ec4
Change abstract surface flow routing types
vers-w Mar 18, 2026
fcdc233
Update docstrings
vers-w Mar 18, 2026
7131e20
Renaming of init functions surface flow routing
vers-w Mar 18, 2026
832dbc5
Refactor init local inertial river flow parameters
vers-w Mar 19, 2026
37ea6bf
Merge branch 'master' into feat/kinwave_floodplain
vers-w Mar 23, 2026
7e85c49
Update info log message
vers-w Mar 24, 2026
c4bf8be
Add init kinwave staggered river flow
vers-w Mar 24, 2026
ab7ab0c
Refactor init river flow staggered a bit
vers-w Mar 25, 2026
a58cccf
Use split up of local_inertial_river_update! function
vers-w Mar 25, 2026
d7b1e7e
Init parameter `h_thresh` staggered kinematic wave
vers-w Mar 25, 2026
ac0f1f8
Fix typo
vers-w Mar 26, 2026
54cd40d
Fix slope computation
vers-w Mar 26, 2026
88a918b
Add update manning's river flow staggered grid
vers-w Mar 26, 2026
cc924c0
Refactor init staggered routing
vers-w Mar 30, 2026
fd91dd9
Add `stable_timestep` function `ManningStaggered`
vers-w Mar 30, 2026
121ba99
Some fixes
vers-w Mar 30, 2026
b86f3ab
Revert `river_routing` TOML setting change
vers-w Mar 30, 2026
992fe92
Add TOML setting `alpha` staggered manning flow
vers-w Mar 31, 2026
22936f7
Rename file `surface_local_inertial.jl`
vers-w Mar 31, 2026
e5ffb8c
Add test river and floodplain Manning's flow on staggered grid
vers-w Apr 1, 2026
0e0abb9
Add missing toml file
vers-w Apr 1, 2026
a6715eb
Some ordering and renaming
vers-w Apr 1, 2026
5a05a01
Add floodplain model for kinematic wave
vers-w Apr 7, 2026
2f6ad38
Simplify dispatching on floodplain model
vers-w Apr 7, 2026
7f2316d
Init manning flow parameters
vers-w Apr 7, 2026
a1b1d4d
Use separate structs river and overland flow variables
vers-w Apr 8, 2026
e193cdc
Add kinematic wave flood routing
vers-w Apr 13, 2026
33ab154
Use function for wetted perimeter channel
vers-w Apr 13, 2026
db4afdd
Refactor computation of floodplain variables
vers-w Apr 14, 2026
d2c5e45
Use function for active floodplain cells
vers-w Apr 14, 2026
7ff7e8c
Move update kinematic wave floodplain to function
vers-w Apr 15, 2026
0f70c6e
Separate routing for floodplain
vers-w May 5, 2026
339d35d
Merge branch 'master' into feat/kinwave_floodplain
vers-w May 6, 2026
f34afb0
Merge branch 'master' into feat/kinwave_floodplain
vers-w May 7, 2026
f8f5069
Support mass balance computation `ManningStaggered`
vers-w May 11, 2026
69c9979
Merge branch 'master' into feat/kinwave_floodplain
vers-w May 12, 2026
dbd1969
Merge branch 'master' into feat/kinwave_floodplain
vers-w May 26, 2026
bb5782d
Merge branch 'master' into feat/kinwave_floodplain
vers-w Jun 1, 2026
72797ee
Merge branch 'master' into feat/kinwave_floodplain
vers-w Jun 3, 2026
fcff1b3
Merge branch 'master' into feat/kinwave_floodplain
vers-w Jun 3, 2026
43651d8
Consistent use of `at_edge`
vers-w Jun 3, 2026
9c2c9f5
Explain `FloodPlainModel` `domain`
vers-w Jun 4, 2026
680fb28
Address review comment
vers-w Jun 4, 2026
953eacd
Address review comment
vers-w Jun 4, 2026
e7d3047
Remove `Float64` `hydraulic_radius_pow`
vers-w Jun 4, 2026
a19a519
Address review comment
vers-w Jun 4, 2026
3bfa352
Use constant `BETA_KINWAVE` for `celerity` computation
vers-w Jun 4, 2026
a951f2e
Compute stable timestep using variables at edges
vers-w Jun 4, 2026
bc61814
Remove magic number
vers-w Jun 4, 2026
156c4c7
Address review comment
vers-w Jun 4, 2026
0a85945
Improve docstring for `FloodPlainModel`
vers-w Jun 5, 2026
8deb87d
Add docstrings related to `FloodPlainModel`
vers-w Jun 5, 2026
b9c4612
Update and add docstrings
vers-w Jun 5, 2026
5100d42
Some more docstrings
vers-w Jun 5, 2026
860ed61
Update `stable_timestep` staggered scheme
vers-w Jun 8, 2026
1add29c
Add small comment
vers-w Jun 8, 2026
810bda5
Add docstring and renaming function
vers-w Jun 8, 2026
6f3a271
Update docs routing on staggered grid
vers-w Jun 8, 2026
db41a72
Fix links staggered grid docs
vers-w Jun 8, 2026
b91c95b
Merge branch 'master' into feat/kinwave_floodplain
vers-w Jun 8, 2026
5caf409
Add docs floodplain routing kinematic wave
vers-w Jun 9, 2026
970c00a
Update docs and introduce standard name `floodplain__slope`
vers-w Jun 9, 2026
3771eb6
Update routing_metadata json output
vers-w Jun 9, 2026
79fe9fe
Update model_config docs
vers-w Jun 9, 2026
f87acd7
Small formatting
vers-w Jun 9, 2026
d345b23
Update faq docs
vers-w Jun 9, 2026
a4b5b70
Remove flow_area from test description
vers-w Jun 10, 2026
0f2d868
Merge branch 'master' into feat/kinwave_floodplain
vers-w Jun 10, 2026
753729c
Use `floodplain__slope` for kinematic wave floodplain
vers-w Jun 10, 2026
e215ba9
Merge branch 'master' into feat/kinwave_floodplain
vers-w Jun 10, 2026
0677036
Add unit test river flow with floodplain
vers-w Jun 11, 2026
252f9f2
Small change comment in unit test
vers-w Jun 11, 2026
026dde3
Add unit test kinematic wave routing with floodplain
vers-w Jun 11, 2026
d23346f
Update model settings docs
vers-w Jun 11, 2026
ee06568
Rename inds `EdgeConnectivity`
vers-w Jun 11, 2026
3c6df1e
Merge branch 'master' into feat/kinwave_floodplain
vers-w Jun 12, 2026
9174b86
Update struct model docs
vers-w Jun 12, 2026
405a2f0
Update changelog
vers-w Jun 12, 2026
5b801c0
Update docs model parameters staggered grid
vers-w Jun 12, 2026
8b46eaf
Fix some doc tags model parameters
vers-w Jun 12, 2026
751925a
Formatting and typo docs routing parameters
vers-w Jun 12, 2026
29aea9f
Fix missing space in changelog
vers-w Jun 12, 2026
e454e14
Rename routing method kinematic wave floodplain
vers-w Jun 12, 2026
9396140
Fix `NaN`/`Inf` values floodplain hydraulic radius
vers-w Jun 16, 2026
2f8d803
Remove check active floodplain index
vers-w Jun 16, 2026
81a3408
Merge branch 'master' into feat/kinwave_floodplain
vers-w Jul 2, 2026
5faf1fd
Fix large `q` fluctuations `manning_staggered` routing
vers-w Jul 3, 2026
c946f0f
Merge branch 'master' into feat/kinwave_floodplain
vers-w Jul 3, 2026
36b12d9
Address review comment
vers-w Jul 3, 2026
61b5d5f
Small change "upwind" option `manning_staggered`
vers-w Jul 3, 2026
5adc8d2
Merge branch 'master' into feat/kinwave_floodplain
vers-w Jul 6, 2026
20ce151
Address review comment
vers-w Jul 6, 2026
7fe5253
Fix states kinematic wave flood routing
vers-w Jul 8, 2026
7b31faf
Merge branch 'master' into feat/kinwave_floodplain
vers-w Jul 8, 2026
444e263
Update docs Model structure
vers-w Jul 8, 2026
13dd728
Update docs state kinematic wave floodplain
vers-w Jul 8, 2026
63b0cbb
Merge branch 'master' into feat/kinwave_floodplain
JoostBuitink Jul 13, 2026
b5a05a3
Merge branch 'master' into feat/kinwave_floodplain
JoostBuitink Jul 13, 2026
58fdc01
Update tests
vers-w Jul 13, 2026
62b8ca1
Merge branch 'master' into feat/kinwave_floodplain
vers-w Jul 13, 2026
32a2168
Remove `hydraulic_radius` check floodplain
vers-w Jul 14, 2026
3228a4c
Merge branch 'master' into feat/kinwave_floodplain
vers-w Jul 15, 2026
92ea747
Fix `dt` input `update_floodplain_model!`
vers-w Jul 15, 2026
3438eef
Fix reading `alpha_coefficient` `manning_staggered`
vers-w Jul 15, 2026
e4f94f7
Revert small change used for testing
vers-w Jul 15, 2026
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 6 additions & 2 deletions Wflow/src/Wflow.jl
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,8 @@ const VERSION =
VersionNumber(TOML.parsefile(joinpath(@__DIR__, "..", "Project.toml"))["version"])

const GRAVITATIONAL_ACCELERATION = 9.80665 # m s⁻²
# local drain direction pit [-]
const LDD_PIT = 5

mutable struct Clock{T}
time::T
Expand Down Expand Up @@ -139,7 +141,7 @@ include("routing/routing.jl")
include("domain.jl")

"""
Model{R <: Routing, L <: AbstractLandModel, M <: AbstractMassBalance, T <: AbstractModelType} <: AbstractModel{T}
Model{R <: Routing, L <: AbstractLandModel, M <: AbstractMassBalance, W <: Writer, T <: AbstractModelType} <: AbstractModel{T}

Composite type that represents all different aspects of a Wflow Model, such as the network,
parameters, clock, configuration and input and output.
Expand Down Expand Up @@ -209,8 +211,10 @@ include("routing/subsurface/lateral_subsurface_flow.jl")
include("routing/subsurface/subsurface_process.jl")
include("routing/subsurface/boundary_conditions.jl")
include("routing/surface/reservoir.jl")
include("routing/surface/floodplain.jl")
include("routing/surface/surface_flow.jl")
include("routing/surface/surface_kinwave.jl")
include("routing/surface/surface_local_inertial.jl")
include("routing/surface/surface_staggered_scheme.jl")
include("routing/surface/surface_routing.jl")
include("routing/surface/surface_process.jl")
include("demand/water_demand.jl")
Expand Down
18 changes: 9 additions & 9 deletions Wflow/src/bmi.jl
Original file line number Diff line number Diff line change
Expand Up @@ -312,9 +312,9 @@ function BMI.get_grid_edge_count(model::Model, grid::Int)
if grid == 3
return ne(domain.river.network.graph)
elseif grid == 4
return length(domain.land.network.edge_indices.idx_right)
return length(domain.land.network.edge_indices.ind_x_up)
elseif grid == 5
return length(domain.land.network.edge_indices.idx_up)
return length(domain.land.network.edge_indices.ind_y_up)
elseif grid in 0:2 || grid == 6
@warn("edges are not provided for grid type $grid (variables are located at nodes)")
else
Expand All @@ -334,16 +334,16 @@ function BMI.get_grid_edge_nodes(model::Model, grid::Int, edge_nodes::Vector{Int
edge_nodes[range(2, n; step = 2)] = nodes_at_edge.dst
return edge_nodes
elseif grid == 4
idx_right = domain.land.network.edge_indices.idx_right
ind_x_up = domain.land.network.edge_indices.ind_x_up
edge_nodes[range(1, n; step = 2)] = 1:m
idx_right[idx_right .== m + 1] .= -999
edge_nodes[range(2, n; step = 2)] = idx_right
ind_x_up[ind_x_up .== m + 1] .= -999
edge_nodes[range(2, n; step = 2)] = ind_x_up
return edge_nodes
elseif grid == 5
idx_up = domain.land.network.edge_indices.idx_up
ind_y_up = domain.land.network.edge_indices.ind_y_up
edge_nodes[range(1, n; step = 2)] = 1:m
idx_up[idx_up .== m + 1] .= -999
edge_nodes[range(2, n; step = 2)] = idx_up
ind_y_up[ind_y_up .== m + 1] .= -999
edge_nodes[range(2, n; step = 2)] = ind_y_up
return edge_nodes
elseif grid in 0:2 || grid == 6
@warn("edges are not provided for grid type $grid (variables are located at nodes)")
Expand Down Expand Up @@ -408,7 +408,7 @@ Return the grid element type of a model variable (PropertyLens `var`) based on a
function grid_element_type(
::T,
var::PropertyLens,
) where {T <: Union{LocalInertialRiverFlowModel, LocalInertialOverlandFlowModel}}
) where {T <: Union{RiverFlowModel{<:LocalInertial}, OverlandFlowModel{<:LocalInertial}}}
vars = (PropertyLens(x) for x in (:q, :q_average, :qx, :qy))
element_type = if var in vars
"edge"
Expand Down
7 changes: 5 additions & 2 deletions Wflow/src/config_structure.jl
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ For configuration files we use TOML.
=#

# Option enumerators
@enumx RoutingType kinematic_wave local_inertial
@enumx RoutingType kinematic_wave manning_staggered local_inertial
@enumx ModelType sbm sbm_gwf sediment
@enumx CalendarType standard gregorian proleptic_gregorian julian noleap _365_day all_leap _366_day _360_day
@enumx GwfConductivityProfileType uniform exponential
Expand Down Expand Up @@ -91,11 +91,14 @@ end
river_local_inertial_flow__alpha_coefficient::Float64 = 0.7
land_local_inertial_flow__alpha_coefficient::Float64 = 0.7
land_local_inertial_flow__theta_coefficient::Float64 = 1.0
river_water_flow_threshold__depth = 1e-3
land_surface_water_flow_threshold__depth = 1e-3
river_water_flow__froude_limit_flag = true
land_surface_water_flow__froude_limit_flag = true
# Local inertial and staggered manning river flow routing
river_water_flow_threshold__depth = 1e-3
floodplain_1d__flag::Bool = false
# Staggered manning river flow routing
river_staggered_manning_flow__alpha_coefficient::Float64 = 0.7
# Groundwater flow
conductivity_profile::GwfConductivityProfileType.T = GwfConductivityProfileType.uniform
drain__flag::Bool = false
Expand Down
3 changes: 2 additions & 1 deletion Wflow/src/domain.jl
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,8 @@ function Domain(dataset::NCDataset, config::Config, ::Union{SbmModel, SbmGwfMode
if river_routing == RoutingType.kinematic_wave
@reset network_river.upstream_nodes =
filter_upstream_nodes(network_river.graph, pits[network_river.indices])
elseif river_routing == RoutingType.local_inertial
elseif river_routing == RoutingType.local_inertial ||
river_routing == RoutingType.manning_staggered
nodes_at_edge, index_pit = NodesAtEdge(network_river)
@reset network_river.nodes_at_edge = nodes_at_edge
@reset network_river.pit_indices = network_river.indices[index_pit]
Expand Down
48 changes: 25 additions & 23 deletions Wflow/src/mass_balance.jl
Original file line number Diff line number Diff line change
Expand Up @@ -125,13 +125,12 @@ function compute_total_storage!(
end

"""
get_storage(river_flow_model::LocalInertialRiverFlowModel, i)
get_storage(river_flow_model::KinWaveRiverFlowModel, i)
get_storage(river_flow_model::RiverFlowModel, i)

Return storage of a river flow model at index `i`. For `LocalInertialRiverFlowModel` floodplain
storage is added to river storage if an optional floodplain is included.
Return storage of a river flow model at index `i`, floodplain storage is added to river
storage if an optional floodplain is included.
"""
function get_storage(river_flow_model::LocalInertialRiverFlowModel, i)
function get_storage(river_flow_model::AbstractRiverFlowModel, i)
(; storage) = river_flow_model.variables
if isnothing(river_flow_model.floodplain)
return storage[i]
Expand All @@ -140,8 +139,6 @@ function get_storage(river_flow_model::LocalInertialRiverFlowModel, i)
return total_storage
end
end
get_storage(river_flow_model::KinWaveRiverFlowModel, i) =
river_flow_model.variables.storage[i]

"""
Save river (+ floodplain) storage at previous time step as `storage_prev` of river
Expand Down Expand Up @@ -291,20 +288,24 @@ compute_flow_balance!(reservoir_model::Nothing, water_balance::NoMassBalance, dt

"Compute water mass balance error and relative error for river kinematic wave routing."
function compute_flow_balance!(
river_flow_model::KinWaveRiverFlowModel,
river_flow_model::RiverFlowModel{<:KinematicWave},
water_balance::MassBalance,
network::NetworkRiver,
dt::Float64,
)
(; storage_prev, error, relative_error) = water_balance
(; inwater, external_inflow, actual_external_abstraction_average, abstraction) =
river_flow_model.boundary_conditions
(; qin_average, q_average, storage) = river_flow_model.variables
(; qin_average, q_average) = river_flow_model.variables

for i in eachindex(storage_prev)
total_in = inwater[i] + qin_average[i] + max(0.0, external_inflow[i])
total_out = q_average[i] + actual_external_abstraction_average[i] + abstraction[i]
storage_rate = (storage[i] - storage_prev[i]) / dt
storage = river_flow_model.variables.storage[i]
if !isnothing(river_flow_model.floodplain)
storage += river_flow_model.floodplain.variables.storage[i]
end
storage_rate = (storage - storage_prev[i]) / dt
error[i], relative_error[i] =
compute_mass_balance_error(total_in, total_out, storage_rate)
end
Expand All @@ -316,7 +317,7 @@ Compute water mass balance error and relative error for river (and floodplain) l
inertial routing.
"""
function compute_flow_balance!(
river_flow_model::LocalInertialRiverFlowModel,
river_flow_model::RiverFlowModel{<:AbstractStaggeredRoutingMethod},
water_balance::MassBalance,
network::NetworkRiver,
dt::Float64,
Expand All @@ -326,18 +327,17 @@ function compute_flow_balance!(
river_flow_model.boundary_conditions
(; edges_at_node) = network

q_av_average = river_flow_model.variables.q_average
actual_external_abstraction_av_average = actual_external_abstraction_average
(; q_average) = river_flow_model.variables

for i in river_flow_model.parameters.active_n
total_in = 0.0
total_out = 0.0
q_src = sum_at(q_av_average, edges_at_node.src[i])
q_src = sum_at(q_average, edges_at_node.src[i])
total_in, total_out = add_inflow(total_in, total_out, [q_src, inwater[i]])
total_in += max(0.0, external_inflow[i])
q_dst = sum_at(q_av_average, edges_at_node.dst[i])
q_dst = sum_at(q_average, edges_at_node.dst[i])
total_in, total_out = add_outflow(total_in, total_out, q_dst)
total_out += actual_external_abstraction_av_average[i] + abstraction[i]
total_out += actual_external_abstraction_average[i] + abstraction[i]
storage = river_flow_model.variables.storage[i]

if !isnothing(river_flow_model.floodplain)
Expand Down Expand Up @@ -380,7 +380,7 @@ Compute water mass balance error and relative error for overland flow kinematic
routing.
"""
function compute_flow_balance!(
overland_flow_model::KinWaveOverlandFlowModel,
overland_flow_model::OverlandFlowModel{<:KinematicWave},
water_balance::MassBalance,
dt::Float64,
)
Expand All @@ -404,8 +404,8 @@ Compute water mass balance error and relative error for 1D river local inertial
computed for each land cell (total storage) considering both river and overland flow.
"""
function compute_flow_balance!(
river_flow_model::LocalInertialRiverFlowModel,
overland_flow_model::LocalInertialOverlandFlowModel,
river_flow_model::RiverFlowModel{<:LocalInertial},
overland_flow_model::OverlandFlowModel{<:LocalInertial},
water_balance::MassBalance,
domain::Domain,
dt::Float64,
Expand All @@ -426,14 +426,14 @@ function compute_flow_balance!(
qy_av_average = qy_average

for i in 1:(overland_flow_model.parameters.n)
idx_down = indices.idx_down[i]
idx_left = indices.idx_left[i]
ind_y_down = indices.ind_y_down[i]
ind_x_down = indices.ind_x_down[i]
total_in = 0.0
total_out = 0.0
total_in, total_out = add_inflow(
total_in,
total_out,
[qx_av_average[idx_left], qy_av_average[idx_down], runoff[i]],
[qx_av_average[ind_x_down], qy_av_average[ind_y_down], runoff[i]],
)
total_in, total_out =
add_outflow(total_in, total_out, [qx_av_average[i], qy_av_average[i]])
Expand Down Expand Up @@ -512,7 +512,9 @@ end

function compute_flow_routing_balance!(
model::Model{R},
) where {R <: Routing{<:LocalInertialOverlandFlowModel, <:LocalInertialRiverFlowModel}}
) where {
R <: Routing{<:OverlandFlowModel{<:LocalInertial}, <:RiverFlowModel{<:LocalInertial}},
}
(; river_flow, overland_flow, subsurface_flow) = model.routing
(; reservoir) = river_flow.boundary_conditions
(; overland_water_balance, reservoir_water_balance, subsurface_water_balance) =
Expand Down
30 changes: 16 additions & 14 deletions Wflow/src/network.jl
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# maps the fields of struct `EdgeConnectivity` to the defined Wflow cartesian indices of
# const `neighbors`.
const DIRS = (:idx_down, :idx_left, :idx_right, :idx_up)
const DIRS = (:ind_y_down, :ind_x_down, :ind_x_up, :ind_y_up)

"""
Struct for storing 2D staggered grid edge connectivity in `x` and `y` directions. For
Expand All @@ -15,19 +15,21 @@ Edges without neighbors are handled by an extra index (at `n + 1`, with `n` edge
linear index `i` of the `EdgeConnectivity` fields represents the edge between node index `i`
and the neighboring nodes in the CartesianIndex(-1,0) and CartesianIndex(0,-1) directions.
The edges are defined as follows:
- `idx_right` is the edge between node `i` and node `idx_right` in the `CartesianIndex(1,0)` direction.
- `idx_left` is the edge between node `idx_left` in the `CartesianIndex(-1,0)` direction and the
neighboring node (CartesianIndex(-2,0) direction).
- `idx_up` is the edge between node `i` and node `idx_up` in the `CartesianIndex(0,1)` direction.
- `idx_down` is the edge between node `idx_down` in the `CartesianIndex(0,-1)` direction and the
neighboring node (`CartesianIndex(0,-2)` direction).
- `ind_x_up` is the edge between node `i` and node `ind_x_up` in the `CartesianIndex(1,0)`
direction.
- `ind_x_down` is the edge between node `ind_x_down` in the `CartesianIndex(-1,0)` direction
and the neighboring node (CartesianIndex(-2,0) direction).
- `ind_y_up` is the edge between node `i` and node `ind_y_up` in the `CartesianIndex(0,1)`
direction.
- `ind_y_down` is the edge between node `ind_y_down` in the `CartesianIndex(0,-1)` direction
and the neighboring node (`CartesianIndex(0,-2)` direction).
"""
@with_kw struct EdgeConnectivity
n::Int
idx_right::Vector{Int} = zeros(Int, n)
idx_left::Vector{Int} = zeros(Int, n)
idx_up::Vector{Int} = zeros(Int, n)
idx_down::Vector{Int} = zeros(Int, n)
ind_x_up::Vector{Int} = zeros(Int, n)
ind_x_down::Vector{Int} = zeros(Int, n)
ind_y_up::Vector{Int} = zeros(Int, n)
ind_y_down::Vector{Int} = zeros(Int, n)
end

"Struct for storing source `src` node and destination `dst` node of an edge."
Expand Down Expand Up @@ -115,7 +117,7 @@ nthreads > 1 to run the kinematic wave parallel, otherwise it is equal to the co
domain.
"""
function network_subdomains(config::Config, network::NetworkLand)
pit_inds = findall(x -> x == 5, network.local_drain_direction)
pit_inds = findall(x -> x == LDD_PIT, network.local_drain_direction)
order_of_subdomains, subdomain_inds, toposort_subdomain = kinwave_set_subdomains(
network.graph,
network.order,
Expand Down Expand Up @@ -261,7 +263,7 @@ nthreads > 1 to run the kinematic wave parallel, otherwise it is equal to the co
domain.
"""
function network_subdomains(config::Config, network::NetworkRiver)
pit_inds = findall(x -> x == 5, network.local_drain_direction)
pit_inds = findall(x -> x == LDD_PIT, network.local_drain_direction)
order_of_subdomains, subdomain_inds, toposort_subdomain = kinwave_set_subdomains(
network.graph,
network.order,
Expand All @@ -277,7 +279,7 @@ end

"Initialize `NodesAtEdge`"
function NodesAtEdge(network::NetworkRiver)
index_pit = findall(x -> x == 5, network.local_drain_direction)
index_pit = findall(x -> x == LDD_PIT, network.local_drain_direction)
add_vertex_edge_graph!(network.graph, index_pit)
nodes_at_edge = NodesAtEdge(; adjacent_nodes_at_edge(network.graph)...)
return nodes_at_edge, index_pit
Expand Down
12 changes: 7 additions & 5 deletions Wflow/src/routing/initialize_routing.jl
Original file line number Diff line number Diff line change
Expand Up @@ -52,9 +52,9 @@ function initialize_overland_flow(dataset::NCDataset, config::Config, domain::Do
(; land_routing) = config.model

if land_routing == RoutingType.kinematic_wave
overland_flow = KinWaveOverlandFlowModel(dataset, config, domain.land)
overland_flow = init_kinematic_wave_overland_flow(dataset, config, domain.land)
elseif land_routing == RoutingType.local_inertial
overland_flow = LocalInertialOverlandFlowModel(dataset, config, domain)
overland_flow = init_local_inertial_overland_flow(dataset, config, domain)
end
return overland_flow
end
Expand All @@ -71,9 +71,11 @@ function initialize_river_flow(dataset::NCDataset, config::Config, domain::Domai
ReservoirModel(dataset, config, domain.reservoir.network) : nothing

if river_routing == RoutingType.kinematic_wave
river_flow = KinWaveRiverFlowModel(dataset, config, domain.river, reservoir)
elseif river_routing == RoutingType.local_inertial
river_flow = LocalInertialRiverFlowModel(dataset, config, domain.river, reservoir)
river_flow =
init_kinematic_wave_river_flow(dataset, config, domain.river, reservoir)
elseif river_routing == RoutingType.local_inertial ||
river_routing == RoutingType.manning_staggered
river_flow = init_staggered_river_flow(dataset, config, domain.river, reservoir)
end
end

Expand Down
12 changes: 10 additions & 2 deletions Wflow/src/routing/routing.jl
Original file line number Diff line number Diff line change
@@ -1,6 +1,14 @@
abstract type AbstractSubsurfaceFlowModel end
abstract type AbstractOverlandFlowModel end
abstract type AbstractRiverFlowModel end
abstract type AbstractOverlandFlowModel end
abstract type AbstractSubsurfaceFlowModel end

abstract type AbstractRoutingMethod end
abstract type AbstractStaggeredRoutingMethod <: AbstractRoutingMethod end

struct Manning <: AbstractRoutingMethod end
struct KinematicWave <: AbstractRoutingMethod end
struct ManningStaggered <: AbstractStaggeredRoutingMethod end
struct LocalInertial <: AbstractStaggeredRoutingMethod end

struct NoSubsurfaceFlow <: AbstractSubsurfaceFlowModel end
struct NoOverlandFlow <: AbstractOverlandFlowModel end
Expand Down
Loading