OpenSWMM Engine  6.0.0-alpha.1
Data-oriented, plugin-extensible SWMM Engine (6.0.0-alpha.1)
Loading...
Searching...
No Matches
TableData.hpp File Reference

Time series and rating curve data with bidirectional cursor. More...

#include <string>
#include <vector>
#include <cstdint>
#include <cassert>
#include <algorithm>
Include dependency graph for TableData.hpp:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Classes

struct  openswmm::TableCursor
 Bidirectional cursor tracking the last accessed index in a Table. More...
 
struct  openswmm::Table
 A single time series or rating curve. More...
 
struct  openswmm::TableData
 SoA collection of all time series and curves in the model. More...
 

Namespaces

namespace  openswmm
 

Enumerations

enum class  openswmm::TableType : int {
  openswmm::TIMESERIES = 0 ,
  openswmm::CURVE_STORAGE = 1 ,
  openswmm::CURVE_DIVERSION = 2 ,
  openswmm::CURVE_RATING = 3 ,
  openswmm::CURVE_SHAPE = 4 ,
  openswmm::CURVE_CONTROL = 5 ,
  openswmm::CURVE_TIDAL = 6 ,
  openswmm::CURVE_PUMP1 = 7 ,
  openswmm::CURVE_PUMP2 = 8 ,
  openswmm::CURVE_PUMP3 = 9 ,
  openswmm::CURVE_PUMP4 = 10
}
 Type of data stored in a Table. More...
 

Functions

double openswmm::table_lookup_cursor (Table &tbl, double x_query) noexcept
 Look up a value in a Table using the bidirectional cursor.
 
double openswmm::table_step_cursor (Table &tbl, double x_query) noexcept
 Piecewise-constant (step function) table lookup with cursor.
 

Detailed Description

Time series and rating curve data with bidirectional cursor.

Provides the Table struct (a single time series or curve) and TableData (the SoA collection of all tables in the model), plus the cursor-optimized lookup function.

Cursor Optimization

The legacy SWMM table_lookup() in src/solver/table.c performs a linear scan from index 0 on every call. For a simulation with many output steps and long time series, this becomes O(N*T) total work where N is the number of table entries and T is the number of timesteps.

The new engine uses a bidirectional cursor that remembers where the last lookup landed. For monotonically advancing simulation time (the common case), each lookup costs O(1) — the cursor simply advances one or a few positions. For backward seeks (e.g., restart scenarios), the cursor retreats.

See also
Legacy reference: src/solver/table.c — table_lookup()
tests/unit/test_timeseries_cursor.cpp
tests/benchmarks/bench_timeseries_lookup.cpp
Author
Caleb Buahin caleb.nosp@m..bua.nosp@m.hin@g.nosp@m.mail.nosp@m..com
License\n MIT License