hydrobricks
Loading...
Searching...
No Matches
SettingsModel.h
1#ifndef HYDROBRICKS_SETTINGS_MODEL_H
2#define HYDROBRICKS_SETTINGS_MODEL_H
3
4#include <yaml-cpp/yaml.h>
5
6#include "Includes.h"
7#include "Parameter.h"
8
10 string name;
11};
12
14 string start;
15 string end;
16 int timeStep = 1;
17 string timeStepUnit;
18};
19
21 string target;
22 string fluxType = "water";
23 bool isInstantaneous = false;
24 bool isStatic = false;
25};
26
28 string name;
29 string type;
30 vecStr logItems;
31 vector<Parameter*> parameters;
32 vector<VariableType> forcing;
33 vector<OutputSettings> outputs;
34};
35
37 string name;
38 string type;
39 vecStr logItems;
40 vector<Parameter*> parameters;
41 vector<VariableType> forcing;
42 vector<OutputSettings> outputs;
43};
44
46 string name;
47 string type;
48 string parent;
49 vecStr logItems;
50 vector<Parameter*> parameters;
51 vector<VariableType> forcing;
52 vector<ProcessSettings> processes;
53};
54
56 int id;
57 vecStr logItems;
58 vector<BrickSettings> hydroUnitBricks;
59 vector<BrickSettings> subBasinBricks;
60 vecInt landCoverBricks;
61 vecInt surfaceComponentBricks;
62 vector<SplitterSettings> hydroUnitSplitters;
63 vector<SplitterSettings> subBasinSplitters;
64};
65
66class SettingsModel : public wxObject {
67 public:
68 explicit SettingsModel();
69
70 ~SettingsModel() override;
71
72 void SetSolver(const string& solverName);
73
74 void SetTimer(const string& start, const string& end, int timeStep, const string& timeStepUnit);
75
76 void AddHydroUnitBrick(const string& name, const std::string& type = "storage");
77
78 void AddSubBasinBrick(const string& name, const std::string& type = "storage");
79
80 void AddLandCoverBrick(const string& name, const string& type);
81
82 void AddSurfaceComponentBrick(const string& name, const string& type);
83
84 void SetSurfaceComponentParent(const string& name);
85
86 void AddBrickParameter(const string& name, float value, const std::string& type = "constant");
87
88 void SetBrickParameterValue(const string& name, float value, const std::string& type = "constant");
89
90 bool BrickHasParameter(const string& name);
91
92 void AddBrickForcing(const string& name);
93
94 void AddBrickProcess(const string& name, const string& type, const string& target = "", bool log = false);
95
96 void AddProcessParameter(const string& name, float value, const std::string& type = "constant");
97
98 void SetProcessParameterValue(const string& name, float value, const std::string& type = "constant");
99
100 void AddProcessForcing(const string& name);
101
102 void AddProcessOutput(const string& target);
103
104 void SetProcessOutputsAsInstantaneous();
105
106 void SetProcessOutputsAsStatic();
107
108 void OutputProcessToSameBrick();
109
110 void AddHydroUnitSplitter(const string& name, const string& type);
111
112 void AddSubBasinSplitter(const string& name, const string& type);
113
114 void AddSplitterParameter(const string& name, float value, const std::string& type = "constant");
115
116 void SetSplitterParameterValue(const string& name, float value, const std::string& type = "constant");
117
118 void AddSplitterForcing(const string& name);
119
120 void AddSplitterOutput(const string& target, const string& fluxType = "water");
121
122 void AddLoggingToItem(const string& itemName);
123
124 void AddLoggingToItems(std::initializer_list<const string> items);
125
126 void AddBrickLogging(const string& itemName);
127
128 void AddBrickLogging(std::initializer_list<const string> items);
129
130 void AddProcessLogging(const string& itemName);
131
132 void AddSplitterLogging(const string& itemName);
133
134 void GeneratePrecipitationSplitters(bool withSnow);
135
136 void GenerateSnowpacks(const string& snowMeltProcess);
137
138 void GenerateSnowpacksWithWaterRetention(const string& snowMeltProcess, const string& outflowProcess);
139
140 bool SelectStructure(int id);
141
142 void SelectHydroUnitBrick(int index);
143
144 void SelectSubBasinBrick(int index);
145
146 bool SelectHydroUnitBrickIfFound(const string& name);
147
148 bool SelectSubBasinBrickIfFound(const string& name);
149
150 void SelectHydroUnitBrick(const string& name);
151
152 void SelectHydroUnitBrickByName(const string& name);
153
154 void SelectSubBasinBrick(const string& name);
155
156 void SelectProcess(int index);
157
158 void SelectProcess(const string& name);
159
160 void SelectProcessWithParameter(const string& name);
161
162 void SelectHydroUnitSplitter(int index);
163
164 void SelectSubBasinSplitter(int index);
165
166 bool SelectHydroUnitSplitterIfFound(const string& name);
167
168 bool SelectSubBasinSplitterIfFound(const string& name);
169
170 void SelectHydroUnitSplitter(const string& name);
171
172 void SelectSubBasinSplitter(const string& name);
173
174 bool ParseStructure(const string& path);
175
176 bool ParseParameters(const string& path);
177
178 bool SetParameterValue(const string& component, const string& name, float value);
179
180 int GetStructuresNb() const {
181 return int(m_modelStructures.size());
182 }
183
184 int GetHydroUnitBricksNb() const {
185 wxASSERT(m_selectedStructure);
186 return int(m_selectedStructure->hydroUnitBricks.size());
187 }
188
189 int GetSubBasinBricksNb() const {
190 wxASSERT(m_selectedStructure);
191 return int(m_selectedStructure->subBasinBricks.size());
192 }
193
194 int GetSurfaceComponentBricksNb() const {
195 wxASSERT(m_selectedStructure);
196 return int(m_selectedStructure->surfaceComponentBricks.size());
197 }
198
199 int GetProcessesNb() const {
200 wxASSERT(m_selectedBrick);
201 return int(m_selectedBrick->processes.size());
202 }
203
204 int GetHydroUnitSplittersNb() const {
205 wxASSERT(m_selectedStructure);
206 return int(m_selectedStructure->hydroUnitSplitters.size());
207 }
208
209 int GetSubBasinSplittersNb() const {
210 wxASSERT(m_selectedStructure);
211 return int(m_selectedStructure->subBasinSplitters.size());
212 }
213
214 SolverSettings GetSolverSettings() const {
215 return m_solver;
216 }
217
218 TimerSettings GetTimerSettings() const {
219 return m_timer;
220 }
221
222 BrickSettings GetHydroUnitBrickSettings(int index) const {
223 wxASSERT(m_selectedStructure);
224 return m_selectedStructure->hydroUnitBricks[index];
225 }
226
227 BrickSettings GetHydroUnitBrickSettings(const string& name) const {
228 wxASSERT(m_selectedStructure);
229
230 for (auto& brick : m_selectedStructure->hydroUnitBricks) {
231 if (brick.name == name) {
232 return brick;
233 }
234 }
235
236 throw std::runtime_error("Brick not found.");
237 }
238
239 BrickSettings GetSurfaceComponentBrickSettings(int index) const {
240 wxASSERT(m_selectedStructure);
241 int brickIndex = m_selectedStructure->surfaceComponentBricks[index];
242 return m_selectedStructure->hydroUnitBricks[brickIndex];
243 }
244
245 vecInt GetSurfaceComponentBricksIndices() const {
246 wxASSERT(m_selectedStructure);
247 return m_selectedStructure->surfaceComponentBricks;
248 }
249
250 vecInt GetLandCoverBricksIndices() const {
251 wxASSERT(m_selectedStructure);
252 return m_selectedStructure->landCoverBricks;
253 }
254
255 vecStr GetLandCoverBricksNames() const;
256
257 BrickSettings GetSubBasinBrickSettings(int index) const {
258 wxASSERT(m_selectedStructure);
259 return m_selectedStructure->subBasinBricks[index];
260 }
261
262 ProcessSettings GetProcessSettings(int index) const {
263 wxASSERT(m_selectedBrick);
264 return m_selectedBrick->processes[index];
265 }
266
267 SplitterSettings GetHydroUnitSplitterSettings(int index) const {
268 wxASSERT(m_selectedStructure);
269 return m_selectedStructure->hydroUnitSplitters[index];
270 }
271
272 SplitterSettings GetSubBasinSplitterSettings(int index) const {
273 wxASSERT(m_selectedStructure);
274 return m_selectedStructure->subBasinSplitters[index];
275 }
276
277 vecStr GetSubBasinLogLabels();
278
279 vecStr GetSubBasinGenericLogLabels();
280
281 vecStr GetHydroUnitLogLabels();
282
283 void SetLogAll(bool logAll = true) {
284 if (logAll) {
285 wxLogVerbose("Logging all components.");
286 } else {
287 wxLogVerbose("Minimal logging.");
288 }
289 m_logAll = logAll;
290 }
291
292 bool LogAll() {
293 return m_logAll;
294 }
295
296 protected:
297 bool m_logAll;
298 vector<ModelStructure> m_modelStructures;
299 SolverSettings m_solver;
300 TimerSettings m_timer;
301 ModelStructure* m_selectedStructure;
302 BrickSettings* m_selectedBrick;
303 ProcessSettings* m_selectedProcess;
304 SplitterSettings* m_selectedSplitter;
305
306 vecStr ParseLandCoverNames(const YAML::Node& settings);
307
308 vecStr ParseLandCoverTypes(const YAML::Node& settings);
309
310 string ParseSolver(const YAML::Node& settings);
311
312 bool LogAll(const YAML::Node& settings);
313};
314
315#endif // HYDROBRICKS_SETTINGS_MODEL_H
Definition SettingsModel.h:66
Definition SettingsModel.h:45
Definition SettingsModel.h:55
Definition SettingsModel.h:20
Definition SettingsModel.h:27
Definition SettingsModel.h:9
Definition SettingsModel.h:36
Definition SettingsModel.h:13