Skip to content

Commit

Permalink
Use FlatVector for generating concentration table (#1933)
Browse files Browse the repository at this point in the history
Fixes #1907.
  • Loading branch information
SouthEndMusic authored Nov 14, 2024
1 parent dfbdbb1 commit 34ba2ec
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 14 deletions.
8 changes: 4 additions & 4 deletions core/src/parameter.jl
Original file line number Diff line number Diff line change
Expand Up @@ -266,10 +266,6 @@ for discrete control
itp_update::Vector{ParameterUpdate{ScalarInterpolation}} = []
end

abstract type AbstractParameterNode end

abstract type AbstractDemandNode <: AbstractParameterNode end

"""
In-memory storage of saved mean flows for writing to results.
Expand Down Expand Up @@ -307,6 +303,10 @@ In-memory storage of saved instantaneous storages and levels for writing to resu
t::Float64
end

abstract type AbstractParameterNode end

abstract type AbstractDemandNode <: AbstractParameterNode end

"""
Caches of current basin properties
"""
Expand Down
11 changes: 1 addition & 10 deletions core/src/write.jl
Original file line number Diff line number Diff line change
Expand Up @@ -276,18 +276,9 @@ function concentration_table(
ntsteps = length(data.time) - 1
nbasin = length(data.node_id)
nsubstance = length(basin.substances)
nrows = ntsteps * nbasin * nsubstance

substances = String.(basin.substances)
concentration = zeros(nrows)

idx_row = 0
for cvec in saved.flow.saveval
for concentration_ in vec(cvec.concentration)
idx_row += 1
concentration[idx_row] = concentration_
end
end
concentration = FlatVector(saved.flow.saveval, :concentration)

time = repeat(data.time[begin:(end - 1)]; inner = nbasin * nsubstance)
substance = repeat(substances; inner = nbasin, outer = ntsteps)
Expand Down

0 comments on commit 34ba2ec

Please sign in to comment.