From 34ba2ecea98dece068a08a01a22c1aa47e1d4209 Mon Sep 17 00:00:00 2001 From: Bart de Koning <74617371+SouthEndMusic@users.noreply.github.com> Date: Thu, 14 Nov 2024 11:51:35 +0100 Subject: [PATCH] Use FlatVector for generating concentration table (#1933) Fixes https://github.com/Deltares/Ribasim/issues/1907. --- core/src/parameter.jl | 8 ++++---- core/src/write.jl | 11 +---------- 2 files changed, 5 insertions(+), 14 deletions(-) diff --git a/core/src/parameter.jl b/core/src/parameter.jl index 97bc1cab3..48a58e4a0 100644 --- a/core/src/parameter.jl +++ b/core/src/parameter.jl @@ -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. @@ -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 """ diff --git a/core/src/write.jl b/core/src/write.jl index 39a706d97..bb3ad0472 100644 --- a/core/src/write.jl +++ b/core/src/write.jl @@ -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)