Skip to content

Commit

Permalink
Precalculate neighboring edges for ManningResistance
Browse files Browse the repository at this point in the history
  • Loading branch information
SouthEndMusic committed May 8, 2024
1 parent 6425d61 commit a09d4a5
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 10 deletions.
8 changes: 4 additions & 4 deletions core/src/parameter.jl
Original file line number Diff line number Diff line change
Expand Up @@ -275,8 +275,8 @@ end
This is a simple Manning-Gauckler reach connection.
node_id: node ID of the ManningResistance node
inflow_id: node ID across the incoming flow edge
outflow_id: node ID across the outgoing flow edge
inflow_edge: incoming flow edge metadata
outflow_edge: outgoing flow edge metadata
length: reach length
manning_n: roughness; Manning's n in (SI units).
Expand Down Expand Up @@ -309,8 +309,8 @@ Requirements:
"""
struct ManningResistance <: AbstractParameterNode
node_id::Vector{NodeID}
inflow_id::Vector{NodeID}
outflow_id::Vector{NodeID}
inflow_edge::Vector{EdgeMetadata}
outflow_edge::Vector{EdgeMetadata}
active::BitVector
length::Vector{Float64}
manning_n::Vector{Float64}
Expand Down
4 changes: 2 additions & 2 deletions core/src/read.jl
Original file line number Diff line number Diff line change
Expand Up @@ -350,8 +350,8 @@ function ManningResistance(db::DB, config::Config, graph::MetaGraph)::ManningRes

return ManningResistance(
node_id,
inflow_id.(Ref(graph), node_id),
outflow_id.(Ref(graph), node_id),
inflow_edge.(Ref(graph), node_id),
outflow_edge.(Ref(graph), node_id),
BitVector(parsed_parameters.active),
parsed_parameters.length,
parsed_parameters.manning_n,
Expand Down
11 changes: 7 additions & 4 deletions core/src/solve.jl
Original file line number Diff line number Diff line change
Expand Up @@ -452,8 +452,11 @@ function formulate_flow!(
(; node_id, active, length, manning_n, profile_width, profile_slope) =
manning_resistance
for (i, id) in enumerate(node_id)
inflow_id = manning_resistance.inflow_id[i]
outflow_id = manning_resistance.outflow_id[i]
inflow_edge = manning_resistance.inflow_edge[i]
outflow_edge = manning_resistance.outflow_edge[i]

inflow_id = inflow_edge.edge[1]
outflow_id = outflow_edge.edge[2]

if !active[i]
continue
Expand Down Expand Up @@ -492,8 +495,8 @@ function formulate_flow!(

q = q_sign * A / n * R_h^(2 / 3) * sqrt(Δh / L * 2 / π * atan(k * Δh) + eps)

set_flow!(graph, inflow_id, id, q)
set_flow!(graph, id, outflow_id, q)
set_flow!(graph, inflow_edge, q)
set_flow!(graph, outflow_edge, q)
end
return nothing
end
Expand Down

0 comments on commit a09d4a5

Please sign in to comment.