This commit places more conditions on the branch discovery order
than the previous work in commit 6d3ee57dd. In particular, we now
ensure that branches are discovered ("created") in the order of
increasing segment number of the branch outlet segment.
Furthermore, if multiple branches have the same outlet segment, then
we sort those branches on their increasing branch IDs.
To this end, switch from using a std::queue<int> to using a
std::priority_queue<KickOffPoint>, with the KickOffPoint being a
custom structure holding the kick-off segment, the branch outlet
segment, and the branch ID and a custom operator<() to plug into the
priority_queue<> heap mechanism.
This new sort order changes the result of certain unit tests, but
those changes are expected and desired.
The existing algorithm was a little too fragile and dependent on
branch numbers. This new version starts at segment 1/branch 1 and
follows Segment::inletSegments() in depth-first order, taking care
to enqueue new branches as they're encountered instead of in
numerical order. We search to the end of each branch before
switching to the next branch. This ensures determinism regardless
of branch numbering and input ordering.
While here, switch iLBR_ to a WindowedMatrix<int> to simplify branch
references in the output table.
The value in ISEG[0] does not necessarily correspond to the search
order of that segment. Rather, ISEG[0] is the depth-first ordering
of the segment search tree when traversing kick-off branches before
the main stem from which those branches kick off.
The current code that aggregates flow rates from connection to
segment levels assumes that the simulator generates connection
results for the open connections only. Relax this restriction as
upcoming work in the context of WELPI will require generating at
least the CTFs even for shut connections.
- Change SummaryState::add() -> SummaryState::update(), the
SummaryState::update() method is semantically aware of totals.
- Add an internal variable to the SummaryState class to keep track of the
elapsed simulation time.