OpenSWMM Engine  6.0.0-alpha.1
Data-oriented, plugin-extensible SWMM Engine (6.0.0-alpha.1)
Loading...
Searching...
No Matches
RunoffInterface.hpp
Go to the documentation of this file.
1
27#ifndef OPENSWMM_RUNOFF_INTERFACE_HPP
28#define OPENSWMM_RUNOFF_INTERFACE_HPP
29
30#include <string>
31#include <vector>
32#include <cstdio>
33
34namespace openswmm {
35
36struct SimulationContext;
37
38namespace runoff_iface {
39
40static constexpr int N_FIXED_RESULTS = 8;
41static const char FILE_STAMP[] = "SWMM5-RUNOFF";
42
47public:
49
54 int openForWrite(const std::string& path, int n_subcatch, int n_pollut,
55 int flow_units);
56
61 int openForRead(const std::string& path, int n_subcatch, int n_pollut,
62 int flow_units);
63
69 void saveResults(const SimulationContext& ctx, double dt);
70
77
79 void close();
80
81 bool isOpen() const { return fp_ != nullptr; }
82
83private:
84 std::FILE* fp_ = nullptr;
85 bool writing_ = false;
86 int n_subcatch_ = 0;
87 int n_pollut_ = 0;
88 int n_results_ = 0;
89 int step_count_ = 0;
90 long max_steps_pos_ = 0;
91 std::vector<float> buf_;
92};
93
94} // namespace runoff_iface
95} // namespace openswmm
96
97#endif // OPENSWMM_RUNOFF_INTERFACE_HPP
Runoff interface file manager.
Definition RunoffInterface.hpp:46
~RunoffInterfaceFile()
Definition RunoffInterface.hpp:48
int openForWrite(const std::string &path, int n_subcatch, int n_pollut, int flow_units)
Open file for writing (SAVE mode).
Definition RunoffInterface.cpp:26
void close()
Close the file and finalize header (write step count for SAVE mode).
Definition RunoffInterface.cpp:184
int openForRead(const std::string &path, int n_subcatch, int n_pollut, int flow_units)
Open file for reading (USE mode).
Definition RunoffInterface.cpp:62
bool isOpen() const
Definition RunoffInterface.hpp:81
void saveResults(const SimulationContext &ctx, double dt)
Save one timestep of runoff results to file.
Definition RunoffInterface.cpp:107
bool readResults(SimulationContext &ctx)
Read one timestep of runoff results from file.
Definition RunoffInterface.cpp:150
Definition NodeCoupling.cpp:15
#define FILE_STAMP
Definition rdii.c:36
Central, reentrant simulation context.
Definition SimulationContext.hpp:274