OpenSWMM Engine  6.0.0-alpha.3
Data-oriented, plugin-extensible SWMM Engine (6.0.0-alpha.3)
Loading...
Searching...
No Matches
RunoffInterface.hpp
Go to the documentation of this file.
1
46
47#ifndef OPENSWMM_RUNOFF_INTERFACE_HPP
48#define OPENSWMM_RUNOFF_INTERFACE_HPP
49
50#include <string>
51#include <vector>
52#include <cstdio>
53
54namespace openswmm {
55
57
58namespace runoff_iface {
59
60static constexpr int N_FIXED_RESULTS = 8;
61static const char FILE_STAMP[] = "SWMM5-RUNOFF";
62
67public:
69
74 int openForWrite(const std::string& path, int n_subcatch, int n_pollut,
75 int flow_units);
76
81 int openForRead(const std::string& path, int n_subcatch, int n_pollut,
82 int flow_units);
83
89 void saveResults(const SimulationContext& ctx, double dt);
90
100 bool readResults(SimulationContext& ctx, double* dt_out = nullptr);
101
103 void close();
104
105 bool isOpen() const { return fp_ != nullptr; }
106
107private:
108 std::FILE* fp_ = nullptr;
109 bool writing_ = false;
110 int n_subcatch_ = 0;
111 int n_pollut_ = 0;
112 int n_results_ = 0;
113 int flow_units_ = 0;
114 int unit_system_ = 0;
115 int step_count_ = 0;
116 long max_steps_pos_ = 0;
117 std::vector<float> buf_;
118};
119
120} // namespace runoff_iface
121} // namespace openswmm
122
123#endif // OPENSWMM_RUNOFF_INTERFACE_HPP
Runoff interface file manager.
Definition RunoffInterface.hpp:66
~RunoffInterfaceFile()
Definition RunoffInterface.hpp:68
int openForWrite(const std::string &path, int n_subcatch, int n_pollut, int flow_units)
Open file for writing (SAVE mode).
Definition RunoffInterface.cpp:33
bool readResults(SimulationContext &ctx, double *dt_out=nullptr)
Read one timestep of runoff results from file.
Definition RunoffInterface.cpp:177
void close()
Close the file and finalize header (write step count for SAVE mode).
Definition RunoffInterface.cpp:224
int openForRead(const std::string &path, int n_subcatch, int n_pollut, int flow_units)
Open file for reading (USE mode).
Definition RunoffInterface.cpp:71
bool isOpen() const
Definition RunoffInterface.hpp:105
void saveResults(const SimulationContext &ctx, double dt)
Save one timestep of runoff results to file.
Definition RunoffInterface.cpp:118
Definition RunoffInterface.cpp:21
Definition NodeCoupling.cpp:15
Central, reentrant simulation context.
Definition SimulationContext.hpp:292